From 821e26fa30372ad6e534a54134653d8f664c58dd Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 6 Jan 2013 19:45:09 +0100 Subject: fixed the lexer rules --- module/web/static/js/libs/handlebars.l | 48 ++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 module/web/static/js/libs/handlebars.l (limited to 'module/web/static/js/libs/handlebars.l') diff --git a/module/web/static/js/libs/handlebars.l b/module/web/static/js/libs/handlebars.l new file mode 100644 index 000000000..f0c04f91e --- /dev/null +++ b/module/web/static/js/libs/handlebars.l @@ -0,0 +1,48 @@ + +%x mu emu + +%% + +[^\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]{2,}?/("{{"|<>) { + if(yytext.slice(-1) !== "\\") this.popState(); + if(yytext.slice(-1) === "\\") yytext = yytext.substr(0,yyleng-1); + return 'CONTENT'; + } + +"{{>" { return 'OPEN_PARTIAL'; } +"<%=" { return 'OPEN_BLOCK'; } +"<%/" { return 'OPEN_ENDBLOCK'; } +"{{^" { return 'OPEN_INVERSE'; } +"<%"\s*"else" { return 'OPEN_INVERSE'; } +"{<%%" { return 'OPEN_UNESCAPED'; } +"{{&" { return 'OPEN_UNESCAPED'; } +"<%!"[\s\S]*?"%>" { yytext = yytext.substr(3,yyleng-5); this.popState(); return 'COMMENT'; } +"<%" { return 'OPEN'; } + +"=" { return 'EQUALS'; } +"."/[%} ] { return 'ID'; } +".." { return 'ID'; } +[\/.] { return 'SEP'; } +\s+ { /*ignore whitespace*/ } +"%%>" { this.popState(); return 'CLOSE'; } +"%>" { this.popState(); return 'CLOSE'; } +'"'("\\"["]|[^"])*'"' { yytext = yytext.substr(1,yyleng-2).replace(/\\"/g,'"'); return 'STRING'; } +"'"("\\"[']|[^'])*"'" { yytext = yytext.substr(1,yyleng-2).replace(/\\"/g,'"'); return 'STRING'; } +"@"[a-zA-Z]+ { yytext = yytext.substr(1); return 'DATA'; } +"true"/[%}\s] { return 'BOOLEAN'; } +"false"/[%}\s] { return 'BOOLEAN'; } +[0-9]+/[%}\s] { return 'INTEGER'; } +[a-zA-Z0-9_$-]+/[=%}\s\/.] { return 'ID'; } +'['[^\]]*']' { yytext = yytext.substr(1, yyleng-2); return 'ID'; } +. { return 'INVALID'; } + +<> { return 'EOF'; } + -- cgit v1.2.3