[antlr-interest] Problem #2: template lists expanding to weird stuff?

Terence Parr parrt at cs.usfca.edu
Wed Apr 16 08:42:02 PDT 2008


toString is called on all objects.  that is Token.toString().  use  
the .text property of each

<items:{<it.text>}; separator=", ">

Ter
On Apr 16, 2008, at 7:47 AM, Peter Nann wrote:

>
> Now, my grammar has a more serious template using Lists and the  
> '+=' operator.
>
> It is getting rather strange expanded output which looks like:
>
>         <one-of> [@2,2:2='x',<4>,1:2] </one-of>
>
>
> What the heck is going on there?
> It looks like the List object has expanded itself using some  
> strange toString() method.
>
> Any clues on this one?
>
>
> Updated grammar:
>
> ----------------------
> grammar Test;
> options {output=template; rewrite=true;}
>
> test
>         : '[' ( items+=WORD )* ']'
>                 -> template(items={$items})
>                         << \<one-of\> <items; separator=", "> \</ 
> one-of\> >> ;
>
> WORD : ('a'..'z'|'-'|'_'|'\'') ('a'..'z'|'-'|'_'|'\'')* ;
> WS : ( ' ' | '\t' | '\r' | '\n' )+ {$channel = HIDDEN;} ;
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080416/f614c244/attachment.html 


More information about the antlr-interest mailing list