[antlr-interest] philosophy about translation
Andy Tripp
antlr at jazillian.com
Wed Nov 1 20:26:41 PST 2006
Jim Idle wrote:
>To be honest it is this sort of question (and the answer) that we need to have in the book. The problem is that I would not have thought of this question in a million years (and that is no slight on Andy at all).
>
>
>
I assume you mean here that you would have just gone ahead and plugged
in the "calculate n" code at the appropriate place in your grammar.
It might help to see my perspective if you realize:
* I didn't write the grammar. I use Monty's C grammar, and so I've
avoided learning much about ANTLR.
* I'm now in beta trial on a COBOL-to-Java translator and a C++-to-Java
translator. I bet I wrote the whole
COBOL-to-Java translator in less time than those couple of poor souls
who are trying to create an ANTLR COBOL grammar.
* I'll almost certainly need to "calculate n" at other places in the
tree sooner or later. It makes no sense at all to me to put "calculate
n" code
at one place in the grammar, and then keep having to repeat that. Even
an AST lets me avoid that (with some kind of
getChildCount()).
* If you haven't worked with a grammar the size of the C grammar, you
probably don't have a feel for how awkward embedding
actions is. And the C++ and COBOL (if ever finished) are even larger.
* Nothing makes you really want to avoid learning ANTLR (or anything
else new)
like a large and impossible project with an unreasonable deadline. :)
Andy
More information about the antlr-interest
mailing list