[antlr-interest] philosophy about translation

Andy Tripp antlr at jazillian.com
Sat Oct 28 08:14:30 PDT 2006


Loring Craymer wrote:

>Sheesh.  Can we please stop rehashing late 70's
>technology and get away from ignorance of modern
>rewrite systems?  A friend of mine--Ron Ayres--did one
>of the first such systems for his PhD thesis in the
>late '70's and subsequently used it as a core
>technology for Silicon Compilers and then for MOSIS. 
>Somewhere I have a copy of a paper from the early
>'80's advocating the use of iterative pattern matching
>for rewriting parse trees.  The current easily
>available pattern-matching transformation systems
>(rule-based) include TXL (http://www.txl.ca)and
>stratego
>(http://www.stratego-language.org/Stratego/WebHome). 
>Both are open source; the power and quirks of such
>systems are well documented.
>  
>
I didn't mean to imply that the little term-rewriting thing that I just 
did was
in any way new or innovative. And if my mentioning it makes you think
that I don't know about TXL and stratego, that's your call.

>I can understand why Andy found TXL unsatisfactory: 
>it is a pure interpreter, and that makes it unsuitable
>for producing a packaged product.  
>
That's not why I found TXL unsatisfactory. It's because I didn't see how it
would scale beyond the trivial examples in its documentation. But then 
again,
ANTLR often scales to do things that I didn't realize it could, so maybe 
it's
just me.

>Stratego generates
>C, but it requires doing at least a minimal literature
>search to find and is not so well-known as TXL.
>  
>

IIRC, I had the same problem with stratego as I did with TXL.

My problem with all these tools
(including ASTs in general and ANTLR treewalkers) is that while they
may be capable of a lot of things, they require far too much effort to
learn about all those abilities.

That's why I prefer Swing over VB. I prefer a well-designed library
where I can build something up using code, rather than a all-in-one
tool. Once you get a few basic ideas,
a nicely designed toolkit becomes easy and infinitely powerful. With
VB, you either know how to do what you want, or you don't. And if you
don't, it's tough to find out it can be done (and maybe it can't). I get the
same feeling with ANTLR and these other tools.

>There are innovative possibilities for using rewrite
>systems with ANTLR, and I would certainly be
>interested in hearing of anyone exploring them.  For
>that matter, I would be quite interested in hearing of
>anyone using TXL for working with ANTLR grammars. 
>However, I get tired of being told about the use of
>rule-based systems for simple HLL to HLL translations:
> there are some nice TXL examples of this already.
>  
>
That's fine, but not everyone is interested in just hearing about 
innovative stuff.
Some of us are interested in building real-world solutions to real-world 
problems.
That's nice that TXL exists to help me replace "a+0" with just "a". But 
it's sure
not obvious how it might help me with replacing goto's. In fact, I don't 
see how
it can even help me to know whether "a+0" really is the same as "a" when I
take operator overloading into account.

It's not always about science, sometimes it's about engineering, too.

And it's not about what works in theory, but what works in practice.
If I had taken the "what works in theory" approach, I'd have quickly 
seen that
translating C to Java is impossible in general and given up. Or, I'd 
have seen that
it's already been done (Ephedra) and given up. Instead, I chose to say 
"lots of
people are rewriting C code to Java...let's automate that process and 
save them
huge amounts of time and money".

Andy

>--Loring
>
>
> 
>____________________________________________________________________________________
>Get your email and see which of your friends are online - Right on the New Yahoo.com 
>(http://www.yahoo.com/preview) 
>
>  
>



More information about the antlr-interest mailing list