From 7f04cad34d40dcea1ae0285ef85e308bbcdc7f71 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Tue, 15 Oct 2013 23:25:31 +0900 Subject: [PATCH] scan real numbers --- src/scan.l | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/scan.l b/src/scan.l index e19a0425..dcec67ea 100644 --- a/src/scan.l +++ b/src/scan.l @@ -17,9 +17,11 @@ struct parser_control { %% [ \t\n\r] /* skip whitespace */ -"(" return tLPAREN; -")" return tRPAREN; -[1-9][0-9]* { yylval.datum = pic_float_value(atoi(yytext)); return tNUMBER; } +"(" return tLPAREN; +")" return tRPAREN; +[0-9]+ { yylval.datum = pic_float_value(atoi(yytext)); return tNUMBER; } +\.[0-9]+ { yylval.datum = pic_float_value(atof(yytext)); return tNUMBER; } +[0-9]+\.[0-9]* { yylval.datum = pic_float_value(atof(yytext)); return tNUMBER; } [a-z0-9A-Z+-/*]+ { yylval.datum = pic_intern_cstr(p->pic, yytext); return tSYMBOL; } %%