From b669d3d2e83d3c50238751b57cff3ed0ca39bc8a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 20 Jan 2016 00:05:28 +0100 Subject: [PATCH] Revert "next try for "don't abort when given unmatched '}' with 'start-condition stack underflow'. This fixes #751"" This reverts commit ed23c8568e10d15196bb4ff2b79fc14191d28109. Let's merge this *after* the 1.11.1 release. --- src/libexpr/lexer.l | 24 +++++++----------------- tests/lexer.nix | 2 -- tests/lexer.sh | 3 --- tests/local.mk | 2 +- 4 files changed, 8 insertions(+), 23 deletions(-) delete mode 100644 tests/lexer.nix delete mode 100644 tests/lexer.sh diff --git a/src/libexpr/lexer.l b/src/libexpr/lexer.l index 478f41641..1f2957ec7 100644 --- a/src/libexpr/lexer.l +++ b/src/libexpr/lexer.l @@ -8,7 +8,6 @@ %x STRING %x IND_STRING -%x INSIDE_DOLLAR_CURLY %{ @@ -94,8 +93,6 @@ URI [a-zA-Z][a-zA-Z0-9\+\-\.]*\:[a-zA-Z0-9\%\/\?\:\@\&\=\+\$\,\-\_\.\!\~ %% -{ - if { return IF; } then { return THEN; } @@ -127,15 +124,11 @@ or { return OR_KW; } return INT; } -\$\{ { PUSH_STATE(INSIDE_DOLLAR_CURLY); return DOLLAR_CURLY; } -} +\$\{ { PUSH_STATE(INITIAL); return DOLLAR_CURLY; } +\{ { PUSH_STATE(INITIAL); return '{'; } +\} { POP_STATE(); return '}'; } -\} { return '}'; } -\} { POP_STATE(); return '}'; } -\{ { return '{'; } -\{ { PUSH_STATE(INSIDE_DOLLAR_CURLY); return '{'; } - -\" { PUSH_STATE(STRING); return '"'; } +\" { PUSH_STATE(STRING); return '"'; } ([^\$\"\\]|\$[^\{\"\\]|\\.|\$\\.)*\$/\" | ([^\$\"\\]|\$[^\{\"\\]|\\.|\$\\.)+ { /* It is impossible to match strings ending with '$' with one @@ -144,11 +137,11 @@ or { return OR_KW; } yylval->e = unescapeStr(data->symbols, yytext); return STR; } -\$\{ { PUSH_STATE(INSIDE_DOLLAR_CURLY); return DOLLAR_CURLY; } +\$\{ { PUSH_STATE(INITIAL); return DOLLAR_CURLY; } \" { POP_STATE(); return '"'; } . return yytext[0]; /* just in case: shouldn't be reached */ -\'\'(\ *\n)? { PUSH_STATE(IND_STRING); return IND_STRING_OPEN; } +\'\'(\ *\n)? { PUSH_STATE(IND_STRING); return IND_STRING_OPEN; } ([^\$\']|\$[^\{\']|\'[^\'\$])+ { yylval->e = new ExprIndStr(yytext); return IND_STR; @@ -165,7 +158,7 @@ or { return OR_KW; } yylval->e = unescapeStr(data->symbols, yytext + 2); return IND_STR; } -\$\{ { PUSH_STATE(INSIDE_DOLLAR_CURLY); return DOLLAR_CURLY; } +\$\{ { PUSH_STATE(INITIAL); return DOLLAR_CURLY; } \'\' { POP_STATE(); return IND_STRING_CLOSE; } \' { yylval->e = new ExprIndStr("'"); @@ -173,8 +166,6 @@ or { return OR_KW; } } . return yytext[0]; /* just in case: shouldn't be reached */ -{ - {PATH} { yylval->path = strdup(yytext); return PATH; } {HPATH} { yylval->path = strdup(yytext); return HPATH; } {SPATH} { yylval->path = strdup(yytext); return SPATH; } @@ -186,7 +177,6 @@ or { return OR_KW; } . return yytext[0]; -} %% diff --git a/tests/lexer.nix b/tests/lexer.nix deleted file mode 100644 index 05c78b301..000000000 --- a/tests/lexer.nix +++ /dev/null @@ -1,2 +0,0 @@ -let const = a: "const"; in -''${ const { x = "q"; }}'' diff --git a/tests/lexer.sh b/tests/lexer.sh deleted file mode 100644 index e45a6b00a..000000000 --- a/tests/lexer.sh +++ /dev/null @@ -1,3 +0,0 @@ -source common.sh - -nix-instantiate --eval ./lexer.nix diff --git a/tests/local.mk b/tests/local.mk index 05c6e04ee..03f53b44c 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -11,7 +11,7 @@ nix_tests = \ binary-patching.sh timeout.sh secure-drv-outputs.sh nix-channel.sh \ multiple-outputs.sh import-derivation.sh fetchurl.sh optimise-store.sh \ binary-cache.sh nix-profile.sh repair.sh dump-db.sh case-hack.sh \ - check-reqs.sh pass-as-file.sh tarball.sh lexer.sh + check-reqs.sh pass-as-file.sh tarball.sh # parallel.sh install-tests += $(foreach x, $(nix_tests), tests/$(x))