[antlr-interest] template rewrites
Steve Ebersole
steve at hibernate.org
Thu Apr 30 09:24:16 PDT 2009
And...
On Wed, 2009-04-29 at 18:49 -0500, Steve Ebersole wrote:
> Also, for "simple token" matches I end up with stuff like:
>
> numeric_literal
> : INTEGER_LITERAL -> template(id={$INTEGER_LITERAL.text}) "<id>"
> | DECIMAL_LITERAL -> template(id={$DECIMAL_LITERAL.text}) "<id>"
> | FLOATING_POINT_LITERAL -> template(id={$FLOATING_POINT_LITERAL.text})
> "<id>"
> ;
>
> Is the a better pattern which can be applied here?
>
> On Wed, 2009-04-29 at 18:43 -0500, Steve Ebersole wrote:
> > I am trying to develop a grammar which uses StringTemplate for its
> > rendering. But I find something rather annoying and wanted to see if I
> > am just missing something. Basically I have a bunch of rules which call
> > other rules; the "top" rule is just to group like rules together. For
> > example:
> >
> > function
> > : castFunction
> > | trimFunction
> > ...
> > ;
> >
> > All the rules under function return StringTemplates. Yet in order to
> > get any output, I need to do the following:
> >
> > function
> > : castFunction -> {$castFunction.st}
> > | trimFunction -> {$trimFunction.st}
> > ...
> > ;
> >
> > Which seems redundant to me. Is there something I am missing?
> >
--
Steve Ebersole <steve at hibernate.org>
Hibernate.org
More information about the antlr-interest
mailing list