[antlr-interest] setTreeAdaptor and delegates

Dimitrios Kolovos dskolovos at gmail.com
Fri Jun 20 05:20:36 PDT 2008


Hi,

In the composite grammar (3.1.b) that I'm working on, I need to set the 
TreeAdaptor of the generated parser to a custom one. I expected that 
setting the TreeAdaptor to the top-level parser would also propagate it 
in the delegates but this doesn't seem to be the case.

If implementing such a TreeAdaptor-propagating behaviour would be too 
much of a problem, it would be nice to at least have a field (e.g. 
"delegates") that contains a collection of all the delegates in the 
generated parser (in addition to the individual fields) so that one can 
implement this propagating behaviour in a recursive manner using a 
generic algorithm that doesn't need to know the names of each delegate. 
(Such a generic algorithm would also require the getTreeAdaptor() and 
setTreeAdaptor() methods to be moved to a core base-class such as Parser 
or Base Recognizer)

I've managed to do this using a custom base-class and reflection, but I 
thought this may be a useful enhancement for future versions of ANTLR. 
Any ideas?

Cheers,
Dimitrios


More information about the antlr-interest mailing list