[antlr-interest] New AST and findAll in C++

Ric Klaren ric.klaren at gmail.com
Tue Nov 30 10:57:42 PST 2004


Hi,

On Mon, 29 Nov 2004 21:59:49 -0500, Bryan Ewbank <ewbank at synopsys.com> wrote:
> I'm attempting to use findAll in the C++ world with a new node type
> (ASTLabelType="MyNodeRef"), and have problems because the functions are all
> declared using the BaseAST referent class - thus the link fails because of
> type mismatches.

The link fails ? Or the compile ? I would suspect some casting to be
necessary or reconstruction of a RefAST reference counter from the
MyNodeRef input, whichever works. I never use the findAll things. I
could suspect they don't work very well with custom ast's due to the
reference counter.

> Do I need to redefine all these functions in my new AST node type, or do I
> just use vector<RefAST> and pretend it matches??

If you do redefine them, make them templates outside the the AST
nodes, that way the compiler will sort things out for itself with some
luck. Keeping algorithms like this and the types they work on
separated is really good practice.

Cheers,

Ric


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list