Hi Ter, all!

  I never did get fully functional with ANTLR 3, and returning after a
long hiatus I find ANTLR 4 on the horizon.  :)  How time flies.  But
getting down to business, I've been looking at ANTLR 4 for a personal
project I'm wanting to do, have cloned it on github, and am playing
around with it.  Some observations:

* Seemingly the codegen in v4's current code is driven by a "language"
option in the grammar.  Notwithstanding the fact that I haven't yet
figured out precisely where to set this if I want to toy with a new
codegen target, if one of v4's goals is to decouple a given grammar
from its targets, wouldn't it be more to the point to add a Tool
option to specify the desired output language?

* Taking further some of the extensibility requests I came across in
the ML archives, what about the idea of abstracting the notion of a
Grammar processor, e.g.:

public interface GrammarProcessor {
  void process(Grammar g);
}

and

public class CodeGenPipeline implements GrammarProcessor {
  public void process(Grammar g) {
    ...
  }
}

Now Tool could accept an option of a classname specifying whatever
kind of GrammarProcessor to use, defaulting to CodeGenPipeline.  This
could open up some interesting possibilities.  For example, AFAICT
there is currently no obvious way to add CodeGeneratorExtensions.
Maybe a custom CodeGenPipeline subclass would offer an easy foothold
for this.

These are just some thoughts I'm kicking around as I look at v4's code
generation.  I've got some other items I'd like advice on; these will
explain *why* I'm looking at codegen.  ;)  I think that email is more
properly addressed to antlr-interest, however, so stay tuned!

Matt
_______________________________________________
antlr-dev mailing list
antlr-dev@antlr.org
http://www.antlr.org/mailman/listinfo/antlr-dev

Reply via email to