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

atripp54321 atripp at comcast.net
Tue Nov 23 07:47:07 PST 2004



--- In antlr-interest at yahoogroups.com, Oliver Zeigermann
<oliver.zeigermann at g...> wrote:
> On Mon, 22 Nov 2004 21:16:12 -0000, atripp54321 <atripp at c...> wrote:
> > No, because there's no mixing of code there, it's all ANTLR.
> > And besides, I can (pretty much) use ANTLR without understanding
> > the grammar syntax - just use the .g files that came with it.
> 
> Just for me, as I tend to be a little sluggish: You use the ANTLR
> grammar (for C) and let it generate the AST? Which is something that
> can be done without any idea of ANTLR... Then you access this AST and
> make the translation to Java as explained in your article, right?
> Well, you would at least have to know the structure of the AST, or am
> I getting it all wrong again?

That's exactly right. (Though I do know some ANTLR grammar
syntax, but for the sake of argument, assume I don't).

> 
>  > Right, but the whole point of the tree grammar is to minimize
> > the amount of code that you have to write. What's the point
> > of embedding 30,000 lines of code inside a 350 line grammar,
> > if you could have just written 30,020 lines that do the same
> > thing?
> 
> I thought it might be because of readability and maintenance. Where
> you have a separation of what describes the structure (the AST
> traversal notation) and what is to be done (the Java code).

With treewalkers or not, you're always going to have
the "shape" of the AST buried throughout your code.






 
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