[antlr-interest] Quick ANTLR/ST question
Bill Andersen
bill.andersen at mac.com
Sun Aug 28 17:08:41 PDT 2011
Nevermind, answered my own question with some dim memories and some playing around.
On Aug 26, 2011, at 11:15 , Bill Andersen wrote:
> Hi all...
>
> I have the following production alternative:
>
> | ^(ASTERISK e1=unary_expression e2=unary_expression)
>
> and want to use templates that look like this in my STG:
>
> app2(op,e1,e2) ::= "<op>(<e1>,<e2>)"
>
> op_ASTERISK() ::= "mult"
>
> Question is - if I want to keep the translation of ASTERISK in the STG, how do I express the template return in the alternative above. E.g.,
>
> | ^(ASTERISK e1=unary_expression e2=unary_expression)
> -> app2(op=???, e1={$e1.st}, e2={$e2.st})
>
> What goes in the place of ??? to cause op_ASTERISK() to be inserted into the resulting ST?
The answer is:
-> app2(op={%op_ASTERISK()}, e1={$e1.st}, e2={$e2.st})
Could not find this in any doc to save my life, but the generated code is correct.
>
> Using ANTLR 3.3 / ST 3...
>
> Thanks
>
> .bill
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest
mailing list