[antlr-interest] New article on StringTemplates and Treewalkers

Andy Tripp atripp at jazillian.com
Tue Jan 10 14:05:57 PST 2006


> 
>I will add initially, however, that you seem to be  
>sweeping under the rug the one big counterexample of your statement,  
>"one assumption is that the structure of the input and output  
>language ASTs are similar."  I'm pretty sure that ANTLR's input /  
>output languages are vastly more different than your C->Java  
>translation. ;)

Yes, good point! I guess it's not so much an issue of "is the output
language/AST similar to the input one". It's really "can each piece of the output 
language/AST be derived from a single piece of the input language/AST".

Or, "show me a node in the ANTLR input AST, and I will show you the equivalent
node in the Java-version of the ANTLR output AST (probably without thoroughly
examining the whole AST - just looking at the one node".

But..."show me a node in a C AST (let's say INT_NUMBER "0"), and I can't tell
you what the equivalent node is in the output Java AST without a thorough
examination of the AST, both above and below the current node."

So a morse-code-to-English translator is trivial, even though the two ASTs are
completely different. But a Spanish-to-Italian translator is incredibly complex,
even though the ASTs are similar. The difference is really the extent of the
amount of work that needs to be done in examining the input AST. In ANTLR, you
rarely have to look beyond the current AST node. In C-to-Java (at least to the
extent that I've done it), you usually do.

Andy

p.s. I sure hope there's a way to update an article on antlr.org :)



More information about the antlr-interest mailing list