[TypeScript target] Suggestion for transformation of parse tree

24 views
Skip to first unread message

Ajinkya Bokade

unread,
Sep 19, 2023, 2:09:39 PM9/19/23
to antlr-discussion

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?

Reply all
Reply to author
Forward
0 new messages