Remove braces on single line lex statements

Resolves a parsing issue in the 0.4 branch of jison.
This commit is contained in:
kpdecker
2013-07-24 23:43:56 -05:00
parent 117239ca7c
commit 497515c02f
2 changed files with 60 additions and 60 deletions
+30 -30
View File
@@ -566,7 +566,7 @@ lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_STA
var YYSTATE=YY_START
switch($avoiding_name_collisions) {
case 0: yy_.yytext = "\\"; return 14;
case 0:yy_.yytext = "\\"; return 14;
break;
case 1:
if(yy_.yytext.slice(-1) !== "\\") this.begin("mu");
@@ -574,7 +574,7 @@ case 1:
if(yy_.yytext) return 14;
break;
case 2: return 14;
case 2:return 14;
break;
case 3:
if(yy_.yytext.slice(-1) !== "\\") this.popState();
@@ -582,61 +582,61 @@ case 3:
return 14;
break;
case 4: yy_.yytext = yy_.yytext.substr(0, yy_.yyleng-4); this.popState(); return 15;
case 4:yy_.yytext = yy_.yytext.substr(0, yy_.yyleng-4); this.popState(); return 15;
break;
case 5: return 25;
case 5:return 25;
break;
case 6: return 16;
case 6:return 16;
break;
case 7: return 20;
case 7:return 20;
break;
case 8: return 19;
case 8:return 19;
break;
case 9: return 19;
case 9:return 19;
break;
case 10: return 23;
case 10:return 23;
break;
case 11: return 22;
case 11:return 22;
break;
case 12: this.popState(); this.begin('com');
case 12:this.popState(); this.begin('com');
break;
case 13: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15;
case 13:yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15;
break;
case 14: return 22;
case 14:return 22;
break;
case 15: return 39;
case 15:return 39;
break;
case 16: return 38;
case 16:return 38;
break;
case 17: return 38;
case 17:return 38;
break;
case 18: return 42;
case 18:return 42;
break;
case 19: /*ignore whitespace*/
case 19:/*ignore whitespace*/
break;
case 20: this.popState(); return 24;
case 20:this.popState(); return 24;
break;
case 21: this.popState(); return 18;
case 21:this.popState(); return 18;
break;
case 22: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 32;
case 22:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 32;
break;
case 23: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\'/g,"'"); return 32;
case 23:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\'/g,"'"); return 32;
break;
case 24: return 40;
case 24:return 40;
break;
case 25: return 34;
case 25:return 34;
break;
case 26: return 34;
case 26:return 34;
break;
case 27: return 33;
case 27:return 33;
break;
case 28: return 38;
case 28:return 38;
break;
case 29: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 38;
case 29:yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 38;
break;
case 30: return 'INVALID';
case 30:return 'INVALID';
break;
case 31: return 5;
case 31:return 5;
break;
}
};
+30 -30
View File
@@ -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'; }
<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 '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'; }
<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';