-
Notifications
You must be signed in to change notification settings - Fork 154
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
Modifying AST and generating source code #3466
Comments
If it can't be done to generate the source, I don't require the generated source code as long as I can run the modified AST result. Something like |
@kddnewton Any insights on this? |
Not quite sure why you pinged me on this 😅 I guess because I worked on the |
@Earlopain thanks ... I was just looking for advice for someone knowledgeable about Prism to weigh in on whether this was even possible right now. |
Forgive my ignorance but I'm trying to use Prism to modify Ruby source (add nodes) and then regenerate the source to be interpreted. I'm using
Prism.parse(text)
and then implementing aPrism::Visitor
to potentially modify the nodes as they are visited. I assume this is possible but I haven't really seen any examples of it. Finally I would like to 'unparse' the AST back into source code.The Python equivalent is indeed
unparse
which is where I'm taking many of the ideas. They also have aNodeTransformer
which is allowed to modify the nodes in the visit pattern. I don't see equivalents in Prism but perhaps you're always allowed to modify the nodes ... this is Ruby afterall.Thanks for any help pointing me in the right direction!
The text was updated successfully, but these errors were encountered: