Permalink
Browse files

trailing foreaches

  • Loading branch information...
1 parent c84d11c commit 979b4fed86b57852fd50affa78c67255713eac48 @jeffsu committed Sep 5, 2012
@@ -921,7 +921,7 @@ class Parser
OO.addMember("parse", function(tokens){var self=this;
- var beginning = tokens.match(/^<<(\w+)(?::(\w+))?(.*?)\n/);
+ var beginning = tokens.match(/^<<(\w+)(?::(\w+))?(.*?)?\n/);
var terminator = beginning[1];
tokens.consume(beginning[0].length);
@@ -1108,7 +1108,7 @@ class Parser
OO.addMember("_TYPE", 'Foreach');
- var REGEX = Tokens.regex("<FOREACH><LBRACE><VAR> <IDENT>(?:**:**<IDENT>)? in (.*?)**<RBRACE>**{");
+ var REGEX = Tokens.regex("<FOREACH><LBRACE><VAR> <IDENT>(?:**:**<IDENT>)? in (.*?)**<RBRACE>**");
OO.addMember("startParse", function(tokens){var self=this;
@@ -908,7 +908,7 @@ RootParser.extend("HereDocParser", function(KLASS, OO){
OO.addMember("parse", function(tokens){var self=this;
- var beginning = tokens.match(/^<<(\w+)(?::(\w+))?(.*?)\n/);
+ var beginning = tokens.match(/^<<(\w+)(?::(\w+))?(.*?)?\n/);
var terminator = beginning[1];
tokens.consume(beginning[0].length);
@@ -1095,7 +1095,7 @@ CurlyParser.extend("ForeachParser", function(KLASS, OO){
OO.addMember("_TYPE", 'Foreach');
- var REGEX = Tokens.regex("<FOREACH><LBRACE><VAR> <IDENT>(?:**:**<IDENT>)? in (.*?)**<RBRACE>**{");
+ var REGEX = Tokens.regex("<FOREACH><LBRACE><VAR> <IDENT>(?:**:**<IDENT>)? in (.*?)**<RBRACE>**");
OO.addMember("startParse", function(tokens){var self=this;
View
@@ -361,7 +361,7 @@ class HereDocParser extends RootParser {
}
function parse(tokens) {
- var beginning = tokens.match(/^<<(\w+)(?::(\w+))?(.*?)\n/);
+ var beginning = tokens.match(/^<<(\w+)(?::(\w+))?(.*?)?\n/);
var terminator = beginning[1];
tokens.consume(beginning[0].length);
@@ -548,7 +548,7 @@ class ForeachParser extends CurlyParser {
var _TYPE = 'Foreach';
private {
- var REGEX = Tokens.regex("<FOREACH><LBRACE><VAR> <IDENT>(?:**:**<IDENT>)? in (.*?)**<RBRACE>**{");
+ var REGEX = Tokens.regex("<FOREACH><LBRACE><VAR> <IDENT>(?:**:**<IDENT>)? in (.*?)**<RBRACE>**");
}
function startParse(tokens) {
@@ -0,0 +1,5 @@
+var list = [ 'hello', 'world', 'foo', 'bar', null, {}, false, 'bar2' ];
+
+foreach (var item in list) container = item;
+
+$m.test(#{ $1.eq(container, 'bar2') });

0 comments on commit 979b4fe

Please sign in to comment.