[antlr-interest] multiple pass translator

Don Boogert don.boogert at gmail.com
Fri Apr 27 00:24:55 PDT 2012


Hi,

I have a toy language translator which uses ANTLR, C runtime and LLVM to
execute simple programs.  It uses combined grammar and a tree grammar (
https://bitbucket.org/dmb/egg/src/2c5b5d10322c/src/grammar) which contains
the C++ calls to LLVM. I'd like to be able to add multiple passes to my
translator.

My options :

1) Define additional tree grammars for the new passes
2) Walk the AST tree in code.
3) Add a switch to my existing tree grammar to alter the output based on
pass

I'm leaning towards option (1)  but it seems a lot of information needs to
be duplicated between the tree grammars for the various passes. Is there
any recommendations of how I should do this with ANTLR & C runtime?

Thanks for the help

- Don


More information about the antlr-interest mailing list