I am working with antlr4 to create a tree from cobol code and my main objective is to add new code by modifying tree. Are there any way to modify or add new nodes to the tree and generate a new cobol code from this new tree?
For example, If I have a cobol code with
DISPLAY "Hello world!".
I want to modify the text "Hello world!" or adding a new node with the code
DISPLAY "Hello again!".
And from this, generate a new updated cobol code from this new modified tree.
Thanks in advance!
Antlr4 does not support direct modification of the parse-tree. Instead, it prefers decoration of the parse-tree nodes. So, on your output pass over the parse-tree, just check the decorator instances for updated node values and generate accordingly.