aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/lexer.l
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-01-20 16:34:42 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-01-20 16:34:42 +0100
commit5d8b7eb3e1f6030dfb1677af7a6ca9e2f1ebc11a (patch)
treea3f1db7dc4c77a0c4bc969ce3423294f5bbf7bc2 /src/libexpr/lexer.l
parent84e01203a72e8b8b5fefea93ed4a8dbdaef519ea (diff)
Revert "Revert "next try for "don't abort when given unmatched '}' with 'start-condition stack underflow'. This fixes #751"""
This reverts commit b669d3d2e83d3c50238751b57cff3ed0ca39bc8a.
Diffstat (limited to 'src/libexpr/lexer.l')
-rw-r--r--src/libexpr/lexer.l24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l
index 1f2957ec7..478f41641 100644
--- a/src/libexpr/lexer.l
+++ b/src/libexpr/lexer.l
@@ -8,6 +8,7 @@
%x STRING
%x IND_STRING
+%x INSIDE_DOLLAR_CURLY
%{
@@ -93,6 +94,8 @@ URI [a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~
%%
+<INITIAL,INSIDE_DOLLAR_CURLY>{
+
if { return IF; }
then { return THEN; }
@@ -124,11 +127,15 @@ or { return OR_KW; }
return INT;
}
-\$\{ { PUSH_STATE(INITIAL); return DOLLAR_CURLY; }
-\{ { PUSH_STATE(INITIAL); return '{'; }
-\} { POP_STATE(); return '}'; }
+\$\{ { PUSH_STATE(INSIDE_DOLLAR_CURLY); return DOLLAR_CURLY; }
+}
+
+\} { return '}'; }
+<INSIDE_DOLLAR_CURLY>\} { POP_STATE(); return '}'; }
+\{ { return '{'; }
+<INSIDE_DOLLAR_CURLY>\{ { PUSH_STATE(INSIDE_DOLLAR_CURLY); return '{'; }
-\" { PUSH_STATE(STRING); return '"'; }
+<INITIAL,INSIDE_DOLLAR_CURLY>\" { PUSH_STATE(STRING); return '"'; }
<STRING>([^\$\"\\]|\$[^\{\"\\]|\\.|\$\\.)*\$/\" |
<STRING>([^\$\"\\]|\$[^\{\"\\]|\\.|\$\\.)+ {
/* It is impossible to match strings ending with '$' with one
@@ -137,11 +144,11 @@ or { return OR_KW; }
yylval->e = unescapeStr(data->symbols, yytext);
return STR;
}
-<STRING>\$\{ { PUSH_STATE(INITIAL); return DOLLAR_CURLY; }
+<STRING>\$\{ { PUSH_STATE(INSIDE_DOLLAR_CURLY); return DOLLAR_CURLY; }
<STRING>\" { POP_STATE(); return '"'; }
<STRING>. return yytext[0]; /* just in case: shouldn't be reached */
-\'\'(\ *\n)? { PUSH_STATE(IND_STRING); return IND_STRING_OPEN; }
+<INITIAL,INSIDE_DOLLAR_CURLY>\'\'(\ *\n)? { PUSH_STATE(IND_STRING); return IND_STRING_OPEN; }
<IND_STRING>([^\$\']|\$[^\{\']|\'[^\'\$])+ {
yylval->e = new ExprIndStr(yytext);
return IND_STR;
@@ -158,7 +165,7 @@ or { return OR_KW; }
yylval->e = unescapeStr(data->symbols, yytext + 2);
return IND_STR;
}
-<IND_STRING>\$\{ { PUSH_STATE(INITIAL); return DOLLAR_CURLY; }
+<IND_STRING>\$\{ { PUSH_STATE(INSIDE_DOLLAR_CURLY); return DOLLAR_CURLY; }
<IND_STRING>\'\' { POP_STATE(); return IND_STRING_CLOSE; }
<IND_STRING>\' {
yylval->e = new ExprIndStr("'");
@@ -166,6 +173,8 @@ or { return OR_KW; }
}
<IND_STRING>. return yytext[0]; /* just in case: shouldn't be reached */
+<INITIAL,INSIDE_DOLLAR_CURLY>{
+
{PATH} { yylval->path = strdup(yytext); return PATH; }
{HPATH} { yylval->path = strdup(yytext); return HPATH; }
{SPATH} { yylval->path = strdup(yytext); return SPATH; }
@@ -177,6 +186,7 @@ or { return OR_KW; }
. return yytext[0];
+}
%%