[antlr-interest] template rewrites

Steve Ebersole steve at hibernate.org
Wed Apr 29 16:43:16 PDT 2009


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