[antlr-interest] tricky (to this newby) translation problem

Terence Parr parrt at cs.usfca.edu
Fri Dec 30 11:40:07 PST 2005


On Dec 30, 2005, at 11:36 AM, Sohail Somani wrote:

> On Fri, 2005-12-30 at 10:14 -0800, Terence Parr wrote:
>>
>> Hi.  First let me suggest using StringTemplate in combination with
>> ANTLR:
>>
>> http://www.codegeneration.net/tiki-read_article.php?articleId=77
>>
>
> This is a good example. I wonder if we should write one that does a
> TreeParser too. imho, thats the best route to take with  
> StringTemplate.
> What do you think?

Yes, a great idea.  I've done that myself to good effect.  You'll  
note that ANTLR v3 has a first parser phase to get an AST and then 3  
tree passes to build NFAs, etc... plus a final tree pass, codegen.g,  
that spews out templates to generate code.  My new "best practices"  
philosophy for difficult/complex translations then is parsing to  
trees with multiple tree passes and a final ST construction pass.

Ter


More information about the antlr-interest mailing list