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

Anthony Youngman Anthony.Youngman at ECA-International.com
Tue Nov 23 03:38:52 PST 2004


Let's see your pattern match cope with the following line of (*real*)
code from a (*real*) language ...

REM: REM = REM( 85, 17) ;* REM calculate the remainder

Where REM is sequentially a label, a variable, a function, and a
statement. I think that pretty much this statement is in the compiler's
regression tests to make sure it works properly :-)

Cheers,
Wol

-----Original Message-----
From: John D. Mitchell [mailto:johnm-antlr at non.net] 
Sent: 22 November 2004 06:45
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Re: Translators Should Use Tree Grammars


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


> 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



 





****************************************************************************

This transmission is intended for the named recipient only. It may contain private and confidential information. If this has come to you in error you must not act on anything disclosed in it, nor must you copy it, modify it, disseminate it in any way, or show it to anyone. Please e-mail the sender to inform us of the transmission error or telephone ECA International immediately and delete the e-mail from your information system.

Telephone numbers for ECA International offices are: Sydney +61 (0)2 8272 5300, Hong Kong + 852 2121 2388, London +44 (0)20 7351 5000 and New York +1 212 582 2333.

****************************************************************************



 
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