[antlr-interest] StringTemplate in ANTLR Grammars
Zachary Palmer
zep_antlr at bahj.com
Sun Oct 24 08:23:57 PDT 2010
All,
I've noticed that when I write a Java action in an ANTLR grammar that
contains a modulus operator ('%'), I have to escape that operator. It
appears to have to do with StringTemplate and the like, but this is the
case even when I don't have output=template.
So does StringTemplate have some additional behavior in ANTLR? Is it
possible for me to use StringTemplate as a sort of macro language over
the ANTLR grammar in order to template rules I create on a regular
basis? More importantly, could I do this without writing any extra
tooling or having escapes scattered all over my grammar? I read through
The Definitive ANTLR Reference, but it simply discusses using ANTLR to
produce string templates. If this is not possible, then why does ANTLR
process my grammar actions in such a way that I have to escape the %?
Thanks,
Zachary Palmer
More information about the antlr-interest
mailing list