Updated code based on PR feedback Created new functions to capture the different categories of directives.
diff --git a/verible/verilog/parser/verilog-token-classifications.cc b/verible/verilog/parser/verilog-token-classifications.cc index 27ab8ba..1e53ceb 100644 --- a/verible/verilog/parser/verilog-token-classifications.cc +++ b/verible/verilog/parser/verilog-token-classifications.cc
@@ -92,17 +92,8 @@ } } -bool IsPreprocessorKeyword(verilog_tokentype token_type) { +bool IsCompilerDirective(verilog_tokentype token_type) { switch (token_type) { - case verilog_tokentype::PP_include: - case verilog_tokentype::PP_define: - case verilog_tokentype::PP_ifdef: - case verilog_tokentype::PP_ifndef: - case verilog_tokentype::PP_else: - case verilog_tokentype::PP_elsif: - case verilog_tokentype::PP_endif: - case verilog_tokentype::PP_undef: - // Compiler directives (DR_*) case verilog_tokentype::DR_timescale: case verilog_tokentype::DR_resetall: case verilog_tokentype::DR_celldefine: @@ -132,6 +123,22 @@ } } +bool IsPreprocessorKeyword(verilog_tokentype token_type) { + switch (token_type) { + case verilog_tokentype::PP_include: + case verilog_tokentype::PP_define: + case verilog_tokentype::PP_ifdef: + case verilog_tokentype::PP_ifndef: + case verilog_tokentype::PP_else: + case verilog_tokentype::PP_elsif: + case verilog_tokentype::PP_endif: + case verilog_tokentype::PP_undef: + return true; + default: + return IsCompilerDirective(token_type); + } +} + bool IsPreprocessorControlToken(verilog_tokentype token_type) { switch (token_type) { case verilog_tokentype::PP_Identifier:
diff --git a/verible/verilog/parser/verilog-token-classifications.h b/verible/verilog/parser/verilog-token-classifications.h index e6109c5..4b15df0 100644 --- a/verible/verilog/parser/verilog-token-classifications.h +++ b/verible/verilog/parser/verilog-token-classifications.h
@@ -40,6 +40,10 @@ // Returns true for `ifdef, `define, `include, `undef, etc. bool IsPreprocessorKeyword(verilog_tokentype); +// Returns true for SystemVerilog compiler directives (DR_*), e.g. `timescale, +// `default_nettype, `resetall, etc. +bool IsCompilerDirective(verilog_tokentype); + // Returns true for any preprocessing token, not just control flow. bool IsPreprocessorControlToken(verilog_tokentype token_type);