forked from github/verilator
Internals: add isProgram to AstModule (#2470)
This allows to check which AstModules were created from `program` keyword
This commit is contained in:
parent
1488f9130d
commit
58739a0a99
@ -2441,11 +2441,14 @@ public:
|
|||||||
|
|
||||||
class AstModule : public AstNodeModule {
|
class AstModule : public AstNodeModule {
|
||||||
// A module declaration
|
// A module declaration
|
||||||
|
private:
|
||||||
|
bool m_isProgram; // Module represents a program
|
||||||
public:
|
public:
|
||||||
AstModule(FileLine* fl, const string& name)
|
AstModule(FileLine* fl, const string& name, bool program = false)
|
||||||
: ASTGEN_SUPER(fl, name) {}
|
: ASTGEN_SUPER(fl, name)
|
||||||
|
, m_isProgram(program) {}
|
||||||
ASTNODE_NODE_FUNCS(Module)
|
ASTNODE_NODE_FUNCS(Module)
|
||||||
virtual string verilogKwd() const { return "module"; }
|
virtual string verilogKwd() const { return m_isProgram ? "program" : "module"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class AstNotFoundModule : public AstNodeModule {
|
class AstNotFoundModule : public AstNodeModule {
|
||||||
|
@ -1465,7 +1465,7 @@ program_declaration: // IEEE: program_declaration + program_nonansi_header + pr
|
|||||||
|
|
||||||
pgmFront<modulep>:
|
pgmFront<modulep>:
|
||||||
yPROGRAM lifetimeE idAny/*new_program*/
|
yPROGRAM lifetimeE idAny/*new_program*/
|
||||||
{ $$ = new AstModule($<fl>3,*$3);
|
{ $$ = new AstModule($<fl>3, *$3, true);
|
||||||
$$->lifetime($2);
|
$$->lifetime($2);
|
||||||
$$->inLibrary(PARSEP->inLibrary() || $$->fileline()->celldefineOn());
|
$$->inLibrary(PARSEP->inLibrary() || $$->fileline()->celldefineOn());
|
||||||
$$->modTrace(GRAMMARP->allTracingOn($$->fileline()));
|
$$->modTrace(GRAMMARP->allTracingOn($$->fileline()));
|
||||||
|
Loading…
Reference in New Issue
Block a user