[antlr-interest] heterogeneous trees and importing vocabularies (v2.7.x)

Ric Klaren ric.klaren at gmail.com
Tue Feb 14 11:20:37 PST 2006


Bryan Ewbank wrote:
> Have a C++ code-generation question (but have a bad feeling about it :-)...
> 
> I am using importVocab for my parser and all the tree parsers; I am
> now starting to consider using a heterogeneous tree.  My problem, and
> the question, is

I cannot really recommend the heterogeneous AST stuff... you're bound to
run into quirks/problems/limitations of the reference counter.

> Are heterogeneous trees and the importVocab option mutually exclusive?
>  The error I get when I add a tokens{} section to a grammar seems to
> imply that is so.

I would have to check the source, what is the message you get?

> To push a bit further, is there any way folks have come up with to use
> templated types as the AST types?
>    // this goes boom (error "excepting CLOSE_ELEMENT_OPTION, found '<' ")
>    tokens {
>       PLUS<AST=Node<PLUS> >;
>    };

Hmmm would require building escaping into antlr.g... Does it work to
typedef the node type outside somewhere?

Cheers,

Ric


More information about the antlr-interest mailing list