[antlr-interest] Help with compressing trees and custom nodes
tnine at apigee.com
Thu Mar 15 11:02:11 PDT 2012
Hi guys. I'm new to antlr and have a question regarding tree compressions.
My ultimate goal is to use my grammar to create an AST. From this AST I
then will utilize the visitor pattern to walk the tree and evaluate my
results for our Cassandra query engine. I'm having issues with my tree
having a lot of additional nodes that don't have 2 children due to operator
precedence. My questions are below.
1. How can I create a different node class for each element? For instance,
&& ad || need their own nodes, as well as 'NOT' 'within' etc
2. How can I collapse tree elements that only have 1 child. I.E turn orexp
-> andexp -> notexp -> andexp into just an andexp node
I've read all the documentation here, but I have a few things that aren't
When creating my own node classes, it's not clear to me if I need to
subclass an antlr node class, or just create any class. Are there any
examples on both compression and creating custom classes?
More information about the antlr-interest