Skip to content
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

macro call parsing issue #140

Open
gjcoram opened this issue Jul 12, 2024 · 2 comments
Open

macro call parsing issue #140

gjcoram opened this issue Jul 12, 2024 · 2 comments

Comments

@gjcoram
Copy link

gjcoram commented Jul 12, 2024

If I have
`define myexp exp
and then call it with
y = `myexp(5.0);
OpenVAF complains
error: argument mismatch expected 0 but found 1!

If I do
y = `myexp (5.0);
then it works fine -- note the space before the open-parenthesis.

The parser properly looks for an open-parenthesis when parsing the define: if it finds a parenthesis before any whitespace, then there are arguments for that macro. But when parsing the call, this is not the proper way to determine whether there are arguments.

Interestingly, it seems that the parser can support a macro call in the formal arguments:
`define myadd(arg1, arg2) (arg1) + (arg2)
which seems a little weird. parse_define calls parse_macro_token, which can get macros.

@gjcoram
Copy link
Author

gjcoram commented Jul 12, 2024

I have a way to fix this, but it's inefficient, because it clones the AHashMap for the macros, in order to be able to look up the number of arguments for the macro, to know if the macro call should have any.

gjcoram added a commit to gjcoram/OpenVAF that referenced this issue Jul 14, 2024
@gjcoram
Copy link
Author

gjcoram commented Jul 14, 2024

I found a better way to fix this and have added it to my fork.

arpadbuermen pushed a commit to arpadbuermen/OpenVAF that referenced this issue Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant