[antlr-interest] ANTLR 3 rewrite rule syntax
David Holroyd
dave at badgers-in-foil.co.uk
Mon Dec 4 09:19:13 PST 2006
On Mon, Dec 04, 2006 at 03:56:45PM +0200, Shmuel Siegel wrote:
> Consider
>
> rule : A? B (id+)=C*
>
> I know that I can write -> A? MYTOKEN[$B] $id*
>
> But how can I make private tokens from "A" and "C". Ultimately "C" can
> be handled by a subrule but how do I issue a conditional token in my
> rewrite. MYTOKEN[$A?] and MYTOKEN[$A]? don't seem to work.
In addition to Jim's suggestion, you could also push "A" into another
rule:
rule : myA? B (id+=C)* -> myA? MYTOKEN[$B] $id
;
myA : A -> MYTOKEN[$A]
;
ta,
dave
--
http://david.holroyd.me.uk/
More information about the antlr-interest
mailing list