summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-02-01 22:01:43 -0800
committerKaz Kylheku <kaz@kylheku.com>2017-02-01 22:01:43 -0800
commit7326866a6348d62f1a49e604e0526c39ccdc842f (patch)
tree0a963ee64117dce7719b7d5c69766da8d4e727a5
parentdb608e087727829c3d6f9b8f02942364bb941c5f (diff)
downloadtxr-7326866a6348d62f1a49e604e0526c39ccdc842f.tar.gz
txr-7326866a6348d62f1a49e604e0526c39ccdc842f.tar.bz2
txr-7326866a6348d62f1a49e604e0526c39ccdc842f.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.l14
1 files changed, 14 insertions, 0 deletions
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;
}
+<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;