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

Terence Parr parrt at cs.usfca.edu
Sat Nov 20 11:36:33 PST 2004



On Nov 20, 2004, at 10:57 AM, atripp54321 wrote:
> Take my whole JavaEmitter thing. If that's so easy to do
> with a treewalker, why hasn't anyone done it, either in
> the years before I wrote mine or since then? It only
> took me a day or two, can't someone take a day and write a treewalker
> to emit Java code, so we can compare the two?

Hi Andy,

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) ;)

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 :)

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