[antlr-interest] New article on StringTemplates and Treewalkers

Terence Parr parrt at cs.usfca.edu
Tue Jan 10 14:41:41 PST 2006


On Jan 10, 2006, at 2:29 PM, Andy Tripp wrote:
> Ter,
> If I understand you right, you've inadvertently proved my point  
> exactly.

Uh oh! ;)

> Your code above (if I read it right) only checks that the function  
> contains at least one "return".
> But it may find a return inside some "if", for example, whereas  
> javac does static flow analysis
> and will see that there exists a path through the function that  
> does not end with a "return".
> I mention this in my article.

Ah.  Sorry.  If you want flow analysis then yes you must right it.   
Then my boolean is a function call checking flow results.  Either I'd  
walk the tree building flow graphs or I'd build another structure and  
walk it.  What does this have to do with grammars and ST though?  You  
must compute it, period, right?  Use a tree, use a flow graph, use  
flat text, up to you.  Once you have a result to spit out (i.e,. "add  
a return statement or not"), you can use ST to say that.  ST has  
nothing to do with that.  The tree walker merely guides general  
output generation...it would reference a previous pass over the input  
that computed the flow analysis.

Ter




More information about the antlr-interest mailing list