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

Add ability to automatically generate default visitor methods that just "walk" the AST and return void #549

Merged
merged 2 commits into from Oct 26, 2022

Conversation

kontheocharis
Copy link
Collaborator

This adds the macros:

ast_visitor*_default_impl!(Expr, Name);

Providing the arguments Expr, Main, the macro will generate default implementations for those AST nodes. In subsequent PRs this can be used to replace all the manually written methods with this macro.

It would also be nice to have a way to "hide" AST nodes, but macros make that a little bit more complicated. It is left as a @@todo.

@kontheocharis kontheocharis added the ast Relating to AST label Oct 26, 2022
@kontheocharis kontheocharis self-assigned this Oct 26, 2022
compiler/hash-tree-def/src/emit.rs Outdated Show resolved Hide resolved
compiler/hash-tree-def/src/emit.rs Show resolved Hide resolved
@feds01
Copy link
Contributor

feds01 commented Oct 26, 2022

Very nice, should shave off another couple of 100loc within the visitor impls!

@kontheocharis kontheocharis merged commit 346570c into main Oct 26, 2022
@kontheocharis
Copy link
Collaborator Author

Closes #545.

@kontheocharis kontheocharis deleted the fix-545 branch October 26, 2022 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ast Relating to AST
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants