forked from github/verilator
Defines with // comments still need continuation - spec ambiguity
This commit is contained in:
parent
9a3e497c22
commit
72218fb475
@ -154,6 +154,7 @@ psl [p]sl
|
||||
|
||||
/* Reading definition value */
|
||||
<DEFVAL>"/*" { LEXP->m_defCmtSlash=false; yy_push_state(DEFCMT); yymore(); } /* Special comment parser */
|
||||
<DEFVAL>"//"[^\n\r]*[\\]{crnl} { linenoInc(); appendDefValue((char*)"\n",1); } /* Spec says // not part of define value */
|
||||
<DEFVAL>"//"[^\n\r]* { return (VP_COMMENT);}
|
||||
<DEFVAL>{drop} { }
|
||||
<DEFVAL><<EOF>> { linenoInc(); yy_pop_state(); yytext=(char*)"\n"; yyleng=1; return (VP_DEFVALUE); } /* Technically illegal, but people complained */
|
||||
|
@ -71,7 +71,7 @@ class V3DefineRef {
|
||||
string m_name; // Define last name being defined
|
||||
string m_params; // Define parameter list for next expansion
|
||||
string m_nextarg; // String being built for next argument
|
||||
int m_parenLevel; // Parenthesis counting inside def args
|
||||
int m_parenLevel; // Parenthesis counting inside def args (for PARENT not child)
|
||||
|
||||
vector<string> m_args; // List of define arguments
|
||||
public:
|
||||
@ -80,9 +80,10 @@ public:
|
||||
string nextarg() const { return m_nextarg; }
|
||||
void nextarg(const string& value) { m_nextarg = value; }
|
||||
int parenLevel() const { return m_parenLevel; }
|
||||
void parenLevel(int value) { m_parenLevel = value; }
|
||||
vector<string>& args() { return m_args; }
|
||||
V3DefineRef(const string& name, const string& params, int pl)
|
||||
: m_name(name), m_params(params), m_parenLevel(pl) {}
|
||||
V3DefineRef(const string& name, const string& params)
|
||||
: m_name(name), m_params(params), m_parenLevel(0) {}
|
||||
~V3DefineRef() {}
|
||||
};
|
||||
|
||||
@ -1054,7 +1055,9 @@ int V3PreProcImp::getToken() {
|
||||
}
|
||||
else { // Found, with parameters
|
||||
UINFO(4,"Defref `"<<name<<" => parameterized"<<endl);
|
||||
m_defRefs.push(V3DefineRef(name, params, m_lexp->m_parenLevel));
|
||||
// The CURRENT macro needs the paren saved, it's not a property of the child macro
|
||||
if (!m_defRefs.empty()) m_defRefs.top().parenLevel(m_lexp->m_parenLevel);
|
||||
m_defRefs.push(V3DefineRef(name, params));
|
||||
m_state = ps_DEFPAREN; m_stateFor = tok;
|
||||
m_lexp->pushStateDefArg(0);
|
||||
goto next_tok;
|
||||
|
@ -244,13 +244,64 @@ $display("bits %d %d", $bits(foo), `10);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1 /*verilator NOT IN DEFINE*/ (nodef)
|
||||
2 /*verilator PART OF DEFINE*/ (hasdef)
|
||||
3 /*verilator NOT PART OF DEFINE*/ (nodef)
|
||||
4 /*verilator PART OF DEFINE*/ (nodef)
|
||||
5 also in also3 (nodef)
|
||||
|
||||
|
||||
HAS a NEW LINE
|
||||
|
||||
|
||||
`line 203 "t/t_preproc.v" 2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
EXP: clxx_scen
|
||||
clxx_scen
|
||||
EXP: clxx_scen
|
||||
"clxx_scen"
|
||||
|
||||
EXP: do if (start("verilog/inc1.v", 25)) begin message({"Blah-", "clx_scen", " end"}); end while(0);
|
||||
do
|
||||
`line 231 "t/t_preproc.v" 0
|
||||
if (start("t/t_preproc.v", 231)) begin message({"Blah-", "clx_scen", " end"}); end while(0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
`line 241 "t/t_preproc.v" 0
|
||||
|
||||
|
||||
EXP: This is fooed
|
||||
This is fooed
|
||||
|
||||
EXP: This is fooed_2
|
||||
This is fooed_2
|
||||
|
||||
|
||||
`line 250 "t/t_preproc.v" 2
|
||||
|
@ -191,12 +191,57 @@ Line_Preproc_Check `__LINE__
|
||||
OF DEFINE */
|
||||
`define CMT4 /* verilator PART \
|
||||
OF DEFINE */
|
||||
`define CMT5 // CMT NOT \
|
||||
also in // BUT TEXT IS \
|
||||
also3 // CMT NOT
|
||||
|
||||
1 `CMT1 (nodef)
|
||||
2 `CMT2 (hasdef)
|
||||
3 `CMT3 (nodef)
|
||||
4 `CMT4 (nodef)
|
||||
5 `CMT5 (nodef)
|
||||
`define NL HAS a NEW \
|
||||
LINE
|
||||
`NL
|
||||
|
||||
//======================================================================
|
||||
|
||||
`define msg_fatal(log, msg) \
|
||||
do \
|
||||
/* synopsys translate_off */ \
|
||||
`ifdef NEVER \
|
||||
`error "WTF" \
|
||||
`else \
|
||||
if (start(`__FILE__, `__LINE__)) begin \
|
||||
`endif \
|
||||
message(msg); \
|
||||
end \
|
||||
/* synopsys translate_on */ \
|
||||
while(0)
|
||||
|
||||
`define msg_scen_(cl) cl``_scen
|
||||
`define MSG_MACRO_TO_STRING(x) `"x`"
|
||||
|
||||
EXP: clxx_scen
|
||||
`msg_scen_(clxx)
|
||||
EXP: clxx_scen
|
||||
`MSG_MACRO_TO_STRING(`msg_scen_(clxx))
|
||||
`define mf(clx) `msg_fatal(this.log, {"Blah-", `MSG_MACRO_TO_STRING(`msg_scen_(clx)), " end"});
|
||||
EXP: do if (start("verilog/inc1.v", 25)) begin message({"Blah-", "clx_scen", " end"}); end while(0);
|
||||
`mf(clx)
|
||||
|
||||
//======================================================================
|
||||
|
||||
`define makedefine(name) \
|
||||
`define def_``name This is name \
|
||||
`define def_``name``_2 This is name``_2 \
|
||||
|
||||
`makedefine(fooed)
|
||||
`ifndef def_fooed `error "No def_fooed" `endif
|
||||
//`ifndef def_fooed_2 `error "No def_fooed_2" `endif
|
||||
EXP: This is fooed
|
||||
`def_fooed
|
||||
EXP: This is fooed_2
|
||||
`def_fooed_2
|
||||
|
||||
//======================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user