[antlr-interest] advocacy of C++ support in ANTLR 3.x

Tomas Potrusil potrto at centrum.cz
Thu Apr 3 00:27:26 PDT 2008


> If they want to replace the entire tree structure, then they 
> ignore ANTLR3_COMMON_TREE and inherit from 
> ANTLR3_BASE_TREE_ADAPTOR; this requires them to implement all 
> methods, but means that their tree node could be some C++ type 
> completely divorced from ANTLR -- the adaptor carries the burden 
> of converting the interfaces.

This is exactly what I wanted to say. Thanks Gavin.

I think that this is exactly the reason why adaptors were introduced. To be
completely independent of the ANTLR tree classes/structures. If you omit
this independence then the adaptors are not real adaptors as they do not
adapt your classes to something ANTLR can understand. In the current
situation you can remove all the "adaptive" functions from
ANTLR3_BASE_TREE_ADAPTOR and call the functions directly on ANTLR3_BASE_TREE
- this change will preserve all other functionality, the uses will not need
to notice it... But then the ANTLR3_BASE_TREE_ADAPTOR will consist of
functions that do just some sugar (i.e. becomeRoot()), these could be also
removed somewhere else, and the rest will be just "factory methods". And
hence the ANTLR3_BASE_TREE_ADAPTOR will be renamed to
ANTLR3_BASE_TREE_FACTORY :-) It will be perfectly correct, the current
functionality will be entirely preserved, but this system will be obviously
without adaptors...

Tom



More information about the antlr-interest mailing list