[antlr-interest] AST to AST

Terence Parr parrt at cs.usfca.edu
Wed Nov 19 19:28:06 PST 2008


On Nov 19, 2008, at 6:49 PM, Robert Soule wrote:

> 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.

As of 3.1 it does. :)

Ter


More information about the antlr-interest mailing list