I have an ANTLR ParseTree for an sql grammar.
Example :
My goal is to edit this tree so that i can delete all the middle (booleanExpression, predicated, valueExpression, primaryExpression ) nodes inbetween. I have explored visitor and listenors but they don’t generate the tree for me. And i'd like to not touch the grammar since its the official source one.
So how can i do it? Thanks
There is no such feature in ANTLR's API (removing/mutating the
ParseTree). You'll have to walk the tree yourself and create a copy of theParseTreeand ignore certain sub-trees you do not want/need.