home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 June / PCWorld_2005-06_cd.bin / software / vyzkuste / firewally / firewally.exe / framework-2.3.exe / ast.py < prev    next >
Text File  |  2003-12-30  |  32KB  |  1,242 lines

  1. """Python abstract syntax node definitions
  2.  
  3. This file is automatically generated.
  4. """
  5. from types import TupleType, ListType
  6. from consts import CO_VARARGS, CO_VARKEYWORDS
  7.  
  8. def flatten(list):
  9.     l = []
  10.     for elt in list:
  11.         t = type(elt)
  12.         if t is TupleType or t is ListType:
  13.             for elt2 in flatten(elt):
  14.                 l.append(elt2)
  15.         else:
  16.             l.append(elt)
  17.     return l
  18.  
  19. def flatten_nodes(list):
  20.     return [n for n in flatten(list) if isinstance(n, Node)]
  21.  
  22. def asList(nodearg):
  23.     l = []
  24.     for item in nodearg:
  25.         if hasattr(item, "asList"):
  26.             l.append(item.asList())
  27.         else:
  28.             t = type(item)
  29.             if t is TupleType or t is ListType:
  30.                 l.append(tuple(asList(item)))
  31.             else:
  32.                 l.append(item)
  33.     return l
  34.  
  35. nodes = {}
  36.  
  37. class Node: # an abstract base class
  38.     lineno = None # provide a lineno for nodes that don't have one
  39.     def getType(self):
  40.         pass # implemented by subclass
  41.     def getChildren(self):
  42.         pass # implemented by subclasses
  43.     def asList(self):
  44.         return tuple(asList(self.getChildren()))
  45.     def getChildNodes(self):
  46.         pass # implemented by subclasses
  47.  
  48. class EmptyNode(Node):
  49.     pass
  50.  
  51. class Slice(Node):
  52.     nodes["slice"] = "Slice"
  53.     def __init__(self, expr, flags, lower, upper):
  54.         self.expr = expr
  55.         self.flags = flags
  56.         self.lower = lower
  57.         self.upper = upper
  58.  
  59.     def getChildren(self):
  60.         children = []
  61.         children.append(self.expr)
  62.         children.append(self.flags)
  63.         children.append(self.lower)
  64.         children.append(self.upper)
  65.         return tuple(children)
  66.  
  67.     def getChildNodes(self):
  68.         nodelist = []
  69.         nodelist.append(self.expr)
  70.         if self.lower is not None:            nodelist.append(self.lower)
  71.         if self.upper is not None:            nodelist.append(self.upper)
  72.         return tuple(nodelist)
  73.  
  74.     def __repr__(self):
  75.         return "Slice(%s, %s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.lower), repr(self.upper))
  76.  
  77. class Const(Node):
  78.     nodes["const"] = "Const"
  79.     def __init__(self, value):
  80.         self.value = value
  81.  
  82.     def getChildren(self):
  83.         return self.value,
  84.  
  85.     def getChildNodes(self):
  86.         return ()
  87.  
  88.     def __repr__(self):
  89.         return "Const(%s)" % (repr(self.value),)
  90.  
  91. class Raise(Node):
  92.     nodes["raise"] = "Raise"
  93.     def __init__(self, expr1, expr2, expr3):
  94.         self.expr1 = expr1
  95.         self.expr2 = expr2
  96.         self.expr3 = expr3
  97.  
  98.     def getChildren(self):
  99.         children = []
  100.         children.append(self.expr1)
  101.         children.append(self.expr2)
  102.         children.append(self.expr3)
  103.         return tuple(children)
  104.  
  105.     def getChildNodes(self):
  106.         nodelist = []
  107.         if self.expr1 is not None:            nodelist.append(self.expr1)
  108.         if self.expr2 is not None:            nodelist.append(self.expr2)
  109.         if self.expr3 is not None:            nodelist.append(self.expr3)
  110.         return tuple(nodelist)
  111.  
  112.     def __repr__(self):
  113.         return "Raise(%s, %s, %s)" % (repr(self.expr1), repr(self.expr2), repr(self.expr3))
  114.  
  115. class For(Node):
  116.     nodes["for"] = "For"
  117.     def __init__(self, assign, list, body, else_):
  118.         self.assign = assign
  119.         self.list = list
  120.         self.body = body
  121.         self.else_ = else_
  122.  
  123.     def getChildren(self):
  124.         children = []
  125.         children.append(self.assign)
  126.         children.append(self.list)
  127.         children.append(self.body)
  128.         children.append(self.else_)
  129.         return tuple(children)
  130.  
  131.     def getChildNodes(self):
  132.         nodelist = []
  133.         nodelist.append(self.assign)
  134.         nodelist.append(self.list)
  135.         nodelist.append(self.body)
  136.         if self.else_ is not None:            nodelist.append(self.else_)
  137.         return tuple(nodelist)
  138.  
  139.     def __repr__(self):
  140.         return "For(%s, %s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.body), repr(self.else_))
  141.  
  142. class AssTuple(Node):
  143.     nodes["asstuple"] = "AssTuple"
  144.     def __init__(self, nodes):
  145.         self.nodes = nodes
  146.  
  147.     def getChildren(self):
  148.         children = []
  149.         children.extend(flatten(self.nodes))
  150.         return tuple(children)
  151.  
  152.     def getChildNodes(self):
  153.         nodelist = []
  154.         nodelist.extend(flatten_nodes(self.nodes))
  155.         return tuple(nodelist)
  156.  
  157.     def __repr__(self):
  158.         return "AssTuple(%s)" % (repr(self.nodes),)
  159.  
  160. class Mul(Node):
  161.     nodes["mul"] = "Mul"
  162.     def __init__(self, (left, right)):
  163.         self.left = left
  164.         self.right = right
  165.  
  166.     def getChildren(self):
  167.         return self.left, self.right
  168.  
  169.     def getChildNodes(self):
  170.         return self.left, self.right
  171.  
  172.     def __repr__(self):
  173.         return "Mul((%s, %s))" % (repr(self.left), repr(self.right))
  174.  
  175. class Invert(Node):
  176.     nodes["invert"] = "Invert"
  177.     def __init__(self, expr):
  178.         self.expr = expr
  179.  
  180.     def getChildren(self):
  181.         return self.expr,
  182.  
  183.     def getChildNodes(self):
  184.         return self.expr,
  185.  
  186.     def __repr__(self):
  187.         return "Invert(%s)" % (repr(self.expr),)
  188.  
  189. class RightShift(Node):
  190.     nodes["rightshift"] = "RightShift"
  191.     def __init__(self, (left, right)):
  192.         self.left = left
  193.         self.right = right
  194.  
  195.     def getChildren(self):
  196.         return self.left, self.right
  197.  
  198.     def getChildNodes(self):
  199.         return self.left, self.right
  200.  
  201.     def __repr__(self):
  202.         return "RightShift((%s, %s))" % (repr(self.left), repr(self.right))
  203.  
  204. class AssList(Node):
  205.     nodes["asslist"] = "AssList"
  206.     def __init__(self, nodes):
  207.         self.nodes = nodes
  208.  
  209.     def getChildren(self):
  210.         children = []
  211.         children.extend(flatten(self.nodes))
  212.         return tuple(children)
  213.  
  214.     def getChildNodes(self):
  215.         nodelist = []
  216.         nodelist.extend(flatten_nodes(self.nodes))
  217.         return tuple(nodelist)
  218.  
  219.     def __repr__(self):
  220.         return "AssList(%s)" % (repr(self.nodes),)
  221.  
  222. class From(Node):
  223.     nodes["from"] = "From"
  224.     def __init__(self, modname, names):
  225.         self.modname = modname
  226.         self.names = names
  227.  
  228.     def getChildren(self):
  229.         return self.modname, self.names
  230.  
  231.     def getChildNodes(self):
  232.         return ()
  233.  
  234.     def __repr__(self):
  235.         return "From(%s, %s)" % (repr(self.modname), repr(self.names))
  236.  
  237. class Getattr(Node):
  238.     nodes["getattr"] = "Getattr"
  239.     def __init__(self, expr, attrname):
  240.         self.expr = expr
  241.         self.attrname = attrname
  242.  
  243.     def getChildren(self):
  244.         return self.expr, self.attrname
  245.  
  246.     def getChildNodes(self):
  247.         return self.expr,
  248.  
  249.     def __repr__(self):
  250.         return "Getattr(%s, %s)" % (repr(self.expr), repr(self.attrname))
  251.  
  252. class Dict(Node):
  253.     nodes["dict"] = "Dict"
  254.     def __init__(self, items):
  255.         self.items = items
  256.  
  257.     def getChildren(self):
  258.         children = []
  259.         children.extend(flatten(self.items))
  260.         return tuple(children)
  261.  
  262.     def getChildNodes(self):
  263.         nodelist = []
  264.         nodelist.extend(flatten_nodes(self.items))
  265.         return tuple(nodelist)
  266.  
  267.     def __repr__(self):
  268.         return "Dict(%s)" % (repr(self.items),)
  269.  
  270. class Module(Node):
  271.     nodes["module"] = "Module"
  272.     def __init__(self, doc, node):
  273.         self.doc = doc
  274.         self.node = node
  275.  
  276.     def getChildren(self):
  277.         return self.doc, self.node
  278.  
  279.     def getChildNodes(self):
  280.         return self.node,
  281.  
  282.     def __repr__(self):
  283.         return "Module(%s, %s)" % (repr(self.doc), repr(self.node))
  284.  
  285. class Expression(Node):
  286.     # Expression is an artifical node class to support "eval"
  287.     nodes["expression"] = "Expression"
  288.     def __init__(self, node):
  289.         self.node = node
  290.  
  291.     def getChildren(self):
  292.         return self.node,
  293.  
  294.     def getChildNodes(self):
  295.         return self.node,
  296.  
  297.     def __repr__(self):
  298.         return "Expression(%s)" % (repr(self.node))
  299.  
  300. class UnaryAdd(Node):
  301.     nodes["unaryadd"] = "UnaryAdd"
  302.     def __init__(self, expr):
  303.         self.expr = expr
  304.  
  305.     def getChildren(self):
  306.         return self.expr,
  307.  
  308.     def getChildNodes(self):
  309.         return self.expr,
  310.  
  311.     def __repr__(self):
  312.         return "UnaryAdd(%s)" % (repr(self.expr),)
  313.  
  314. class Ellipsis(Node):
  315.     nodes["ellipsis"] = "Ellipsis"
  316.     def __init__(self, ):
  317.         pass
  318.  
  319.     def getChildren(self):
  320.         return ()
  321.  
  322.     def getChildNodes(self):
  323.         return ()
  324.  
  325.     def __repr__(self):
  326.         return "Ellipsis()"
  327.  
  328. class Print(Node):
  329.     nodes["print"] = "Print"
  330.     def __init__(self, nodes, dest):
  331.         self.nodes = nodes
  332.         self.dest = dest
  333.  
  334.     def getChildren(self):
  335.         children = []
  336.         children.extend(flatten(self.nodes))
  337.         children.append(self.dest)
  338.         return tuple(children)
  339.  
  340.     def getChildNodes(self):
  341.         nodelist = []
  342.         nodelist.extend(flatten_nodes(self.nodes))
  343.         if self.dest is not None:            nodelist.append(self.dest)
  344.         return tuple(nodelist)
  345.  
  346.     def __repr__(self):
  347.         return "Print(%s, %s)" % (repr(self.nodes), repr(self.dest))
  348.  
  349. class Import(Node):
  350.     nodes["import"] = "Import"
  351.     def __init__(self, names):
  352.         self.names = names
  353.  
  354.     def getChildren(self):
  355.         return self.names,
  356.  
  357.     def getChildNodes(self):
  358.         return ()
  359.  
  360.     def __repr__(self):
  361.         return "Import(%s)" % (repr(self.names),)
  362.  
  363. class Subscript(Node):
  364.     nodes["subscript"] = "Subscript"
  365.     def __init__(self, expr, flags, subs):
  366.         self.expr = expr
  367.         self.flags = flags
  368.         self.subs = subs
  369.  
  370.     def getChildren(self):
  371.         children = []
  372.         children.append(self.expr)
  373.         children.append(self.flags)
  374.         children.extend(flatten(self.subs))
  375.         return tuple(children)
  376.  
  377.     def getChildNodes(self):
  378.         nodelist = []
  379.         nodelist.append(self.expr)
  380.         nodelist.extend(flatten_nodes(self.subs))
  381.         return tuple(nodelist)
  382.  
  383.     def __repr__(self):
  384.         return "Subscript(%s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.subs))
  385.  
  386. class TryExcept(Node):
  387.     nodes["tryexcept"] = "TryExcept"
  388.     def __init__(self, body, handlers, else_):
  389.         self.body = body
  390.         self.handlers = handlers
  391.         self.else_ = else_
  392.  
  393.     def getChildren(self):
  394.         children = []
  395.         children.append(self.body)
  396.         children.extend(flatten(self.handlers))
  397.         children.append(self.else_)
  398.         return tuple(children)
  399.  
  400.     def getChildNodes(self):
  401.         nodelist = []
  402.         nodelist.append(self.body)
  403.         nodelist.extend(flatten_nodes(self.handlers))
  404.         if self.else_ is not None:            nodelist.append(self.else_)
  405.         return tuple(nodelist)
  406.  
  407.     def __repr__(self):
  408.         return "TryExcept(%s, %s, %s)" % (repr(self.body), repr(self.handlers), repr(self.else_))
  409.  
  410. class Or(Node):
  411.     nodes["or"] = "Or"
  412.     def __init__(self, nodes):
  413.         self.nodes = nodes
  414.  
  415.     def getChildren(self):
  416.         children = []
  417.         children.extend(flatten(self.nodes))
  418.         return tuple(children)
  419.  
  420.     def getChildNodes(self):
  421.         nodelist = []
  422.         nodelist.extend(flatten_nodes(self.nodes))
  423.         return tuple(nodelist)
  424.  
  425.     def __repr__(self):
  426.         return "Or(%s)" % (repr(self.nodes),)
  427.  
  428. class Name(Node):
  429.     nodes["name"] = "Name"
  430.     def __init__(self, name):
  431.         self.name = name
  432.  
  433.     def getChildren(self):
  434.         return self.name,
  435.  
  436.     def getChildNodes(self):
  437.         return ()
  438.  
  439.     def __repr__(self):
  440.         return "Name(%s)" % (repr(self.name),)
  441.  
  442. class Function(Node):
  443.     nodes["function"] = "Function"
  444.     def __init__(self, name, argnames, defaults, flags, doc, code):
  445.         self.name = name
  446.         self.argnames = argnames
  447.         self.defaults = defaults
  448.         self.flags = flags
  449.         self.doc = doc
  450.         self.code = code
  451.         self.varargs = self.kwargs = None
  452.         if flags & CO_VARARGS:
  453.             self.varargs = 1
  454.         if flags & CO_VARKEYWORDS:
  455.             self.kwargs = 1
  456.  
  457.  
  458.  
  459.     def getChildren(self):
  460.         children = []
  461.         children.append(self.name)
  462.         children.append(self.argnames)
  463.         children.extend(flatten(self.defaults))
  464.         children.append(self.flags)
  465.         children.append(self.doc)
  466.         children.append(self.code)
  467.         return tuple(children)
  468.  
  469.     def getChildNodes(self):
  470.         nodelist = []
  471.         nodelist.extend(flatten_nodes(self.defaults))
  472.         nodelist.append(self.code)
  473.         return tuple(nodelist)
  474.  
  475.     def __repr__(self):
  476.         return "Function(%s, %s, %s, %s, %s, %s)" % (repr(self.name), repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.doc), repr(self.code))
  477.  
  478. class Assert(Node):
  479.     nodes["assert"] = "Assert"
  480.     def __init__(self, test, fail):
  481.         self.test = test
  482.         self.fail = fail
  483.  
  484.     def getChildren(self):
  485.         children = []
  486.         children.append(self.test)
  487.         children.append(self.fail)
  488.         return tuple(children)
  489.  
  490.     def getChildNodes(self):
  491.         nodelist = []
  492.         nodelist.append(self.test)
  493.         if self.fail is not None:            nodelist.append(self.fail)
  494.         return tuple(nodelist)
  495.  
  496.     def __repr__(self):
  497.         return "Assert(%s, %s)" % (repr(self.test), repr(self.fail))
  498.  
  499. class Return(Node):
  500.     nodes["return"] = "Return"
  501.     def __init__(self, value):
  502.         self.value = value
  503.  
  504.     def getChildren(self):
  505.         return self.value,
  506.  
  507.     def getChildNodes(self):
  508.         return self.value,
  509.  
  510.     def __repr__(self):
  511.         return "Return(%s)" % (repr(self.value),)
  512.  
  513. class Power(Node):
  514.     nodes["power"] = "Power"
  515.     def __init__(self, (left, right)):
  516.         self.left = left
  517.         self.right = right
  518.  
  519.     def getChildren(self):
  520.         return self.left, self.right
  521.  
  522.     def getChildNodes(self):
  523.         return self.left, self.right
  524.  
  525.     def __repr__(self):
  526.         return "Power((%s, %s))" % (repr(self.left), repr(self.right))
  527.  
  528. class Exec(Node):
  529.     nodes["exec"] = "Exec"
  530.     def __init__(self, expr, locals, globals):
  531.         self.expr = expr
  532.         self.locals = locals
  533.         self.globals = globals
  534.  
  535.     def getChildren(self):
  536.         children = []
  537.         children.append(self.expr)
  538.         children.append(self.locals)
  539.         children.append(self.globals)
  540.         return tuple(children)
  541.  
  542.     def getChildNodes(self):
  543.         nodelist = []
  544.         nodelist.append(self.expr)
  545.         if self.locals is not None:            nodelist.append(self.locals)
  546.         if self.globals is not None:            nodelist.append(self.globals)
  547.         return tuple(nodelist)
  548.  
  549.     def __repr__(self):
  550.         return "Exec(%s, %s, %s)" % (repr(self.expr), repr(self.locals), repr(self.globals))
  551.  
  552. class Stmt(Node):
  553.     nodes["stmt"] = "Stmt"
  554.     def __init__(self, nodes):
  555.         self.nodes = nodes
  556.  
  557.     def getChildren(self):
  558.         children = []
  559.         children.extend(flatten(self.nodes))
  560.         return tuple(children)
  561.  
  562.     def getChildNodes(self):
  563.         nodelist = []
  564.         nodelist.extend(flatten_nodes(self.nodes))
  565.         return tuple(nodelist)
  566.  
  567.     def __repr__(self):
  568.         return "Stmt(%s)" % (repr(self.nodes),)
  569.  
  570. class Sliceobj(Node):
  571.     nodes["sliceobj"] = "Sliceobj"
  572.     def __init__(self, nodes):
  573.         self.nodes = nodes
  574.  
  575.     def getChildren(self):
  576.         children = []
  577.         children.extend(flatten(self.nodes))
  578.         return tuple(children)
  579.  
  580.     def getChildNodes(self):
  581.         nodelist = []
  582.         nodelist.extend(flatten_nodes(self.nodes))
  583.         return tuple(nodelist)
  584.  
  585.     def __repr__(self):
  586.         return "Sliceobj(%s)" % (repr(self.nodes),)
  587.  
  588. class Break(Node):
  589.     nodes["break"] = "Break"
  590.     def __init__(self, ):
  591.         pass
  592.  
  593.     def getChildren(self):
  594.         return ()
  595.  
  596.     def getChildNodes(self):
  597.         return ()
  598.  
  599.     def __repr__(self):
  600.         return "Break()"
  601.  
  602. class Bitand(Node):
  603.     nodes["bitand"] = "Bitand"
  604.     def __init__(self, nodes):
  605.         self.nodes = nodes
  606.  
  607.     def getChildren(self):
  608.         children = []
  609.         children.extend(flatten(self.nodes))
  610.         return tuple(children)
  611.  
  612.     def getChildNodes(self):
  613.         nodelist = []
  614.         nodelist.extend(flatten_nodes(self.nodes))
  615.         return tuple(nodelist)
  616.  
  617.     def __repr__(self):
  618.         return "Bitand(%s)" % (repr(self.nodes),)
  619.  
  620. class FloorDiv(Node):
  621.     nodes["floordiv"] = "FloorDiv"
  622.     def __init__(self, (left, right)):
  623.         self.left = left
  624.         self.right = right
  625.  
  626.     def getChildren(self):
  627.         return self.left, self.right
  628.  
  629.     def getChildNodes(self):
  630.         return self.left, self.right
  631.  
  632.     def __repr__(self):
  633.         return "FloorDiv((%s, %s))" % (repr(self.left), repr(self.right))
  634.  
  635. class TryFinally(Node):
  636.     nodes["tryfinally"] = "TryFinally"
  637.     def __init__(self, body, final):
  638.         self.body = body
  639.         self.final = final
  640.  
  641.     def getChildren(self):
  642.         return self.body, self.final
  643.  
  644.     def getChildNodes(self):
  645.         return self.body, self.final
  646.  
  647.     def __repr__(self):
  648.         return "TryFinally(%s, %s)" % (repr(self.body), repr(self.final))
  649.  
  650. class Not(Node):
  651.     nodes["not"] = "Not"
  652.     def __init__(self, expr):
  653.         self.expr = expr
  654.  
  655.     def getChildren(self):
  656.         return self.expr,
  657.  
  658.     def getChildNodes(self):
  659.         return self.expr,
  660.  
  661.     def __repr__(self):
  662.         return "Not(%s)" % (repr(self.expr),)
  663.  
  664. class Class(Node):
  665.     nodes["class"] = "Class"
  666.     def __init__(self, name, bases, doc, code):
  667.         self.name = name
  668.         self.bases = bases
  669.         self.doc = doc
  670.         self.code = code
  671.  
  672.     def getChildren(self):
  673.         children = []
  674.         children.append(self.name)
  675.         children.extend(flatten(self.bases))
  676.         children.append(self.doc)
  677.         children.append(self.code)
  678.         return tuple(children)
  679.  
  680.     def getChildNodes(self):
  681.         nodelist = []
  682.         nodelist.extend(flatten_nodes(self.bases))
  683.         nodelist.append(self.code)
  684.         return tuple(nodelist)
  685.  
  686.     def __repr__(self):
  687.         return "Class(%s, %s, %s, %s)" % (repr(self.name), repr(self.bases), repr(self.doc), repr(self.code))
  688.  
  689. class Mod(Node):
  690.     nodes["mod"] = "Mod"
  691.     def __init__(self, (left, right)):
  692.         self.left = left
  693.         self.right = right
  694.  
  695.     def getChildren(self):
  696.         return self.left, self.right
  697.  
  698.     def getChildNodes(self):
  699.         return self.left, self.right
  700.  
  701.     def __repr__(self):
  702.         return "Mod((%s, %s))" % (repr(self.left), repr(self.right))
  703.  
  704. class Printnl(Node):
  705.     nodes["printnl"] = "Printnl"
  706.     def __init__(self, nodes, dest):
  707.         self.nodes = nodes
  708.         self.dest = dest
  709.  
  710.     def getChildren(self):
  711.         children = []
  712.         children.extend(flatten(self.nodes))
  713.         children.append(self.dest)
  714.         return tuple(children)
  715.  
  716.     def getChildNodes(self):
  717.         nodelist = []
  718.         nodelist.extend(flatten_nodes(self.nodes))
  719.         if self.dest is not None:            nodelist.append(self.dest)
  720.         return tuple(nodelist)
  721.  
  722.     def __repr__(self):
  723.         return "Printnl(%s, %s)" % (repr(self.nodes), repr(self.dest))
  724.  
  725. class Tuple(Node):
  726.     nodes["tuple"] = "Tuple"
  727.     def __init__(self, nodes):
  728.         self.nodes = nodes
  729.  
  730.     def getChildren(self):
  731.         children = []
  732.         children.extend(flatten(self.nodes))
  733.         return tuple(children)
  734.  
  735.     def getChildNodes(self):
  736.         nodelist = []
  737.         nodelist.extend(flatten_nodes(self.nodes))
  738.         return tuple(nodelist)
  739.  
  740.     def __repr__(self):
  741.         return "Tuple(%s)" % (repr(self.nodes),)
  742.  
  743. class AssAttr(Node):
  744.     nodes["assattr"] = "AssAttr"
  745.     def __init__(self, expr, attrname, flags):
  746.         self.expr = expr
  747.         self.attrname = attrname
  748.         self.flags = flags
  749.  
  750.     def getChildren(self):
  751.         return self.expr, self.attrname, self.flags
  752.  
  753.     def getChildNodes(self):
  754.         return self.expr,
  755.  
  756.     def __repr__(self):
  757.         return "AssAttr(%s, %s, %s)" % (repr(self.expr), repr(self.attrname), repr(self.flags))
  758.  
  759. class Keyword(Node):
  760.     nodes["keyword"] = "Keyword"
  761.     def __init__(self, name, expr):
  762.         self.name = name
  763.         self.expr = expr
  764.  
  765.     def getChildren(self):
  766.         return self.name, self.expr
  767.  
  768.     def getChildNodes(self):
  769.         return self.expr,
  770.  
  771.     def __repr__(self):
  772.         return "Keyword(%s, %s)" % (repr(self.name), repr(self.expr))
  773.  
  774. class AugAssign(Node):
  775.     nodes["augassign"] = "AugAssign"
  776.     def __init__(self, node, op, expr):
  777.         self.node = node
  778.         self.op = op
  779.         self.expr = expr
  780.  
  781.     def getChildren(self):
  782.         return self.node, self.op, self.expr
  783.  
  784.     def getChildNodes(self):
  785.         return self.node, self.expr
  786.  
  787.     def __repr__(self):
  788.         return "AugAssign(%s, %s, %s)" % (repr(self.node), repr(self.op), repr(self.expr))
  789.  
  790. class List(Node):
  791.     nodes["list"] = "List"
  792.     def __init__(self, nodes):
  793.         self.nodes = nodes
  794.  
  795.     def getChildren(self):
  796.         children = []
  797.         children.extend(flatten(self.nodes))
  798.         return tuple(children)
  799.  
  800.     def getChildNodes(self):
  801.         nodelist = []
  802.         nodelist.extend(flatten_nodes(self.nodes))
  803.         return tuple(nodelist)
  804.  
  805.     def __repr__(self):
  806.         return "List(%s)" % (repr(self.nodes),)
  807.  
  808. class Yield(Node):
  809.     nodes["yield"] = "Yield"
  810.     def __init__(self, value):
  811.         self.value = value
  812.  
  813.     def getChildren(self):
  814.         return self.value,
  815.  
  816.     def getChildNodes(self):
  817.         return self.value,
  818.  
  819.     def __repr__(self):
  820.         return "Yield(%s)" % (repr(self.value),)
  821.  
  822. class LeftShift(Node):
  823.     nodes["leftshift"] = "LeftShift"
  824.     def __init__(self, (left, right)):
  825.         self.left = left
  826.         self.right = right
  827.  
  828.     def getChildren(self):
  829.         return self.left, self.right
  830.  
  831.     def getChildNodes(self):
  832.         return self.left, self.right
  833.  
  834.     def __repr__(self):
  835.         return "LeftShift((%s, %s))" % (repr(self.left), repr(self.right))
  836.  
  837. class AssName(Node):
  838.     nodes["assname"] = "AssName"
  839.     def __init__(self, name, flags):
  840.         self.name = name
  841.         self.flags = flags
  842.  
  843.     def getChildren(self):
  844.         return self.name, self.flags
  845.  
  846.     def getChildNodes(self):
  847.         return ()
  848.  
  849.     def __repr__(self):
  850.         return "AssName(%s, %s)" % (repr(self.name), repr(self.flags))
  851.  
  852. class While(Node):
  853.     nodes["while"] = "While"
  854.     def __init__(self, test, body, else_):
  855.         self.test = test
  856.         self.body = body
  857.         self.else_ = else_
  858.  
  859.     def getChildren(self):
  860.         children = []
  861.         children.append(self.test)
  862.         children.append(self.body)
  863.         children.append(self.else_)
  864.         return tuple(children)
  865.  
  866.     def getChildNodes(self):
  867.         nodelist = []
  868.         nodelist.append(self.test)
  869.         nodelist.append(self.body)
  870.         if self.else_ is not None:            nodelist.append(self.else_)
  871.         return tuple(nodelist)
  872.  
  873.     def __repr__(self):
  874.         return "While(%s, %s, %s)" % (repr(self.test), repr(self.body), repr(self.else_))
  875.  
  876. class Continue(Node):
  877.     nodes["continue"] = "Continue"
  878.     def __init__(self, ):
  879.         pass
  880.  
  881.     def getChildren(self):
  882.         return ()
  883.  
  884.     def getChildNodes(self):
  885.         return ()
  886.  
  887.     def __repr__(self):
  888.         return "Continue()"
  889.  
  890. class Backquote(Node):
  891.     nodes["backquote"] = "Backquote"
  892.     def __init__(self, expr):
  893.         self.expr = expr
  894.  
  895.     def getChildren(self):
  896.         return self.expr,
  897.  
  898.     def getChildNodes(self):
  899.         return self.expr,
  900.  
  901.     def __repr__(self):
  902.         return "Backquote(%s)" % (repr(self.expr),)
  903.  
  904. class Discard(Node):
  905.     nodes["discard"] = "Discard"
  906.     def __init__(self, expr):
  907.         self.expr = expr
  908.  
  909.     def getChildren(self):
  910.         return self.expr,
  911.  
  912.     def getChildNodes(self):
  913.         return self.expr,
  914.  
  915.     def __repr__(self):
  916.         return "Discard(%s)" % (repr(self.expr),)
  917.  
  918. class Div(Node):
  919.     nodes["div"] = "Div"
  920.     def __init__(self, (left, right)):
  921.         self.left = left
  922.         self.right = right
  923.  
  924.     def getChildren(self):
  925.         return self.left, self.right
  926.  
  927.     def getChildNodes(self):
  928.         return self.left, self.right
  929.  
  930.     def __repr__(self):
  931.         return "Div((%s, %s))" % (repr(self.left), repr(self.right))
  932.  
  933. class Assign(Node):
  934.     nodes["assign"] = "Assign"
  935.     def __init__(self, nodes, expr):
  936.         self.nodes = nodes
  937.         self.expr = expr
  938.  
  939.     def getChildren(self):
  940.         children = []
  941.         children.extend(flatten(self.nodes))
  942.         children.append(self.expr)
  943.         return tuple(children)
  944.  
  945.     def getChildNodes(self):
  946.         nodelist = []
  947.         nodelist.extend(flatten_nodes(self.nodes))
  948.         nodelist.append(self.expr)
  949.         return tuple(nodelist)
  950.  
  951.     def __repr__(self):
  952.         return "Assign(%s, %s)" % (repr(self.nodes), repr(self.expr))
  953.  
  954. class Lambda(Node):
  955.     nodes["lambda"] = "Lambda"
  956.     def __init__(self, argnames, defaults, flags, code):
  957.         self.argnames = argnames
  958.         self.defaults = defaults
  959.         self.flags = flags
  960.         self.code = code
  961.         self.varargs = self.kwargs = None
  962.         if flags & CO_VARARGS:
  963.             self.varargs = 1
  964.         if flags & CO_VARKEYWORDS:
  965.             self.kwargs = 1
  966.  
  967.  
  968.     def getChildren(self):
  969.         children = []
  970.         children.append(self.argnames)
  971.         children.extend(flatten(self.defaults))
  972.         children.append(self.flags)
  973.         children.append(self.code)
  974.         return tuple(children)
  975.  
  976.     def getChildNodes(self):
  977.         nodelist = []
  978.         nodelist.extend(flatten_nodes(self.defaults))
  979.         nodelist.append(self.code)
  980.         return tuple(nodelist)
  981.  
  982.     def __repr__(self):
  983.         return "Lambda(%s, %s, %s, %s)" % (repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.code))
  984.  
  985. class And(Node):
  986.     nodes["and"] = "And"
  987.     def __init__(self, nodes):
  988.         self.nodes = nodes
  989.  
  990.     def getChildren(self):
  991.         children = []
  992.         children.extend(flatten(self.nodes))
  993.         return tuple(children)
  994.  
  995.     def getChildNodes(self):
  996.         nodelist = []
  997.         nodelist.extend(flatten_nodes(self.nodes))
  998.         return tuple(nodelist)
  999.  
  1000.     def __repr__(self):
  1001.         return "And(%s)" % (repr(self.nodes),)
  1002.  
  1003. class Compare(Node):
  1004.     nodes["compare"] = "Compare"
  1005.     def __init__(self, expr, ops):
  1006.         self.expr = expr
  1007.         self.ops = ops
  1008.  
  1009.     def getChildren(self):
  1010.         children = []
  1011.         children.append(self.expr)
  1012.         children.extend(flatten(self.ops))
  1013.         return tuple(children)
  1014.  
  1015.     def getChildNodes(self):
  1016.         nodelist = []
  1017.         nodelist.append(self.expr)
  1018.         nodelist.extend(flatten_nodes(self.ops))
  1019.         return tuple(nodelist)
  1020.  
  1021.     def __repr__(self):
  1022.         return "Compare(%s, %s)" % (repr(self.expr), repr(self.ops))
  1023.  
  1024. class Bitor(Node):
  1025.     nodes["bitor"] = "Bitor"
  1026.     def __init__(self, nodes):
  1027.         self.nodes = nodes
  1028.  
  1029.     def getChildren(self):
  1030.         children = []
  1031.         children.extend(flatten(self.nodes))
  1032.         return tuple(children)
  1033.  
  1034.     def getChildNodes(self):
  1035.         nodelist = []
  1036.         nodelist.extend(flatten_nodes(self.nodes))
  1037.         return tuple(nodelist)
  1038.  
  1039.     def __repr__(self):
  1040.         return "Bitor(%s)" % (repr(self.nodes),)
  1041.  
  1042. class Bitxor(Node):
  1043.     nodes["bitxor"] = "Bitxor"
  1044.     def __init__(self, nodes):
  1045.         self.nodes = nodes
  1046.  
  1047.     def getChildren(self):
  1048.         children = []
  1049.         children.extend(flatten(self.nodes))
  1050.         return tuple(children)
  1051.  
  1052.     def getChildNodes(self):
  1053.         nodelist = []
  1054.         nodelist.extend(flatten_nodes(self.nodes))
  1055.         return tuple(nodelist)
  1056.  
  1057.     def __repr__(self):
  1058.         return "Bitxor(%s)" % (repr(self.nodes),)
  1059.  
  1060. class CallFunc(Node):
  1061.     nodes["callfunc"] = "CallFunc"
  1062.     def __init__(self, node, args, star_args = None, dstar_args = None):
  1063.         self.node = node
  1064.         self.args = args
  1065.         self.star_args = star_args
  1066.         self.dstar_args = dstar_args
  1067.  
  1068.     def getChildren(self):
  1069.         children = []
  1070.         children.append(self.node)
  1071.         children.extend(flatten(self.args))
  1072.         children.append(self.star_args)
  1073.         children.append(self.dstar_args)
  1074.         return tuple(children)
  1075.  
  1076.     def getChildNodes(self):
  1077.         nodelist = []
  1078.         nodelist.append(self.node)
  1079.         nodelist.extend(flatten_nodes(self.args))
  1080.         if self.star_args is not None:            nodelist.append(self.star_args)
  1081.         if self.dstar_args is not None:            nodelist.append(self.dstar_args)
  1082.         return tuple(nodelist)
  1083.  
  1084.     def __repr__(self):
  1085.         return "CallFunc(%s, %s, %s, %s)" % (repr(self.node), repr(self.args), repr(self.star_args), repr(self.dstar_args))
  1086.  
  1087. class Global(Node):
  1088.     nodes["global"] = "Global"
  1089.     def __init__(self, names):
  1090.         self.names = names
  1091.  
  1092.     def getChildren(self):
  1093.         return self.names,
  1094.  
  1095.     def getChildNodes(self):
  1096.         return ()
  1097.  
  1098.     def __repr__(self):
  1099.         return "Global(%s)" % (repr(self.names),)
  1100.  
  1101. class Add(Node):
  1102.     nodes["add"] = "Add"
  1103.     def __init__(self, (left, right)):
  1104.         self.left = left
  1105.         self.right = right
  1106.  
  1107.     def getChildren(self):
  1108.         return self.left, self.right
  1109.  
  1110.     def getChildNodes(self):
  1111.         return self.left, self.right
  1112.  
  1113.     def __repr__(self):
  1114.         return "Add((%s, %s))" % (repr(self.left), repr(self.right))
  1115.  
  1116. class ListCompIf(Node):
  1117.     nodes["listcompif"] = "ListCompIf"
  1118.     def __init__(self, test):
  1119.         self.test = test
  1120.  
  1121.     def getChildren(self):
  1122.         return self.test,
  1123.  
  1124.     def getChildNodes(self):
  1125.         return self.test,
  1126.  
  1127.     def __repr__(self):
  1128.         return "ListCompIf(%s)" % (repr(self.test),)
  1129.  
  1130. class Sub(Node):
  1131.     nodes["sub"] = "Sub"
  1132.     def __init__(self, (left, right)):
  1133.         self.left = left
  1134.         self.right = right
  1135.  
  1136.     def getChildren(self):
  1137.         return self.left, self.right
  1138.  
  1139.     def getChildNodes(self):
  1140.         return self.left, self.right
  1141.  
  1142.     def __repr__(self):
  1143.         return "Sub((%s, %s))" % (repr(self.left), repr(self.right))
  1144.  
  1145. class Pass(Node):
  1146.     nodes["pass"] = "Pass"
  1147.     def __init__(self, ):
  1148.         pass
  1149.  
  1150.     def getChildren(self):
  1151.         return ()
  1152.  
  1153.     def getChildNodes(self):
  1154.         return ()
  1155.  
  1156.     def __repr__(self):
  1157.         return "Pass()"
  1158.  
  1159. class UnarySub(Node):
  1160.     nodes["unarysub"] = "UnarySub"
  1161.     def __init__(self, expr):
  1162.         self.expr = expr
  1163.  
  1164.     def getChildren(self):
  1165.         return self.expr,
  1166.  
  1167.     def getChildNodes(self):
  1168.         return self.expr,
  1169.  
  1170.     def __repr__(self):
  1171.         return "UnarySub(%s)" % (repr(self.expr),)
  1172.  
  1173. class If(Node):
  1174.     nodes["if"] = "If"
  1175.     def __init__(self, tests, else_):
  1176.         self.tests = tests
  1177.         self.else_ = else_
  1178.  
  1179.     def getChildren(self):
  1180.         children = []
  1181.         children.extend(flatten(self.tests))
  1182.         children.append(self.else_)
  1183.         return tuple(children)
  1184.  
  1185.     def getChildNodes(self):
  1186.         nodelist = []
  1187.         nodelist.extend(flatten_nodes(self.tests))
  1188.         if self.else_ is not None:            nodelist.append(self.else_)
  1189.         return tuple(nodelist)
  1190.  
  1191.     def __repr__(self):
  1192.         return "If(%s, %s)" % (repr(self.tests), repr(self.else_))
  1193.  
  1194. class ListComp(Node):
  1195.     nodes["listcomp"] = "ListComp"
  1196.     def __init__(self, expr, quals):
  1197.         self.expr = expr
  1198.         self.quals = quals
  1199.  
  1200.     def getChildren(self):
  1201.         children = []
  1202.         children.append(self.expr)
  1203.         children.extend(flatten(self.quals))
  1204.         return tuple(children)
  1205.  
  1206.     def getChildNodes(self):
  1207.         nodelist = []
  1208.         nodelist.append(self.expr)
  1209.         nodelist.extend(flatten_nodes(self.quals))
  1210.         return tuple(nodelist)
  1211.  
  1212.     def __repr__(self):
  1213.         return "ListComp(%s, %s)" % (repr(self.expr), repr(self.quals))
  1214.  
  1215. class ListCompFor(Node):
  1216.     nodes["listcompfor"] = "ListCompFor"
  1217.     def __init__(self, assign, list, ifs):
  1218.         self.assign = assign
  1219.         self.list = list
  1220.         self.ifs = ifs
  1221.  
  1222.     def getChildren(self):
  1223.         children = []
  1224.         children.append(self.assign)
  1225.         children.append(self.list)
  1226.         children.extend(flatten(self.ifs))
  1227.         return tuple(children)
  1228.  
  1229.     def getChildNodes(self):
  1230.         nodelist = []
  1231.         nodelist.append(self.assign)
  1232.         nodelist.append(self.list)
  1233.         nodelist.extend(flatten_nodes(self.ifs))
  1234.         return tuple(nodelist)
  1235.  
  1236.     def __repr__(self):
  1237.         return "ListCompFor(%s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.ifs))
  1238.  
  1239. klasses = globals()
  1240. for k in nodes.keys():
  1241.     nodes[k] = klasses[nodes[k]]
  1242.