[antlr-interest] Re: Translators Should Use Tree Grammars

John D. Mitchell johnm-antlr at non.net
Sun Nov 21 22:45:20 PST 2004


>>>>> "atripp54321" == atripp54321  <atripp at comcast.net> writes:
>>>>>> <oliver.zeigermann at g...> wrote:
[...]

>> I understand most of your stuff and especially the one about Magic.
>> What I do not quite understand that - as it seems - for the parser you
>> accept grammars are a concise language to describe the language to parse
>> and seem to prefer it over pure Java. Why not for certain tree
>> transformations? I understand in tree transformations the emphasis is
>> not on revealing structure (analysis), but rahter on what to do with
>> certain patterns (synthesis).Do you thing this the important difference?

> Yes, I think that's it exactly.  It seems to me that something like a
> C-to-Java translator is more like an English-to-Spanish translator than
> it is like a C-to-object code compiler. The work that needs to be done is
> so large and complicated, that it lends itself to a
> pattern-matching-and-replacement approach rather than a traverse-the-AST
> approach.

You've just given the rationale for running the hell away from the insanity
caused by "pattern-matching-and-replacement" approaches... They fail to
hold up under the pressure of non-trivial systems.  The very fact that
their behavior is incestuously emergent destroys any semblance of
robustness in the face of change, clarity in debuggability, etc.  The
simplest example of this nightmare is XSLT.  Even hardcore (from a rigor
POV) approaches like prolog work well only for constrained domains and
contexts).


[...]

> I mean look at this huge list of just some of what's needed to convert C
> to Java, omitting almost all detail: http://jazillian.com/how.html How
> can you specify that kind of functionality in a tree grammar?  You'll end
> up with tens of thousands of lines of code embedded within a couple of
> hundred lines of grammar. Moving the code out into another file doesn't
> change much.

Multiple phases.


> I don't want to "walk the tree", I want to "search the tree for patterns
> and make replacements".

That's exactly what a tree walker gives you.

Take care,
	John


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list