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

Visitor example #271

Open
DMS-CPP opened this issue Mar 11, 2023 · 3 comments
Open

Visitor example #271

DMS-CPP opened this issue Mar 11, 2023 · 3 comments

Comments

@DMS-CPP
Copy link

DMS-CPP commented Mar 11, 2023

Could you please provide a short example for how to use traverser::Visitor? I'm not sure how to match for &mut dyn Node cases when traversing the AST

@ryangjchandler
Copy link
Collaborator

Hey @DMS-CPP, what sort of thing are you trying to do with the Visitor exactly? I might be able to provide some more specific help.

The README / docs need updating once I've tagged another release.

@DMS-CPP
Copy link
Author

DMS-CPP commented Mar 11, 2023

I'm just not sure how I could traverse the AST with the Visitor and call different functions for some kind of Nodes. Some practical examples for Visitor would be very helpful. For example if it could be used to find a pattern and modify the AST

@ryangjchandler
Copy link
Collaborator

The crate provides a downcast() method and downcast_mut() method which can be used to convert the trait object into a struct or enum.

I'll provide some examples when I'm at my laptop as part of the README.

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

2 participants