[antlr-interest] Somewhere between actions and string templates

Terence Parr parrt at cs.usfca.edu
Sat May 19 16:20:51 PDT 2007


On May 18, 2007, at 1:59 PM, Ted Villalba wrote:
> expression returns [String subexpr]:         ^('=' tag (v+=value)+)  
> -> template(values={$v}) "<values>" ;
>
>
>
> //          
> {                                                            // 
> Commented out this code to add the template
>
> //           $subexpr=$tag.text+":"+$value.text;      //added the  
> template because this $value.text would only grab the first value
>
> //       }
>
> //      ;
>
>
>
> I am not so interested in printing something out, but rather in  
> passing back subexpr once I can get the list of ‘values’ into that  
> expression( $subexpr=…).

With output=template option rule expression will implicitly return a  
ST.  The explicit return values are no longer needed.

What you have should work fine.  What is going wrong?
>  Somewhat related, in the book when StringTemplates are introduced,  
> the embedded actions go away, yet the return statements remain, so  
> I don’t see how the [int value] is populated here. Maybe if I  
> understand that, it will help me with the above.

ooops.

Ter


More information about the antlr-interest mailing list