[antlr-interest] Using Tree Interface not plain Object

Terence Parr parrt at cs.usfca.edu
Sun Sep 4 13:09:21 PDT 2011


On Sep 4, 2011, at 12:49 PM, Oliver Zeigermann wrote:

> What would be the benefit of introducing and then requiring those
> interfaces?

Breaking up the interfaces make sense so code can use the least restrictive interface.

Requiring something other than object is not necessary since we have the tree adapters and the ASTLabelType option.  In fact, I just noticed that if you don't specify such a label type, I default to CommonAST. You would have to manually set it to Object. I originally thought that some clever person might want to use the token objects themselves as tree nodes to avoid doubling the number of objects traversed by the garbage collector.

> Might make sense when you want to do automatic tree
> traversal, but maybe not when you want to create any kind of object
> where you might not even have a (single) parent or a flat list of
> children. Would it be possible to have both? Tree interfaces for
> homogeneous, normalized trees that can be processed further using
> ANTLR and whatever you want to generate if you do not want further
> ANTLR processing?

 I guess we can just leave that part the way it is.

 splitting up the interfaces though is a good idea because it's making the code a lot cleaner.

Ter



More information about the antlr-interest mailing list