From 58739a0a99ce2f53c553d0b3f2e5bd2d71d78320 Mon Sep 17 00:00:00 2001 From: Piotr Binkowski Date: Thu, 16 Jul 2020 13:31:16 +0200 Subject: [PATCH] Internals: add isProgram to AstModule (#2470) This allows to check which AstModules were created from `program` keyword --- src/V3AstNodes.h | 9 ++++++--- src/verilog.y | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 8ae44fd9b..28d7c003e 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -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 { diff --git a/src/verilog.y b/src/verilog.y index 2e804a72f..b8d9f2cb8 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -1465,7 +1465,7 @@ program_declaration: // IEEE: program_declaration + program_nonansi_header + pr pgmFront: yPROGRAM lifetimeE idAny/*new_program*/ - { $$ = new AstModule($3,*$3); + { $$ = new AstModule($3, *$3, true); $$->lifetime($2); $$->inLibrary(PARSEP->inLibrary() || $$->fileline()->celldefineOn()); $$->modTrace(GRAMMARP->allTracingOn($$->fileline()));