[antlr-interest] Multiple string template rule

Jim Idle jimi at temporal-wave.com
Tue Oct 25 09:02:29 PDT 2011


Probably because you are modifying the OR rule and not the AND rule.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Tim Poole
> Sent: Tuesday, October 25, 2011 8:54 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Multiple string template rule
>
> Hi all,
>
> I'm trying to use the += in the following rule, but I'm not sure if my
> use of it is correct.
>
> Does anyone have any thoughts?
>
> I'm trying to convert:
>
> rule != "working" and mental_state == "distressed"
>
> into:
>
> rule != "working" && mental_state == "distressed"
>
> Obviously, this snippet of grammar doesn't cover the expressions
> (andExpr) on either side of the "and", but I hope it gives you a
> flavour of what I'm trying to achieve.
>
> orExpr
>      : a=andExpr (OR b+=andExpr)* -> template(a={$a.text}, bf={$b})
> "<a><bf; separator=\" && \">"
>      ;
>
> Regards,
>
> Tim.
>
> 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