Replies: 2 comments 1 reply
-
It's not exactly clear what you're trying to achieve here; some guesses based on what you've said:
Some background to help discussion:
|
Beta Was this translation helpful? Give feedback.
-
After looking at a (very) simple testcase, I might be starting to understand why I had such trouble. // Test comment
`define FOO(x) x+1
class bar;
function new()
int i = 0;
`FOO(i);
endfunction;
endclass Is the following stuff: Hidden CST, as fairly long
I can see that the If so, would you have a method to reliably detect and position that macro in the context of scopes and such ? // Test comment
class bar;
function new()
// Define placed at a very weird place...
`define FOO(x) x+1
int i = 0;
`FOO(i);
endfunction;
endclass In this case, just using the SyntaxVisitor and handle the Moreover, for the macro usage, the CST would mean that, post processing, there is something like `FOO(i) // Actually is not really used, is a MacroUsageSyntax
i+1 // Is inserted and actually doing the job. Which would mean that I need to lookup the Finally, I found out that declaring
|
Beta Was this translation helpful? Give feedback.
-
Hi there !
I am struggling at performing sourcefile lookup when macro are involved.
More precisely, working in the context of a language server, I want to improve my symbol detection and definition/references lookup.
The final objective is to be able to lookup a symbol and all its references from a file path and a range.
This was fairly straightforward while only synthetizable RTL was involved : I perform an elaboration, visit what I believe is the CST (the Symbol/Scopes tree) in order to detect all symbols as declarations then go through the AST to detect all kinds of syntax nodes that would be a reference and lookup the symbol based upon the context.
This was done using some tricks but works fairly well.
Problems arise when trying to include UVM in the equation.
The main issue is that UVM uses and abuses of macros, and macros breaks the equivalence between a buffer and the original file. Hence, instead of having a syntax node like
MacroUsageSyntax
(or whatever) the Macro is expanded and it results in a mess.The solution I am envisaging at the moment is something like:
This approach seems rather tedious, in particular "detecting" the scope in step 2, but I am not aware of another solution with slang.
Could you tell me if slang have some mechanisms that would ease this or should I dive in the hard way ?
Beta Was this translation helpful? Give feedback.
All reactions