[antlr-interest] AST Transformation advice

cristiano at defaveri.com.br cristiano at defaveri.com.br
Fri Jun 29 11:20:01 PDT 2012


Hi All, 

I'm working on a AST transformation from a DSL to
JPAQL-like and before going deeper on the code I'd like to some advice
about the best approach using antlr3.x. 

My approach has being : 

Parse the DSL and build the AST, 

b) Walk AST and transform source
AST(a) to JPAQL-like AST(b) and 

c) Walk JPAQL-like AST and generate
target code (using StringTemplate) 

Since the target AST(b) is not very
similar to the source one(a) and needs some external mapping translation
also, my doubt is how much ANTLR 3.x can help me on this transformation
using rewriting rules. My current code is inserting actions in the rules
to populate a semantic model and transform the AST by hand (insert,
remove, moving nodes) - tough work. However, I'm not very very very
confortable with this code and I'd like some advice whether this is the
better approach I can reach now or I could make more successive
transformations using some ANTLR feature itself.  

Thank you in

Best regards, 



More information about the antlr-interest mailing list