[antlr-interest] Template rewriting: processing lists of things (possible bug?)

Conrad Hughes antlr at xrad.org
Wed Mar 9 07:27:46 PST 2011


Terence> Rules do not return templates by default; you have to set them.
Terence> any that does not returns a null, hence, the list of nulls you
Terence> get :)

Thanks for clarifying this.  Dunno if I could table a configurable
alternative (unmodified-defaults-to-self, or something) as a wishlist
item for some future version --- I'm doing some moderately substantial
rewrites on Java source, and in collecting lists of various kinds like
this (where some of the elements are rewritten and some aren't) I end up
having to modify quite a number of rules to just rewrite themselves as
themselves:

  container: (l+=element) -> template(...) "<l:{...}>" ;

  element
      : foo -> template(self={$text}) "<self>"
      ...
      | actualRewrittenStuff
      ;

Regards,
Conrad


More information about the antlr-interest mailing list