From ff8a6cce170ecb6c523b6c59a865946f402226b5 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 20 Mar 2012 23:07:10 -0700 Subject: Regression fix: 1..3 scans incorrectly into 1. .3 tokens. * parser.l (SGN, EXP, DIG): New regex definitions. (FLO): Do not recognize numbers of the form 123. Decimal point must be followed either by exponent, or digits (which may then be followed by an exponent). (FLODOT): New token type, recognizes 123. (grammar): Recognize FLODOT as a floating point number, only if it not trailed by another dot, and recognize FLO unconditionally. --- parser.l | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'parser.l') diff --git a/parser.l b/parser.l index d8fd9150..449cc148 100644 --- a/parser.l +++ b/parser.l @@ -149,8 +149,12 @@ static wchar_t num_esc(char *num) %option noinput SYM [a-zA-Z0-9_]+ -NUM [+\-]?[0-9]+ -FLO [+\-]?([0-9]+[.]?[0-9]*|[0-9]*[.][0-9]+)([eE][+-]?[0-9]+)? +SGN [+\-] +EXP [eE][+\-]?[0-9]+ +DIG [0-9] +NUM {SGN}?{DIG}+ +FLO {SGN}?{DIG}*[.]({DIG}+{EXP}?|{EXP}) +FLODOT {SGN}?{DIG}+[.] BSCHR [a-zA-Z0-9!$%&*+\-<=>?\\^_~] BSYM {BSCHR}({BSCHR}|#)* NSCHR [a-zA-Z0-9!$%&*+\-<=>?\\^_~/] @@ -190,7 +194,8 @@ UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} return NUMBER; } -{FLO} { +{FLODOT}/[^.] | +{FLO} { val str = string_own(utf8_dup_from(yytext)); if (yy_top_state() == INITIAL -- cgit v1.2.3