From 7326866a6348d62f1a49e604e0526c39ccdc842f Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 1 Feb 2017 22:01:43 -0800 Subject: parser: diagnose run-on symbols. * parser.l (grammar): Add rules which capture two symbols glued together, and diagnose as bad token. Of course a legitimate symbol token can be divided into two that are glued together. This rule is placed after the legitimate symbol matching rule, so that if a token can be interpreted as a single symbol token or as two, the first interpretation is taken. --- parser.l | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/parser.l b/parser.l index 39751ed6..569c4a79 100644 --- a/parser.l +++ b/parser.l @@ -409,6 +409,20 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return SYMTOK; } +{BTOK}{BTOK} | +{NTOK}{NTOK} { + if (yy_top_state(yyscanner) == INITIAL + || yy_top_state(yyscanner) == QSILIT + || yy_top_state(yyscanner) == QWLIT) + yy_pop_state(yyscanner); + + yyerrorf(yyg, lit("bad token: ~a"), + string_own(utf8_dup_from(yytext)), + nao); + yylval->lexeme = utf8_dup_from(yytext); + return SYMTOK; +} + \({WS}all{WS}\) { yy_pop_state(yyscanner); yylval->lineno = yyextra->lineno; -- cgit v1.2.3