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

Suggestion for transformation of parse tree #547

Open
acbokade opened this issue Sep 18, 2023 · 0 comments
Open

Suggestion for transformation of parse tree #547

acbokade opened this issue Sep 18, 2023 · 0 comments

Comments

@acbokade
Copy link

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?

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