[antlr-interest] source to source transformations
Gavin Lambert
antlr at mirality.co.nz
Wed Mar 11 12:03:11 PDT 2009
At 06:10 12/03/2009, Robert Soule wrote:
>What I think the right translation approach is to build a B
>language AST by hand. So, when I start the translation, I
>create a B language stub AST (maybe a program node, with
>null a section and b section children). I then would want
>to hold pointers to both those null childen, and when I
>encounter an 'a' or 'b; statement, I add it as a child to
>the appropriate parent node.
You should be able to do this using scopes to hold either the root
or the most-recently-added child of each set (I forget which one
the tree api needs). Or, for that matter, member
variables. Basically just call the tree-construction routines "by
hand" as needed.
More information about the antlr-interest
mailing list