Internals: add isProgram to AstModule (#2470)

This allows to check which AstModules were created from `program` keyword
This commit is contained in:
Piotr Binkowski 2020-07-16 13:31:16 +02:00 committed by GitHub
parent 1488f9130d
commit 58739a0a99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -2441,11 +2441,14 @@ public:
class AstModule : public AstNodeModule {
// A module declaration
private:
bool m_isProgram; // Module represents a program
public:
AstModule(FileLine* fl, const string& name)
: ASTGEN_SUPER(fl, name) {}
AstModule(FileLine* fl, const string& name, bool program = false)
: ASTGEN_SUPER(fl, name)
, m_isProgram(program) {}
ASTNODE_NODE_FUNCS(Module)
virtual string verilogKwd() const { return "module"; }
virtual string verilogKwd() const { return m_isProgram ? "program" : "module"; }
};
class AstNotFoundModule : public AstNodeModule {

View File

@ -1465,7 +1465,7 @@ program_declaration: // IEEE: program_declaration + program_nonansi_header + pr
pgmFront<modulep>:
yPROGRAM lifetimeE idAny/*new_program*/
{ $$ = new AstModule($<fl>3,*$3);
{ $$ = new AstModule($<fl>3, *$3, true);
$$->lifetime($2);
$$->inLibrary(PARSEP->inLibrary() || $$->fileline()->celldefineOn());
$$->modTrace(GRAMMARP->allTracingOn($$->fileline()));