[antlr-interest] Translating from one language to another
Tom Smith
yotommy at gmail.com
Mon Jul 21 13:38:46 PDT 2008
In your case, I'd definitely say "buy the book," because there is a fine
example of a "rewriter," covered in detail over several subsections of
Chapter 9 (Generating Structured Text with Templates and Grammars). There
is one version that rewrites straight from the parser grammar, and another
version using AST generation with a tree walker.
Hope this helps,
Tom.
On Mon, Jul 21, 2008 at 3:54 PM, David Tauzell <dave at tauzell.org> wrote:
> I'd like to translate from language A to java. I've written a grammar that
> parses language A and generates an AST. The language is mostly like java,
> except there are a few cases where I'll need to change the input. For
> example, something like:
>
> a.b.c.d = foo
>
> will be converted to
>
> a.get("b").get("c").get("d").setValue(foo)
>
> Other stuff like:
>
> if( foo == "bar") {
> ...
> }
>
> can stay like it is.
>
> I'm not sure what is the best way to proceed. Should I somehow use
> StringTemplate? Should I walk the AST and generate output? Is this question
> to vague? Do I just need to buy the ANTLR book and learn more about ANTLR?
>
> Thanks,
> Dave
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080721/3572601a/attachment.html
More information about the antlr-interest
mailing list