[antlr-interest] Replacement of language specific actions with a general language?

Monty Zukowski monty at codetransform.com
Mon Mar 19 09:53:51 PDT 2007


On 3/17/07, Johannes Luber <jaluber at gmx.de> wrote:
> Hello,
>
> I've read about Terrance's project regarding grammar comparison, which
> got me thinking. The problem is that, while there is a unique grammar
> definition language (UGDL), that this UGDL doesn't cover implementation
> issues. Those implementation issues result in separating one single
> grammar into several ones, depending on the number of implementation
> targets.
>
> The obvious solution is to define a companion language or a simple
> extension to the UGDL, which is subsequentially translated into language
> constructs of the target language. So far I can see only two problems
> with this approach (to burden target developers with more work may be a
> disadvantage, but isn't a problem):

Terence, Loring and myself discussed this at length at the 2003 ANTLR
Cabal http://www.antlr.org/workshop/cabal-2003/index.html.

Our conclusion was that there were too many details to work out, and
that it wasn't worth the effort.

This is a nuisance when maintaining grammars across targets.  If I
were in that position, I would do one of these:

1) write my own preprocessor to expand list and symbol table functions
into the appropriate target language

2) write my own target language module which translated the custom
functions first and then called the actual target language module to
generate the appropriate code

3) write the grammar in a literate programming language like noweb,
which would be my preferred way to preprocess the source (requires a
little tweaking of noweb)

Monty


More information about the antlr-interest mailing list