I need to "wrap" a collection of statements as a code body in order 
to mechanize if, for and while loops.  In my tree generator, this 
works great as:

prog:   body EOF! {if($body.tree!=null)
                        System.out.println($body.tree.toStringTree());}
         ;

body    : parts -> ^(BODY parts)
         ;

parts:
         ( (stat
         | ifStat)  )*
         ;

This produces, for example, [I inserted some newlines to make it legible]
(BODY (= a 3)
       (= b 4)
       (if (> a b) (BODY (= a (+ b 1)))
        elseif (< a b) (BODY (= b (- a b)) (= c 42) (= d 4))
        else (BODY (= b 4) (= c (- a b)))
        end)
)
I intend the Java code that implements 'if' to receive the "children" 
bodies as sub-trees and invoke the original tree walker on the 
appropriate tree. However, I have no idea how the tree walker should 
parse ^(BODY parts) to execute each statement in that body.
Any ideas?

                                 DMS

David M. Smith http://www.cc.gatech.edu/fac/David.Smith
Georgia Institute of Technology, College of Computing
Sent from my ASR-33 Teletype 


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to