[antlr-interest] philosophy about translation

Andy Tripp antlr at jazillian.com
Wed Oct 11 11:42:58 PDT 2006


Paul Johnson wrote: 

>
> I use ANTLR's tree facilities all the time. What I don't do is to use 
> tree *grammars*, and it is the argument against grammars that I have 
> occasionally seen in this list. This specific AST/tree argument, as I 
> understand it (and *not* the translation philosophy argument) is about 
> whether the advantages of having a tree grammar outweigh the 
> disadvantages.

In this thread, I'm just arguing against a tree-walking-based 
architecture for language translation where
the generated code is "natural" - looks hand-written. I haven't seen 
anyone else build a tool with that
as a basic requirement - my Jazillian tool is the only one I've seen. 
Probably everyone else here is
using ANTLR for some other goal, so I'm not really suggesting anyone 
else change what they're doing.

Just trying to justify my design. My guess is that everyone else who's 
tried to build something like
a COBOL-to-Java or C-to-Java tools has ended up giving up on the 
"produce natural code" goal
to preserve the "produce working code" goal (see 
http://ovid.tigris.org/Ephedra/ for example).

>
> The ease of using visitors is not central to that argument. The 
> problem is that tree grammars are (currently?) inflexible, but 
> visitors are both flexible and trivial, so you should use visitors 
> where appropriate.

Right. I expand on my thoughts in this article:
http://antlr.org/article/1136917339929/stringTemplate.html

And I'm more a fan of "just walk the tree by hand" or "use visitors" 
than I am of the whole ANTLR treewalker thing.
But that's a separate discussion, which I cover here:
http://www.jazillian.com/articles/treewalkers.html

Andy

>
> Paul
>



More information about the antlr-interest mailing list