From 9bf17146994d7586c62f7f52be525ee6f6b08329 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 26 Jun 2015 18:55:22 -0700 Subject: First round of quasiliteral-related fixes. * parser.l: Do not try to recognize floating-point literals in QSPECIAL state; that is not possible because @134.3 in a quasiliteral parses as a METANUM followed by ".3". On the other hand, recognize METANUM literals in QSPECIAL state, so that @@123 scans. Recognize @ as a token in QSPECIAL state, so @@abc will scan. When transitioning from QSILIT and QWLIT states to QSPECIAL upon scanning @, return a @ token, which is now parsed in the grammar. * parser.y (quasi_meta_helper): New static function. (q_var): Do not handle SYMTOK any more, only the braced variable syntax. SYMTOK is handled as a n_expr. Braced vars are handled with explicit '@' token, which is now produced by the scanner when it shifts from QSILIT to QSPECIAL. (quasi_item): No longer necessary to recognize various forms here such as quotes and splices. Just recognize a n_expr, preceded by '@'. --- parser.l | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'parser.l') diff --git a/parser.l b/parser.l index 9036278f..4a133836 100644 --- a/parser.l +++ b/parser.l @@ -269,7 +269,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return NUMBER; } -{FLO} { +{FLO} { val str = string_own(utf8_dup_from(yytext)); if (yy_top_state(yyscanner) == INITIAL @@ -293,7 +293,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return NUMBER; } -({FLO}|{FLODOT}){TOK} | +({FLO}|{FLODOT}){TOK} | ({FLO}|{FLODOT}){BTOK} | ({FLO}|{FLODOT}){NTOK} { val str = string_utf8(yytext); @@ -309,7 +309,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return NUMBER; } -@{NUM} { +@{NUM} { val str = string_own(utf8_dup_from(yytext + 1)); if (yy_top_state(yyscanner) == INITIAL @@ -320,7 +320,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return METANUM; } -@{XNUM} { +@{XNUM} { val str = string_own(utf8_dup_from(yytext + 3)); if (yy_top_state(yyscanner) == INITIAL @@ -331,7 +331,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return METANUM; } -@{ONUM} { +@{ONUM} { val str = string_own(utf8_dup_from(yytext + 3)); if (yy_top_state(yyscanner) == INITIAL @@ -342,7 +342,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return METANUM; } -@{BNUM} { +@{BNUM} { val str = string_own(utf8_dup_from(yytext + 3)); if (yy_top_state(yyscanner) == INITIAL @@ -558,7 +558,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return yytext[0]; } -@ { +@ { yylval->lineno = yyextra->lineno; return yytext[0]; } @@ -897,6 +897,7 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} @ { yy_push_state(QSPECIAL, yyscanner); + return yytext[0]; } {WS} { -- cgit v1.2.3