From 9281217ffad338c3469a38feced75c407e34137d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 4 Apr 2017 19:56:00 -0700 Subject: parser: bugfix: don't scan @NUM in QSPECIAL state. The problem is syntax like `@@12a` being scanned as if it were `@{@12}a` rather than @{@12a}`. When the scanner is in the middle of a quasiliteral, in the QSILIT state and sees a @, it transitions to the QSPECIAL state. In the QSPECIAL state, the METANUM token syntax is recognized consisting of @ followed by a decimal, octal or hex number. In the same QSPECIAL state, however, a meta-variable like @abc is not recognized as a unit; rather, a @ is recognized by itself, and abc by itself. Thus when @12a is seen in the QSPECIAL state, the @12 is the longest match. The fix is to treat METANUM tokens the same way in the QSPECIAL state: just recognize a number without the @ prefix, and report as a METANUM. * parser.l (grammar): Split the pattern in all four METANUM rules so that in the NESTED, BRACED, QSLIT and QWLIT states, the number is recognized together with the @ prefix. But in the QSPECIAL state, indicating that one or more @ characters have been seen, just recognize a number without the prefix as a METANUM. --- parser.l | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/parser.l b/parser.l index 2d2c11ea..cf6de7f0 100644 --- a/parser.l +++ b/parser.l @@ -336,7 +336,8 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return NUMBER; } -@{NUM} { +@{NUM} | +{NUM} { val str = string_own(utf8_dup_from(yytext + 1)); if (yy_top_state(yyscanner) == INITIAL @@ -347,7 +348,8 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return METANUM; } -@{XNUM} { +@{XNUM} | +{XNUM} { val str = string_own(utf8_dup_from(yytext + 3)); if (yy_top_state(yyscanner) == INITIAL @@ -358,7 +360,8 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return METANUM; } -@{ONUM} { +@{ONUM} | +{ONUM} { val str = string_own(utf8_dup_from(yytext + 3)); if (yy_top_state(yyscanner) == INITIAL -- cgit v1.2.3