diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-02-01 22:01:43 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-02-01 22:01:43 -0800 |
commit | 043063bdd6045f4f995e774173bb19877c9779a0 (patch) | |
tree | 0a963ee64117dce7719b7d5c69766da8d4e727a5 | |
parent | 1d412d9e4bf1bbb5b163a218461c9532eb3ebdac (diff) | |
download | txr-043063bdd6045f4f995e774173bb19877c9779a0.tar.gz txr-043063bdd6045f4f995e774173bb19877c9779a0.tar.bz2 txr-043063bdd6045f4f995e774173bb19877c9779a0.zip |
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.
-rw-r--r-- | parser.l | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -409,6 +409,20 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return SYMTOK; } +<BRACED>{BTOK}{BTOK} | +<NESTED>{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; +} + <SPECIAL>\({WS}all{WS}\) { yy_pop_state(yyscanner); yylval->lineno = yyextra->lineno; |