git » unicorn-sparkle-basic.git » commit e9a0ab3

allow negative numbers

author Alan Dipert
2024-04-26 20:04:16 UTC
committer Alan Dipert
2024-04-26 20:04:16 UTC
parent f504779168ed989eea6aa09e71c762c9d5db4942

allow negative numbers

usbasic.l +1 -1

diff --git a/usbasic.l b/usbasic.l
index 005c8ab..821c755 100644
--- a/usbasic.l
+++ b/usbasic.l
@@ -30,7 +30,7 @@
 ">"                 return GT;
 ">="                return GTE;
 "=="                return EQ;
-[0-9]+(\.[0-9]+)?([eE][-+]?[0-9]+)?  { yylval.number = atof(yytext); return NUMBER; }
+-?[0-9]+(\.[0-9]+)?([eE][-+]?[0-9]+)?  { yylval.number = atof(yytext); return NUMBER; }
 [a-zA-Z][a-zA-Z0-9]* { yylval.id = strdup(yytext); return IDENTIFIER; }
 \"([^\\\"]|\\.)*\"   { yylval.str = strdup(yytext); return STRING; }
 .                   return *yytext;