[antlr-interest] AST to AST

Robert Soule robert.soule at gmail.com
Wed Nov 19 18:49:12 PST 2008


Hi,

I have two languages that are fairly similar, and I'd like to translate
from one to the other. For both languages, I have grammars, and
re-write rules that create ASTs. I also have tree grammars that
recognize the ASTs and use StringTemplates to output the original
source.

That is:

Lang1 -> Parser1 -> AST1 -> Template1 -> Lang1
Lang2 -> Parser2 -> AST2 -> Template2 -> Lang2

What I'd like to do is write a tree grammar that recognizes
AST1, and creates an AST2, so that I can use the template2
to output the source:

Lang1 -> Parser1 -> AST1 -> AST2 -> Template2 -> Lang2

As I understand it, antlr dosn't allow me to specify tree
grammars that generate ASTs. Has anyone else tried to do
something like this? If so, can you recommend a way to do
this?

thank you,
Robert


More information about the antlr-interest mailing list