Support free-form `default_net_type directives.
This commit is contained in:
parent
79a3d08d69
commit
cd0b360575
|
|
@ -0,0 +1,19 @@
|
||||||
|
// This is just a syntax test.
|
||||||
|
|
||||||
|
/* comment */ `default_nettype /* comment */ // comment
|
||||||
|
/* comment */ wire /* comment */ // comment
|
||||||
|
module m1;
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
/* comment */`default_nettype/*
|
||||||
|
comment */
|
||||||
|
/* comment */tri0/*
|
||||||
|
comment */
|
||||||
|
module m2;
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module test;
|
||||||
|
|
||||||
|
initial $display("PASSED");
|
||||||
|
|
||||||
|
endmodule
|
||||||
|
|
@ -352,6 +352,7 @@ br_gh732 normal ivltests gold=br_gh732.gold
|
||||||
br_gh782c normal ivltests
|
br_gh782c normal ivltests
|
||||||
br_gh782d normal ivltests
|
br_gh782d normal ivltests
|
||||||
br_gh782e normal ivltests
|
br_gh782e normal ivltests
|
||||||
|
br_gh782f normal ivltests
|
||||||
br_gh788 normal,-gno-io-range-error,-Wno-anachronisms ivltests gold=br_gh788.gold
|
br_gh788 normal,-gno-io-range-error,-Wno-anachronisms ivltests gold=br_gh788.gold
|
||||||
br_gh793 normal ivltests
|
br_gh793 normal ivltests
|
||||||
br_ml20150315 normal ivltests gold=br_ml_20150315.gold
|
br_ml20150315 normal ivltests gold=br_ml_20150315.gold
|
||||||
|
|
|
||||||
27
lexor.lex
27
lexor.lex
|
|
@ -152,6 +152,7 @@ void lex_in_package_scope(PPackage*pkg)
|
||||||
%x PPUCDRIVE
|
%x PPUCDRIVE
|
||||||
%x PPUCDRIVE_ERROR
|
%x PPUCDRIVE_ERROR
|
||||||
%x PPDEFAULT_NETTYPE
|
%x PPDEFAULT_NETTYPE
|
||||||
|
%x PPDEFAULT_NETTYPE_ERROR
|
||||||
%x PPBEGIN_KEYWORDS
|
%x PPBEGIN_KEYWORDS
|
||||||
%x PPBEGIN_KEYWORDS_ERROR
|
%x PPBEGIN_KEYWORDS_ERROR
|
||||||
%s EDGES
|
%s EDGES
|
||||||
|
|
@ -785,16 +786,12 @@ TU [munpf]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Notice and handle the default_nettype directive. The lexor
|
/* Notice and handle the `default_nettype directive. */
|
||||||
detects the default_nettype keyword, and the second part of the
|
|
||||||
rule collects the rest of the line and processes it. We only need
|
|
||||||
to look for the first work, and interpret it. */
|
|
||||||
|
|
||||||
`default_nettype{W}? { BEGIN(PPDEFAULT_NETTYPE); }
|
`default_nettype { BEGIN(PPDEFAULT_NETTYPE); }
|
||||||
<PPDEFAULT_NETTYPE>.* {
|
|
||||||
|
<PPDEFAULT_NETTYPE>[a-zA-Z0-9_]+ {
|
||||||
NetNet::Type net_type;
|
NetNet::Type net_type;
|
||||||
size_t wordlen = strcspn(yytext, " \t\f\r\n");
|
|
||||||
yytext[wordlen] = 0;
|
|
||||||
/* Add support for other wire types and better error detection. */
|
/* Add support for other wire types and better error detection. */
|
||||||
if (strcmp(yytext,"wire") == 0) {
|
if (strcmp(yytext,"wire") == 0) {
|
||||||
net_type = NetNet::WIRE;
|
net_type = NetNet::WIRE;
|
||||||
|
|
@ -832,11 +829,19 @@ TU [munpf]
|
||||||
error_count += 1;
|
error_count += 1;
|
||||||
}
|
}
|
||||||
pform_set_default_nettype(net_type, yylloc.text, yylloc.first_line);
|
pform_set_default_nettype(net_type, yylloc.text, yylloc.first_line);
|
||||||
|
BEGIN(0);
|
||||||
}
|
}
|
||||||
<PPDEFAULT_NETTYPE>\n {
|
|
||||||
yylloc.first_line += 1;
|
|
||||||
BEGIN(0); }
|
|
||||||
|
|
||||||
|
<PPDEFAULT_NETTYPE>"//" { comment_enter = PPDEFAULT_NETTYPE; BEGIN(LCOMMENT); }
|
||||||
|
<PPDEFAULT_NETTYPE>"/*" { comment_enter = PPDEFAULT_NETTYPE; BEGIN(CCOMMENT); }
|
||||||
|
<PPDEFAULT_NETTYPE>"\n" { yylloc.first_line += 1; }
|
||||||
|
<PPDEFAULT_NETTYPE>{W} { ; }
|
||||||
|
<PPDEFAULT_NETTYPE>. { BEGIN(PPDEFAULT_NETTYPE_ERROR); }
|
||||||
|
|
||||||
|
/* On error, try to recover by skipping to the end of the line. */
|
||||||
|
<PPDEFAULT_NETTYPE_ERROR>[^\n]+ {
|
||||||
|
VLerror(yylloc, "error: Invalid `default_nettype directive.");
|
||||||
|
BEGIN(0); }
|
||||||
|
|
||||||
/* These are directives that are not supported by me and should have
|
/* These are directives that are not supported by me and should have
|
||||||
been handled by an external preprocessor such as ivlpp. */
|
been handled by an external preprocessor such as ivlpp. */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue