[antlr-interest] passing parts of the parse around as parameters(newbie)

Gavin Lambert antlr at mirality.co.nz
Sun Jan 25 17:35:05 PST 2009


At 11:23 26/01/2009, Carter Cheng wrote:
 >rule1: type idlist[type];
 >
 >idlist[.... t]: var[type] (COMMA var[type])*;
 >
 >var[... t]: ID -> ^(ID $t);
 >
 >I tried using ANTLR3_BASE_TREE but the last construct does not 
seem
 >to work properly. What is the default return type for a rule in
 >buildAST mode?

Each rule will typically have its own custom return type (eg. the 
idlist rule will return an idlist_return object).

To pass a tree in as a parameter, do something like 
var[$type.tree].



More information about the antlr-interest mailing list