summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2013-07-30 10:25:41 -0500
committerkpdecker <kpdecker@gmail.com>2013-10-14 22:50:50 -0500
commit4e4920cc78b1ad68ca325d9677b2fb8f3dfbaa3a (patch)
tree5bce9bfdb31ff886d72baa1e89e5f73fc530a208 /src
parentd5544d896997d50ad7d045128b4a43596323e429 (diff)
downloadhandlebars.js-4e4920cc78b1ad68ca325d9677b2fb8f3dfbaa3a.zip
handlebars.js-4e4920cc78b1ad68ca325d9677b2fb8f3dfbaa3a.tar.gz
handlebars.js-4e4920cc78b1ad68ca325d9677b2fb8f3dfbaa3a.tar.bz2
Add strip token parsing to lexer
Diffstat (limited to 'src')
-rw-r--r--src/handlebars.l26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/handlebars.l b/src/handlebars.l
index 546852d..740015b 100644
--- a/src/handlebars.l
+++ b/src/handlebars.l
@@ -9,9 +9,11 @@ function strip(start, end) {
%}
+LEFT_STRIP "("
+RIGHT_STRIP ")"
-LOOKAHEAD [=}\s\/.]
-LITERAL_LOOKAHEAD [}\s]
+LOOKAHEAD [=)}\s\/.]
+LITERAL_LOOKAHEAD [)}\s]
/*
ID is the inverse of control characters.
@@ -49,24 +51,24 @@ ID [^\s!"#%-,\.\/;->@\[-\^`\{-~]+/{LOOKAHEAD}
<com>[\s\S]*?"--}}" strip(0,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>"{{"{LEFT_STRIP}?">" return 'OPEN_PARTIAL';
+<mu>"{{"{LEFT_STRIP}?"#" return 'OPEN_BLOCK';
+<mu>"{{"{LEFT_STRIP}?"/" return 'OPEN_ENDBLOCK';
+<mu>"{{"{LEFT_STRIP}?"^" return 'OPEN_INVERSE';
+<mu>"{{"{LEFT_STRIP}?\s*"else" return 'OPEN_INVERSE';
+<mu>"{{"{LEFT_STRIP}?"{" return 'OPEN_UNESCAPED';
+<mu>"{{"{LEFT_STRIP}?"&" return 'OPEN';
<mu>"{{!--" this.popState(); this.begin('com');
<mu>"{{!"[\s\S]*?"}}" strip(3,5); this.popState(); return 'COMMENT';
-<mu>"{{" return 'OPEN';
+<mu>"{{"{LEFT_STRIP}? return 'OPEN';
<mu>"=" return 'EQUALS';
<mu>".." return 'ID';
<mu>"."/{LOOKAHEAD} return 'ID';
<mu>[\/.] return 'SEP';
<mu>\s+ /*ignore whitespace*/
-<mu>"}}}" this.popState(); return 'CLOSE_UNESCAPED';
-<mu>"}}" this.popState(); return 'CLOSE';
+<mu>"}"{RIGHT_STRIP}?"}}" this.popState(); return 'CLOSE_UNESCAPED';
+<mu>{RIGHT_STRIP}?"}}" this.popState(); return 'CLOSE';
<mu>'"'("\\"["]|[^"])*'"' yytext = strip(1,2).replace(/\\"/g,'"'); return 'STRING';
<mu>"'"("\\"[']|[^'])*"'" yytext = strip(1,2).replace(/\\'/g,"'"); return 'STRING';
<mu>"@" return 'DATA';