-í
ëĥ<c       sm      d  k  l Z  d f  d     YZ I d e f d     YZ l e Z m e e d  Z u d   Z d S(   (   s   asts
   ASTVisitorc      sM    t  Z d  Z & ( d Z * d   Z . d   Z 2 d   Z C d   Z RS(   sÊ  Performs a depth-first walk of the AST

    The ASTVisitor will walk the AST, performing either a preorder or
    postorder traversal depending on which method is called.

    methods:
    preorder(tree, visitor)
    postorder(tree, visitor)
        tree: an instance of ast.Node
        visitor: an instance with visitXXX methods

    The ASTVisitor is responsible for walking over the tree in the
    correct order.  For each node, it checks the visitor argument for
    a method named 'visitNodeType' where NodeType is the name of the
    node's class, e.g. Class.  If the method exists, it is called
    with the node as its sole argument.

    The visitor method for a particular node type can control how
    child nodes are visited during a preorder walk.  (It can't control
    the order during a postorder walk, because it is called _after_
    the walk has occurred.)  The ASTVisitor modifies the visitor
    argument by adding a visit method to the visitor; this method can
    be used to visit a particular child node.  If the visitor method
    returns a true value, the ASTVisitor will not traverse the child
    nodes.

    XXX The interface for controlling the preorder walk needs to be
    re-considered.  The current interface is convenient for visitors
    that mostly let the ASTVisitor do everything.  For something like
    a code generator, where you want to walk to occur in a specific
    order, it's a pain to add "return 1" to the end of each method.
    i    c    s   * + t  |  _ , h  |  _ d  S(   N(   s   Nones   selfs   nodes   _cache(   s   self(    (    s&   /usr/lib/python2.2/compiler/visitor.pys   __init__* s   c    s7   . / x* | i   D/ ] } 0 |  i | |  q Wd  S(   N(   s   nodes   getChildNodess   childs   selfs   dispatchs   args(   s   selfs   nodes   argss   child(    (    s&   /usr/lib/python2.2/compiler/visitor.pys   default. s    	c    s   2 3 | |  _  4 | i } 5 |  i i | t  } 6 | t j o? 7 | i } 8 t
 |  i d | |  i  } 9 | |  i | <n A | | |  Sd  S(   Ns   visit(   s   nodes   selfs	   __class__s   klasss   _caches   gets   Nones   meths   __name__s	   classNames   getattrs   visitors   defaults   args(   s   selfs   nodes   argss	   classNames   klasss   meth(    (    s&   /usr/lib/python2.2/compiler/visitor.pys   dispatch2 s   c    s8   C D E | |  _  F |  i | _ G |  i | |  d S(   s&   Do preorder walk of tree using visitorN(   s   visitors   selfs   dispatchs   visits   trees   args(   s   selfs   trees   visitors   args(    (    s&   /usr/lib/python2.2/compiler/visitor.pys   preorderC s   (   s   __name__s
   __module__s   __doc__s   VERBOSEs   __init__s   defaults   dispatchs   preorder(    (    (    s&   /usr/lib/python2.2/compiler/visitor.pys
   ASTVisitor s    	s   ExampleASTVisitorc      s)   I t  Z d  Z O P h  Z R d   Z RS(   sÙ   Prints examples of the nodes that aren't visited

    This visitor-driver is only useful for development, when it's
    helpful to develop a visitor incremently, and get feedback on what
    you still have to do.
    c    s¤  R S | |  _  T |  i i | i t  } U | i i } V | t j o3 W t	 |  i
 d | d  } X | |  i | i <n Y |  i d j o% Z d G| G| o | i p d GHn [ | o \ | | |  nÏ ] |  i d j oğ ^ | i } _ |  i i |  o ` | |  i | <a Hb |  i
 GHc | GHd xL t |  Dd ]; } e | d d j o! f d Gd | Gt	 | |  GHn q?Wg Hn h |  i | |  Sn d  S(	   Ns   visiti    i   s   dispatchs    s   _s   	s   %-12.12s(   s   nodes   selfs   _caches   gets	   __class__s   Nones   meths   __name__s	   classNames   getattrs   visitors   VERBOSEs   argss   klasss   exampless   has_keys   dirs   attrs   default(   s   selfs   nodes   argss	   classNames   klasss   meths   attr(    (    s&   /usr/lib/python2.2/compiler/visitor.pys   dispatchR s.   %
 	%(   s   __name__s
   __module__s   __doc__s   exampless   dispatch(    (    (    s&   /usr/lib/python2.2/compiler/visitor.pys   ExampleASTVisitorI s   	c    sd   m n | t j o o t   } n p | t j	 o q | | _ n r | i |  |  s | i Sd  S(   N(   s   walkers   Nones   _walkers   verboses   VERBOSEs   preorders   trees   visitor(   s   trees   visitors   walkers   verbose(    (    s&   /usr/lib/python2.2/compiler/visitor.pys   walkm s   c    sd   u v |  i GHw xL t |   Dw ]; } x | d d j o! y d Gd | Gt |  |  GHn q Wd  S(   Ni    s   _s   	s   %-10.10s(   s   nodes	   __class__s   dirs   attrs   getattr(   s   nodes   attr(    (    s&   /usr/lib/python2.2/compiler/visitor.pys   dumpNodeu s
    	N(   s   compilers   asts
   ASTVisitors   ExampleASTVisitors   _walkers   Nones   walks   dumpNode(   s   _walkers   asts
   ASTVisitors   ExampleASTVisitors   dumpNodes   walk(    (    s&   /usr/lib/python2.2/compiler/visitor.pys   ? s
   C#	