New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preprocessor callback request #94
Comments
Original Redmine Comment The Verilog::Preproc::def_value callback handles this now; by default it calls Verilog::Getopt. You can change it to do whatever you like, or intercept the Getopt's version by subclassing Verilog::Getopt and passing a reference to that new class in the opt=> argument of the Verilog::SigParser->new call. |
Original Redmine Comment I'll give it a try, thanks! |
Original Redmine Comment Hi Wilson, Does this work for macros with arguments? I haven't find the way to do what I need. Ideally what I need is to know what is going to be substituted (before it actually is substituted) and a way modify it before it is substituted. In other words this would be a callback (once the macro's actual argument have been inserted in the macro-value) once the macro-value is ready to substituted in the buffer (but before it is actually substituted), with an input argument providing the actual macro-value, and expecting a return value with the modified macro-value (a string which is what will be actually substituted). Is there away to do this with the current capabilities of the Verilog::Preproc Thanks in advance |
Original Redmine Comment I think you're looking for VPreprocImp::defineSubst, which is in c++ code to call a perl hook at the bottom? IE calling `foo(bar) would insert result_of(CALLBACK(definition_with_foo_bar_expanded))? |
Original Redmine Comment Thats what I need. I'll take a look. Thanks |
Original Redmine Comment Hi guys, David, I had the same problem recently and I modified the Verilog::Preproc to add a new callback. As Wilson said you need VPreprocImp::defineSubst. The new callback is "subsdef" and some of the features that it has are:
I hope this callback can help you. Thanks Wilson Verilog-Perl is an excelent open soure project, I would like to contribute with new features. |
Original Redmine Comment Thanks, that worked fine!. |
Original Redmine Comment Saul, Thanks for patching this, it's great to have contributions and I want to add it to the next release. Sorry, perhaps I missed something, but the four files attached here seem to match the distribution version and don't have any changes in them. Can you attach the changes (best is a "git diff" off from the git version.) I'm also confused as to what David tried. |
Original Redmine Comment Hi Wilson, I know Saul from school and we're working on similar projects. He sent me the extended parser code prior to the post, so I never really checked the code he uploaded with his post. :P Anyhow, here is the code Saul sent me originally, which adds the aforementioned callback (changes made by Saul). |
Original Redmine Comment Thanks for the files. Unless you see a reason not to, I think the callback should also be called for non-parameterized defines. While defValue could be hacked to do the same thing for non-param defines only, it seems non-obvious that substDef wouldn't be called for both types. |
Original Redmine Comment I made two changes; I call the callback on non-parameterized defines, and I renamed it def_substitute to match the other def_* functions. And I added a test. Thanks again for the patches. I've pushed this to git, and it will be in the next release. |
Original Redmine Comment In 3.211. |
Author Name: David A
Original Redmine Issue: 94 from https://www.veripool.org
Original Date: 2009-05-27
Original Assignee: Wilson Snyder (@wsnyder)
Hi,
I might be wrong, but I haven't found a way (callback) to let the parser notify me when a (previously define) MACRO is being substituted.
Would it be possible to include such a callback? preferably if the callback could provide (argument list) the text to be substituted (once all MACRO arguments have been resolved).
Thanks,
David
The text was updated successfully, but these errors were encountered: