summaryrefslogtreecommitdiffstats
path: root/parser.l
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-02-12 16:04:43 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-02-12 16:04:43 -0800
commit773063af1cf3bb5da145335f7d73a56e084a9c3e (patch)
tree322111bcc79c8406ce6de0227afc25e4928e6c2c /parser.l
parente18525f5d6de86773df9d72dd5d5f9e2c6dca581 (diff)
downloadtxr-773063af1cf3bb5da145335f7d73a56e084a9c3e.tar.gz
txr-773063af1cf3bb5da145335f7d73a56e084a9c3e.tar.bz2
txr-773063af1cf3bb5da145335f7d73a56e084a9c3e.zip
* parser.l: Disallow syntax like 1.0a, flagging it as
an invalid floating-point token. The problem is that 1a is allowed, for compatibility with other Lisp dialects (it is a symbol) whereas 1.0a was scanning as 1.0 followed by a, which is inconsistent. Some Lisp dialects embedded dots in symbols, and allow 1.0a as a symbol token. We don't.
Diffstat (limited to 'parser.l')
-rw-r--r--parser.l14
1 files changed, 14 insertions, 0 deletions
diff --git a/parser.l b/parser.l
index 429fb779..d553b56b 100644
--- a/parser.l
+++ b/parser.l
@@ -213,6 +213,20 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
return NUMBER;
}
+<SPECIAL>({FLO}|{FLODOT}){TOK} |
+<BRACED>({FLO}|{FLODOT}){BTOK} |
+<NESTED>({FLO}|{FLODOT}){NTOK} {
+ val str = string_utf8(yytext);
+
+ yyerrorf(lit("trailing junk in floating-point literal: ~a"), str, nao);
+
+ if (yy_top_state() == INITIAL
+ || yy_top_state() == QSILIT)
+ yy_pop_state();
+
+ yylval.val = flo_str(str);
+ return NUMBER;
+}
<SPECIAL,NESTED,BRACED>{FLO} {
val str = string_own(utf8_dup_from(yytext));