[antlr-interest] Grammar Problem With Custom Nodes

Miguel Marques mig.marques at gmail.com
Sat Jun 21 09:50:47 PDT 2008


Hello,
This is a small snippet of my grammar:

ident_list  : (R0+=ident -> $R0)
                ( ',' R0+=ident -> ^(TOKN_IDENT_LIST<Ident_List>  ident+ )
                 )* ;

ident   : T0=IDENT  -> ^( IDENT<VarIdent> ) ;

As you can see, I'm using custom nodes.

For the input  "x" I get a VarIdent object. Everything is ok so far.

For the input "x,y,z" I get a <Ident_List> with x,y,z as child's but they do
not belong to VarIdent class as I wanted.

Ident_List(root) -> [CommonTree(x), CommonTree(y)]

How can I tell that the "ident+" should produce a list of idents as childs
of Ident_List instanced as objects of the class VarIdent?

Ident_List(root) -> [VarIdent(x),VarIdent(y)]


thanks,
Miguel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080621/100b291f/attachment-0001.html 


More information about the antlr-interest mailing list