Skip to content

Formatting Nodes instead of ParseResults #3

Open
@joeldrapper

Description

@joeldrapper

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions