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

Formatting Nodes instead of ParseResults #3

Open
joeldrapper opened this issue Feb 2, 2024 · 0 comments
Open

Formatting Nodes instead of ParseResults #3

joeldrapper opened this issue Feb 2, 2024 · 0 comments

Comments

@joeldrapper
Copy link

It looks like Prism::Format is currently set up to format Prism::ParseResults. Is there any scope to have it format Prism::Nodes?

It looks like you can create a new Prism::Format with an empty string and then get a Prism::Node to accept it, but then there are issues with an assumed stack. For example, when visiting a block node, it is assumed that @stack[-2] exists and responds to type.

I’m using Prism to find specific patterns and re-write them into better optimised code, so I’m looking to take a mutated Prism::Node and turn it into Ruby that can be eval’d. I don’t know if this kind of round-tripping is a goal for SyntaxTree, or if the focus is more on being a formatter for files.

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

1 participant