V0.8: `timescale can not be inside module definition.
This patch mirrors what was done in development to complain about a `timescale inside of a module definition.
This commit is contained in:
parent
f112b77d3b
commit
e8bb9b1f76
28
lexor.lex
28
lexor.lex
|
|
@ -92,6 +92,7 @@ static int dec_buf_div2(char *buf);
|
||||||
static void process_timescale(const char*txt);
|
static void process_timescale(const char*txt);
|
||||||
|
|
||||||
static int comment_enter;
|
static int comment_enter;
|
||||||
|
static bool in_module = false;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%x CCOMMENT
|
%x CCOMMENT
|
||||||
|
|
@ -215,14 +216,29 @@ W [ \t\b\f\r]+
|
||||||
|
|
||||||
[a-zA-Z_][a-zA-Z0-9$_]* {
|
[a-zA-Z_][a-zA-Z0-9$_]* {
|
||||||
int rc = lexor_keyword_code(yytext, yyleng);
|
int rc = lexor_keyword_code(yytext, yyleng);
|
||||||
if (rc == IDENTIFIER) {
|
switch (rc) {
|
||||||
|
case IDENTIFIER:
|
||||||
yylval.text = strdup(yytext);
|
yylval.text = strdup(yytext);
|
||||||
if (strncmp(yylval.text,"PATHPULSE$", 10) == 0)
|
if (strncmp(yylval.text,"PATHPULSE$", 10) == 0)
|
||||||
rc = PATHPULSE_IDENTIFIER;
|
rc = PATHPULSE_IDENTIFIER;
|
||||||
} else if (rc == K_edge) {
|
break;
|
||||||
|
|
||||||
|
case K_edge:
|
||||||
BEGIN(EDGES);
|
BEGIN(EDGES);
|
||||||
} else {
|
break;
|
||||||
|
|
||||||
|
case K_module:
|
||||||
|
case K_macromodule:
|
||||||
|
in_module = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case K_endmodule:
|
||||||
|
in_module = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
yylval.text = 0;
|
yylval.text = 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
@ -281,6 +297,12 @@ W [ \t\b\f\r]+
|
||||||
^{W}?`timescale { BEGIN(PPTIMESCALE); }
|
^{W}?`timescale { BEGIN(PPTIMESCALE); }
|
||||||
<PPTIMESCALE>.* { process_timescale(yytext); }
|
<PPTIMESCALE>.* { process_timescale(yytext); }
|
||||||
<PPTIMESCALE>\n {
|
<PPTIMESCALE>\n {
|
||||||
|
if (in_module) {
|
||||||
|
cerr << yylloc.text << ":" << yylloc.first_line << ": error: "
|
||||||
|
"`timescale directive can not be inside a module "
|
||||||
|
"definition." << endl;
|
||||||
|
error_count += 1;
|
||||||
|
}
|
||||||
yylloc.first_line += 1;
|
yylloc.first_line += 1;
|
||||||
BEGIN(0); }
|
BEGIN(0); }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue