[antlr-interest] philosophy about translation

Monty Zukowski monty at codetransform.com
Fri Oct 6 12:52:54 PDT 2006


On 10/6/06, Terence Parr <parrt at cs.usfca.edu> wrote:

> Well, I'm not so much worried about how to differentiate the tree
> nodes per se.  I am concerned about making a union grammar that has
> to have both AREV_PLUS and VB_PLUS rules.  Or, if I'm doing this by
> hand, I have to have code that deals with both kinds of tree nodes.
> Propagating grammatical changes forward from phase n to n+i can be
> challenging even if using a grammar.
>
> > I had one super-treegrammar with two complete tree grammars therin.  I
> > found it convenient to bifurcate at the statement level.  For example:
> >
> > program: (statement)*;
> > statement:arevStatement | vbStatement;
>
>    Yes, but what happens when you decide that you need to do a
> transformation sooner than you had it before?  You need to modify all
> of the intermediate transformation phases to deal with new
> grammatical structure.  This cannot really be done automatically.

The thing is I don't need to remember which grammars to modify,
because I modify them all!  Most passes only subclass the rules they
care about, so if I add a new expression type, I only have to modify
the grammars with expression rules in them, etc.  My tree supergrammar
is the definitive grammar, the union of all steps.  I don't have any
way to have "ADD" mean two different things based on which pass I'm
at.

There's no way I could keep it straight if each pass had it's own
special grammar.

Monty


More information about the antlr-interest mailing list