summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2013-07-24 23:43:56 -0500
committerkpdecker <kpdecker@gmail.com>2013-07-24 23:43:56 -0500
commit497515c02fd58d46e38c872a3fbf366be5f876fe (patch)
tree444655df72ffe7fe9987ad4ddbca687e718ee64f /src
parent117239ca7c05d05ac32c84ec4c4e39688b352ec0 (diff)
downloadhandlebars.js-497515c02fd58d46e38c872a3fbf366be5f876fe.zip
handlebars.js-497515c02fd58d46e38c872a3fbf366be5f876fe.tar.gz
handlebars.js-497515c02fd58d46e38c872a3fbf366be5f876fe.tar.bz2
Remove braces on single line lex statements
Resolves a parsing issue in the 0.4 branch of jison.
Diffstat (limited to 'src')
-rw-r--r--src/handlebars.l64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/handlebars.l b/src/handlebars.l
index aa76eab..5fd0bcd 100644
--- a/src/handlebars.l
+++ b/src/handlebars.l
@@ -3,14 +3,14 @@
%%
-"\\\\"/("{{") { yytext = "\\"; return 'CONTENT'; }
+"\\\\"/("{{") yytext = "\\"; return 'CONTENT';
[^\x00]*?/("{{") {
if(yytext.slice(-1) !== "\\") this.begin("mu");
if(yytext.slice(-1) === "\\") yytext = yytext.substr(0,yyleng-1), this.begin("emu");
if(yytext) return 'CONTENT';
}
-[^\x00]+ { return 'CONTENT'; }
+[^\x00]+ return 'CONTENT';
<emu>[^\x00]{2,}?/("{{"|<<EOF>>) {
if(yytext.slice(-1) !== "\\") this.popState();
@@ -18,32 +18,32 @@
return 'CONTENT';
}
-<com>[\s\S]*?"--}}" { yytext = yytext.substr(0, yyleng-4); this.popState(); return 'COMMENT'; }
-
-<mu>"{{>" { return 'OPEN_PARTIAL'; }
-<mu>"{{#" { return 'OPEN_BLOCK'; }
-<mu>"{{/" { return 'OPEN_ENDBLOCK'; }
-<mu>"{{^" { return 'OPEN_INVERSE'; }
-<mu>"{{"\s*"else" { return 'OPEN_INVERSE'; }
-<mu>"{{{" { return 'OPEN_UNESCAPED'; }
-<mu>"{{&" { return 'OPEN'; }
-<mu>"{{!--" { this.popState(); this.begin('com'); }
-<mu>"{{!"[\s\S]*?"}}" { yytext = yytext.substr(3,yyleng-5); this.popState(); return 'COMMENT'; }
-<mu>"{{" { return 'OPEN'; }
-
-<mu>"=" { return 'EQUALS'; }
-<mu>"."/[}\/ ] { return 'ID'; }
-<mu>".." { return 'ID'; }
-<mu>[\/.] { return 'SEP'; }
-<mu>\s+ { /*ignore whitespace*/ }
-<mu>"}}}" { this.popState(); return 'CLOSE_UNESCAPED'; }
-<mu>"}}" { this.popState(); return 'CLOSE'; }
-<mu>'"'("\\"["]|[^"])*'"' { yytext = yytext.substr(1,yyleng-2).replace(/\\"/g,'"'); return 'STRING'; }
-<mu>"'"("\\"[']|[^'])*"'" { yytext = yytext.substr(1,yyleng-2).replace(/\\'/g,"'"); return 'STRING'; }
-<mu>"@" { return 'DATA'; }
-<mu>"true"/[}\s] { return 'BOOLEAN'; }
-<mu>"false"/[}\s] { return 'BOOLEAN'; }
-<mu>\-?[0-9]+/[}\s] { return 'INTEGER'; }
+<com>[\s\S]*?"--}}" yytext = yytext.substr(0, yyleng-4); this.popState(); return 'COMMENT';
+
+<mu>"{{>" return 'OPEN_PARTIAL';
+<mu>"{{#" return 'OPEN_BLOCK';
+<mu>"{{/" return 'OPEN_ENDBLOCK';
+<mu>"{{^" return 'OPEN_INVERSE';
+<mu>"{{"\s*"else" return 'OPEN_INVERSE';
+<mu>"{{{" return 'OPEN_UNESCAPED';
+<mu>"{{&" return 'OPEN';
+<mu>"{{!--" this.popState(); this.begin('com');
+<mu>"{{!"[\s\S]*?"}}" yytext = yytext.substr(3,yyleng-5); this.popState(); return 'COMMENT';
+<mu>"{{" return 'OPEN';
+
+<mu>"=" return 'EQUALS';
+<mu>"."/[}\/ ] return 'ID';
+<mu>".." return 'ID';
+<mu>[\/.] return 'SEP';
+<mu>\s+ /*ignore whitespace*/
+<mu>"}}}" this.popState(); return 'CLOSE_UNESCAPED';
+<mu>"}}" this.popState(); return 'CLOSE';
+<mu>'"'("\\"["]|[^"])*'"' yytext = yytext.substr(1,yyleng-2).replace(/\\"/g,'"'); return 'STRING';
+<mu>"'"("\\"[']|[^'])*"'" yytext = yytext.substr(1,yyleng-2).replace(/\\'/g,"'"); return 'STRING';
+<mu>"@" return 'DATA';
+<mu>"true"/[}\s] return 'BOOLEAN';
+<mu>"false"/[}\s] return 'BOOLEAN';
+<mu>\-?[0-9]+/[}\s] return 'INTEGER';
/*
ID is the inverse of control characters.
@@ -54,10 +54,10 @@ Control characters ranges:
[\[-\^`] [, \, ], ^, `, Exceptions in range: _
[\{-~] {, |, }, ~
*/
-<mu>[^\s!"#%-,\.\/;->@\[-\^`\{-~]+/[=}\s\/.] { return 'ID'; }
+<mu>[^\s!"#%-,\.\/;->@\[-\^`\{-~]+/[=}\s\/.] return 'ID';
-<mu>'['[^\]]*']' { yytext = yytext.substr(1, yyleng-2); return 'ID'; }
-<mu>. { return 'INVALID'; }
+<mu>'['[^\]]*']' yytext = yytext.substr(1, yyleng-2); return 'ID';
+<mu>. return 'INVALID';
-<INITIAL,mu><<EOF>> { return 'EOF'; }
+<INITIAL,mu><<EOF>> return 'EOF';