summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vhd2vl.l16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/vhd2vl.l b/src/vhd2vl.l
index 71f87a9..ab3c0d0 100644
--- a/src/vhd2vl.l
+++ b/src/vhd2vl.l
@@ -36,6 +36,7 @@ extern int skipRem;
void getstring(unsigned skip);
void getbasedstring(unsigned skip);
+int scan_int(char *s);
%}
%%
@@ -157,8 +158,8 @@ void getbasedstring(unsigned skip);
return NAME;
}
-[0-9]+ {
- sscanf(yytext, "%d", &yylval.n);
+[0-9][0-9_]* {
+ yylval.n = scan_int(yytext);
return NATURAL;
}
@@ -196,6 +197,17 @@ void getbasedstring(unsigned skip){
strcpy(yylval.txt, yytext+skip);
}
+int scan_int(char *s){
+ char c;
+ int nn = 0;
+ while ((c=*s++)) {
+ if (c>='0' && c<='9') nn = nn*10 + (c-'0');
+ /* ignore underscores and any other non-digit; depend on
+ * the lex pattern to only feed us digits and underscores */
+ }
+ return nn;
+}
+
void yyerror(char *s){
fprintf(stderr,"%s at \"%s\" in line %d.\n\n",s,yytext,lineno);
}
OpenPOWER on IntegriCloud