diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-08-10 22:33:48 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-08-10 22:33:48 -0700 |
commit | 8130fcae5f65bbc749459a91a3790a2e82e63b7b (patch) | |
tree | 6b8214a298f961befb987f9df7244a2b136703ee | |
parent | f9c0def5b6049bc600051b928910f724e14af4f5 (diff) | |
download | txr-8130fcae5f65bbc749459a91a3790a2e82e63b7b.tar.gz txr-8130fcae5f65bbc749459a91a3790a2e82e63b7b.tar.bz2 txr-8130fcae5f65bbc749459a91a3790a2e82e63b7b.zip |
Diagnose ambiguous floats like (a b).4 and x.y.5
These look like integers involved in qref dot syntax.
* parser.l (DOTFLO): New pattern definition.
(grammar): New rules for detecting cramped floating
literals.
-rw-r--r-- | parser.l | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -176,6 +176,7 @@ XDIG [0-9A-Fa-f] NUM {SGN}?{DIG}+ FLO {SGN}?({DIG}*[.]{DIG}+{EXP}?|{DIG}+[.]?{EXP}) FLODOT {SGN}?{DIG}+[.] +DOTFLO [.]{DIG}+ XNUM #x{SGN}?{XDIG}+ ONUM #o{SGN}?[0-7]+ BNUM #b{SGN}?[0-1]+ @@ -355,6 +356,22 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return METANUM; } +<SPECIAL,QSPECIAL>{TOK}/{DOTFLO} | +<BRACED>{BTOK}/{DOTFLO} | +<NESTED>{NTOK}/{DOTFLO} { + yyerrorf(yyg, lit("cramped floating-point literal: " + "add 0 or whitespace"), nao); + + if (yy_top_state(yyscanner) == INITIAL + || yy_top_state(yyscanner) == QSILIT + || yy_top_state(yyscanner) == QWLIT) + yy_pop_state(yyscanner); + + yylval->lexeme = utf8_dup_from(yytext); + return SYMTOK; +} + + <SPECIAL,QSPECIAL>{TOK} | <BRACED>{BTOK} | <NESTED>{NTOK} { @@ -584,6 +601,19 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return yytext[0]; } +<SPECIAL,QSPECIAL,NESTED>[)\]]/{DOTFLO} { + yyerrorf(yyg, lit("cramped floating-point literal: " + "add 0 or whitespace"), nao); + + yy_pop_state(yyscanner); + if (yy_top_state(yyscanner) == INITIAL + || yy_top_state(yyscanner) == QSILIT + || yy_top_state(yyscanner) == QWLIT) + yy_pop_state(yyscanner); + return yytext[0]; +} + + <SPECIAL,QSPECIAL,NESTED>[)\]] { yy_pop_state(yyscanner); if (yy_top_state(yyscanner) == INITIAL |