mirror of https://github.com/YosysHQ/yosys.git
Added updating of RTLIL::autoidx to ilang frontend
This commit is contained in:
parent
03f0ab9de2
commit
8f11eaaca6
|
@ -25,6 +25,7 @@
|
||||||
%{
|
%{
|
||||||
#include "kernel/rtlil.h"
|
#include "kernel/rtlil.h"
|
||||||
#include "parser.tab.h"
|
#include "parser.tab.h"
|
||||||
|
void update_autoidx(const char *p);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%option yylineno
|
%option yylineno
|
||||||
|
@ -68,7 +69,7 @@
|
||||||
[a-z]+ { return TOK_INVALID; }
|
[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); return TOK_ID; }
|
||||||
"$"[^ \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; }
|
||||||
"."[0-9]+ { 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]+'[01xzm-]* { rtlil_frontend_ilang_yylval.string = strdup(yytext); return TOK_VALUE; }
|
||||||
|
@ -116,6 +117,27 @@
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// this is a hack to avoid the 'yyinput defined but not used' error msgs
|
// this is a hack to avoid the 'yyinput defined but not used' error msgs
|
||||||
void *rtlil_frontend_ilang_avoid_input_warnings() {
|
void *rtlil_frontend_ilang_avoid_input_warnings() {
|
||||||
return (void*)&yyinput;
|
return (void*)&yyinput;
|
||||||
|
|
Loading…
Reference in New Issue