[antlr-interest] Code generation advice

Matt Benson gudnabrsam at gmail.com
Wed Jun 20 09:08:41 PDT 2012


Hi all,
  In the Java ecosystem embedded DSLs have become increasingly popular
over the past several years.  In my opinion the primary drawback to
these is the painful task of their creation.  For this reason I want
to experiment with the generation of Java interfaces from EBNF-style
grammars to see what I can accomplish, in true Dr. Terence Parr "why
program by hand in 5 days..." fashion.  I have explored, for example,
xtext, but the process of going from its meta-grammar to EDSL code is
non-obvious.  I'm open to other suggestions if anyone has any, but in
the meantime I'm looking at ANTLR 4 and/or 3-based approaches.  It
would seem most appropriate to use the ANTLR 4 meta-grammar, from
which point I would seem to have the following options:

* Implement a custom code generation target for ANTLR 4
* Use ANTLRMorph with the ANTLR 3-based ANTLR 4 meta-grammar

It might well be the case that these differ only in the manner in
which the output stringtemplates are provided.  Does anyone have any
opinions on which approach is to be preferred?  Failing that, I am
willing to entertain aspersions cast on, or less likely, advocations
in favor of, my sanity in conceiving this endeavor.

Thanks in advance for any input,
Matt


More information about the antlr-interest mailing list