[antlr-interest] template generation for dumb rules

Philippe Faes ph_reader at faes.net
Wed Mar 19 07:28:19 PDT 2008


Dear ANTLR-gang,

I'm writing an ANTLR stringtemplate generator, which translates a tree to a
string template. My grammar has many rules like this:
a : b | c;
The generation rule that I want for these rules looks something like:
a: b -> template(b={$b.st}) "<b>"
  | c -> template(c={$c.st}) "<c>";
In fact the stringtemplate just repeats whatever the underlying rule would
return as stringtemplate.
These rules have very little extra value, but they require a lot of typing,
and decrease the general readability of the grammar.
I was hoping to find a way of setting this "braindead" stringtemplate rule
as a default. Is there any way somebody can save me a lot of time typing
these rules?

kind regards
Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080319/f1a1cc20/attachment.html 


More information about the antlr-interest mailing list