[antlr-interest] template generation for dumb rules

Grzegorz Cieslewski cieslewski at hcs.ufl.edu
Tue Mar 25 06:01:37 PDT 2008


I am in the similar situation.  In my grammar I have about 100 rules
like that.  I have saved some time by defining all templates in
separate file and creating template  simple(a)::="<a>" and then
invoking it multiple times whenever I have a "dumb" rule.  If any one
knows a better way of doing this I am all ears.

Greg

On Wed, Mar 19, 2008 at 10:28 AM, Philippe Faes <ph_reader at faes.net> wrote:
> 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
>
>



-- 
=====================================================
Grzegorz Cieslewski
Research Assistant
High-performance Computing & Simulation (HCS) Research Laboratory
University of Florida, Dept. of Electrical and Computer Engineering
330 Benton Hall, Gainesville, FL, 32611-6200
Phone: (352) 392-9041
Email: cieslewski at hcs.ufl.edu
Web: www.hcs.ufl.edu
=====================================================


More information about the antlr-interest mailing list