[antlr-interest] Grammar Problem With Custom Nodes
Miguel Marques
mig.marques at gmail.com
Sun Jun 22 10:44:42 PDT 2008
Hy again,
Another thing that I've noticed, if my input is "x,y" I get an
Ident_List ( VarIdent(x) VarIdent(y)) which is correct. If my input is
"x,y,z" I get an Ident_list ( CommonToken(x), CommonToken(y),
CommonToken(z)).
My problem seems to be only with list of idents with length longer
than 2.
thanks,
Miguel
On 2008/06/21, at 17:50, Miguel Marques wrote:
>
> 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
>
More information about the antlr-interest
mailing list