summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-04-18 21:13:24 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-04-18 21:13:24 -0700
commit264e840b7e10ad7bc28e8649fa841364223e56fa (patch)
treeae117cb1cbf6ec761e87dbf9a2b11d11f9296cda
parent362187f4d0c0ff80320cd52634c8b6c245e27ae6 (diff)
downloadtxr-264e840b7e10ad7bc28e8649fa841364223e56fa.tar.gz
txr-264e840b7e10ad7bc28e8649fa841364223e56fa.tar.bz2
txr-264e840b7e10ad7bc28e8649fa841364223e56fa.zip
Bugfix: allow newline in regex parsing from string.
* parser.l (grammar): The newline character is incorrectly handled by the same rule under the SREGEX and REGEX states. In the SREGEX state, just return it as a REGCHAR, not forgetting to increment the line number.
-rw-r--r--parser.l8
1 files changed, 7 insertions, 1 deletions
diff --git a/parser.l b/parser.l
index a6df6ae8..5e608c8b 100644
--- a/parser.l
+++ b/parser.l
@@ -821,12 +821,18 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
yyextra->lineno++;
}
-<REGEX,SREGEX>{NL} {
+<REGEX>{NL} {
yyextra->lineno++;
yyerrprepf(yyg, lit("newline in regex"), nao);
return ERRTOK;
}
+<SREGEX>{NL} {
+ yyextra->lineno++;
+ yylval->chr = yytext[0];
+ return REGCHAR;
+}
+
<REGEX,SREGEX>{REGOP} {
yylval->chr = yytext[0];
return yytext[0];