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

Return Types for Visitors #23

Closed
aferr opened this issue Apr 21, 2021 · 1 comment · Fixed by #29
Closed

Return Types for Visitors #23

aferr opened this issue Apr 21, 2021 · 1 comment · Fixed by #29

Comments

@aferr
Copy link

aferr commented Apr 21, 2021

I was wondering if there is any plan to support parse tree visitors that return something as in the Java implementation of antlr. I find this is a convenient way to write a visitor that constructs AST node objects. Concretely, the current implementation of visit_terminal has signature:
fn visit_terminal(self, TerminalNode<...>) {},

but if it were instead

fn visit_terminal<T>(self, TerminalNode<...>) -> T {}
(and similar for the other functions in the ParseTreeVisitor trait)

then it would be possible to write a visitor that builds an AST by returning the AST nodes with each of these calls.

@rrevenantt rrevenantt mentioned this issue Aug 12, 2021
36 tasks
@aferr
Copy link
Author

aferr commented Aug 1, 2022

Thanks :)

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

Successfully merging a pull request may close this issue.

1 participant