Modifying AST and generating source code
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 1k
- Forks
- 194
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 15
Description
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 a Prism::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 a NodeTransformer 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!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Prism.parse(text) entry point and Prism::Visitor usage described in the issue. Check whether Prism documents mutable AST traversal or source regeneration, and identify the existing examples or tests covering these APIs. The scope is complete only when the supported transformation and unparse behavior are defined and documented or implemented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100