[antlr-interest] Re: Translators Should Use Tree Grammars
atripp54321
atripp at comcast.net
Sun Nov 21 13:18:05 PST 2004
> I'm on a coding frenzy on 3.0 so I'll have to comment in detail later,
> but I built an emitter for my CS652 students doing the "Java + C++
> style comments" project. Trivial but a hassle. Took me a few hours
> rather than a day or two. Want it? 559 lines and handles precedence
> properly so that extra parentheses are not generated spuriously (well,
> that was my intent) ;)
Yea, I just checked out the java.print.g tree grammar
in that JParse thing - 423 lines, very straightforward.
I'd like to see your version, too though - seems like
your "Sharing" section is the place for it.
>
> As you point out further in your response to Loring, the tree grammar
> one is sometimes less obvious to the newbie for sure!
>
> I'll counter by saying we shouldn't be printing back this way. ;)
> Templates are the name of the game for generating output :) If the
> output is very similar to the input, a better way is to just do my
> tricks: either TokenStreamRewriteEngine or track token order in the
> tree so you can dump automatically :)
Yea, I suppose a treewalker is fine when the output is so very
close to just a printing of the inorder traversal of the AST.
But I'm still not convinced that a treewalker is the best
for very complex AST-to-AST transformations.
Andy
>
> Back to coding... (see next email message) :)
>
> Ter
> --
> CS Professor & Grad Director, University of San Francisco
> Creator, ANTLR Parser Generator, http://www.antlr.org
> Cofounder, http://www.jguru.com
> Cofounder, http://www.knowspam.net enjoy email again!
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