[antlr-interest] AST Generation - Order of Children

Liehann Loots liehannl at gmail.com
Thu Jul 3 11:46:47 PDT 2008


Hi,

I have three rules that look something like this:

expr : IDENT (deref^ | invoke^)*;
deref : (PERIOD)! IDENT -> ^(DEREF IDENT);
invoke : (PERIOD)! IDENT (LEFT_BRKT)! (RIGHT_BRKT)! -> ^(INVOKE IDENT);

That produce an AST like this:

INVOKE
|    |
c   DEREF
    |   |
    b   a

What I want to get is a tree like this:

   INVOKE
   |    |
DEREF   c
|   |
a   b

But I'm not sure how to specify a rewrite rule to make the current tree the
first child of the new parent, opposed to appending it to the end.
Any assistance would be appreciated.

Regards,
Liehann
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080703/88081965/attachment.html 


More information about the antlr-interest mailing list