[antlr-interest] Rewriting in non tree grammar
Indhu Bharathi
indhu.b at s7software.com
Thu Feb 26 20:11:20 PST 2009
Hi,
I'm sorry I don't understand. When I write
a : t=B C ;
t will be of type token and I can use it in action. But when I write,
a : t=b c ;
t is not of type token. Infact no code is generated for 't'. So how do I do
I refer to it in action?
Also I don't find any example out there for this requirement. Can anybody
explain a little more clear. Sorry if there is some simple way to do it and
I'm not getting it.
- Indhu
-----Original Message-----
From: Terence Parr [mailto:parrt at cs.usfca.edu]
Sent: Friday, February 27, 2009 2:53 AM
To: Indhu Bharathi
Cc: 'antlr-interest'
Subject: Re: [antlr-interest] Rewriting in non tree grammar
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