[antlr-interest] AST rewrite
Mark Volkmann
r.mark.volkmann at gmail.com
Wed Jan 30 05:48:03 PST 2008
I have the following rule in my parser grammar and it works just fine.
I don't know how though. Note how my rule matches "term" in two places
and I refer to both of them in my rewrite rule without assigning them
to variables.
polynomial[String fnt, String fvt]
: term[$fnt, $fvt] (SIGN term[$fnt, $fvt])*
-> ^(POLYNOMIAL term (SIGN term)*);
Why does this work? I thought I'd have to do something like this.
polynomial[String fnt, String fvt]
: t1=term[$fnt, $fvt] (SIGN tn=term[$fnt, $fvt])*
-> ^(POLYNOMIAL $t1 (SIGN $tn)*);
--
R. Mark Volkmann
Object Computing, Inc.
More information about the antlr-interest
mailing list