[antlr-interest] Multiple string template rule

Tim Poole tim at poole.co.uk
Tue Oct 25 08:53:59 PDT 2011


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.


More information about the antlr-interest mailing list