[antlr-interest] Rewriting in non tree grammar

Terence Parr parrt at cs.usfca.edu
Thu Feb 26 13:22:34 PST 2009


On Feb 26, 2009, at 12:55 PM, Indhu Bharathi wrote:

> Hi,
>
> Suppose I want to do something like this
>
> methodDecl       :               scope t=returnType ident LRAPEN  
> RPAREN
>                                 {
>                                                 insertBefore(t,  
> “something”);
>                                                 or
>                                                 replace(t,  
> “something”);
>                                                 or
>                                                 insertAfter(t,  
> “something”);
>                                 }
>
>
> How can I do this in ANTLR? Note that ‘returnType’ is non-terminal.  
> Also, I don’t want to use tree grammar or string templates. Is this  
> possible with TokenRewriteStream. Is there some documented example  
> in the wiki?
>

Yes, use that class.  easy.  Should be some examples somewhere.

Ter



More information about the antlr-interest mailing list