Is it possible to determine whether a SyntaxNode or Token originates from the source text or is expanded from macros? #1172
-
Hi!👋 Thank you for your dedication to maintaining this project! I am currently learning the API of slang and have written some tests, and I noticed that slang automatically expands macros when generating a SyntaxTree. Is it possible to obtain a SyntaxTree that has not been preprocessed, or is there a method to distinguish whether a SyntaxNode originates from text or it is expanded from a macro? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You cannot obtain a non-preprocessed SyntaxTree; it's not possible to parse SystemVerilog without first expanding macros. You can check whether any particular token comes from a macro or not by looking at its SourceLocation and using SourceManager::isMacroLoc to check. |
Beta Was this translation helpful? Give feedback.
You cannot obtain a non-preprocessed SyntaxTree; it's not possible to parse SystemVerilog without first expanding macros.
You can check whether any particular token comes from a macro or not by looking at its SourceLocation and using SourceManager::isMacroLoc to check.