summaryrefslogtreecommitdiff
path: root/frontends/ilang/lexer.l
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-07-21 15:15:18 +0200
committerClifford Wolf <clifford@clifford.at>2014-07-21 15:15:18 +0200
commit4147b55c233013dd861172f13d0b9669598d234c (patch)
treee28ea6e5e9a1f73a9890ef4e08ab9d174dd181bc /frontends/ilang/lexer.l
parente035f1d886b30329c1c061894146a5c6f92b4f7a (diff)
Added "autoidx" statement to ilang file format
Diffstat (limited to 'frontends/ilang/lexer.l')
-rw-r--r--frontends/ilang/lexer.l27
1 files changed, 3 insertions, 24 deletions
diff --git a/frontends/ilang/lexer.l b/frontends/ilang/lexer.l
index 6557f98a..c40b81af 100644
--- a/frontends/ilang/lexer.l
+++ b/frontends/ilang/lexer.l
@@ -31,7 +31,6 @@
#include "kernel/rtlil.h"
#include "parser.tab.h"
-void update_autoidx(const char *p);
%}
@@ -44,6 +43,7 @@ void update_autoidx(const char *p);
%%
+"autoidx" { return TOK_AUTOIDX; }
"module" { return TOK_MODULE; }
"attribute" { return TOK_ATTRIBUTE; }
"parameter" { return TOK_PARAMETER; }
@@ -76,11 +76,11 @@ void update_autoidx(const char *p);
[a-z]+ { return TOK_INVALID; }
"\\"[^ \t\r\n]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_ID; }
-"$"[^ \t\r\n]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); update_autoidx(yytext); return TOK_ID; }
+"$"[^ \t\r\n]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_ID; }
"."[0-9]+ { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_ID; }
[0-9]+'[01xzm-]* { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_VALUE; }
-[0-9]+ { rtlil_frontend_ilang_yylval.integer = atoi(yytext); return TOK_INT; }
+-?[0-9]+ { rtlil_frontend_ilang_yylval.integer = atoi(yytext); return TOK_INT; }
\" { BEGIN(STRING); }
<STRING>\\. { yymore(); }
@@ -124,27 +124,6 @@ void update_autoidx(const char *p);
%%
-void update_autoidx(const char *p)
-{
- if (*p != '$')
- return;
-
- while (*p) {
- if (*(p++) != '$')
- continue;
- if ('0' <= *p && *p <= '9') {
- const char *q = p;
- while ('0' <= *q && *q <= '9')
- q++;
- if ((q - p) < 10) {
- int idx = atoi(p);
- if (idx >= RTLIL::autoidx)
- RTLIL::autoidx = idx+1;
- }
- }
- }
-}
-
// this is a hack to avoid the 'yyinput defined but not used' error msgs
void *rtlil_frontend_ilang_avoid_input_warnings() {
return (void*)&yyinput;