From 8130fcae5f65bbc749459a91a3790a2e82e63b7b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 10 Aug 2015 22:33:48 -0700 Subject: 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. --- parser.l | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/parser.l b/parser.l index dc083867..59189385 100644 --- a/parser.l +++ b/parser.l @@ -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; } +{TOK}/{DOTFLO} | +{BTOK}/{DOTFLO} | +{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; +} + + {TOK} | {BTOK} | {NTOK} { @@ -584,6 +601,19 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return yytext[0]; } +[)\]]/{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]; +} + + [)\]] { yy_pop_state(yyscanner); if (yy_top_state(yyscanner) == INITIAL -- cgit v1.2.3