On Tue, Sep 27, 2011 at 2:18 PM, David Beazley <[email protected]> wrote:
> I think you just do a depth-first traversal of the parse tree.   For example 
> something sort of like this (shown for a node representing a binary operator):
>
> class BinaryOperator(object):
>      def __init__(self, operator, left, right):
>              self.operator = operator
>              self.left = left
>              self.right  = right
>      def collapse(self):
>              return self.left.collapse() + self.operator + 
> self.right.collapse()
>
> Note:  You'll need to careful about too much recursion depending on the depth 
> of your parse tree.

Thanks, that's useful

Cheers
Tarek
-- 
Tarek Ziadé | http://ziade.org

-- 
You received this message because you are subscribed to the Google Groups 
"ply-hack" 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/ply-hack?hl=en.

Reply via email to