Skip to content

Suggestion for transformation of parse tree #547

Open
@acbokade

Description

We are trying to write a grammar for spreadsheet language.
The parse tree gets generated according to the grammar.
We want to add one more phase after the initial generation of parse tree where we want to transform some nodes in the tree to new nodes.
Basically, we want to replace some nodes with new dynamically created nodes.

In typescript generator parser code,
I went over the methods in ParserRuleContext and RuleContext class.
RuleContext has method setParent and ParserRuleContext has method to addChild.
I can create a new node and then set its parent but how can I replace a particular child of parent node to newly created node?

Also, if this is not the best practice, what are some other options to achieve the same?

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