2000-10-25 15:02:59 -03:00
|
|
|
"""Python abstract syntax node definitions
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-09-07 12:28:01 -03:00
|
|
|
This file is automatically generated by Tools/compiler/astgen.py
|
2000-10-25 15:02:59 -03:00
|
|
|
"""
|
2006-04-03 01:45:34 -03:00
|
|
|
from compiler.consts import CO_VARARGS, CO_VARKEYWORDS
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2005-06-02 02:55:20 -03:00
|
|
|
def flatten(seq):
|
2000-10-25 15:02:59 -03:00
|
|
|
l = []
|
2005-06-02 02:55:20 -03:00
|
|
|
for elt in seq:
|
2000-10-25 15:02:59 -03:00
|
|
|
t = type(elt)
|
2004-09-07 12:28:01 -03:00
|
|
|
if t is tuple or t is list:
|
2000-10-25 15:02:59 -03:00
|
|
|
for elt2 in flatten(elt):
|
|
|
|
l.append(elt2)
|
|
|
|
else:
|
|
|
|
l.append(elt)
|
|
|
|
return l
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2005-06-02 02:55:20 -03:00
|
|
|
def flatten_nodes(seq):
|
|
|
|
return [n for n in flatten(seq) if isinstance(n, Node)]
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
nodes = {}
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-09-07 12:28:01 -03:00
|
|
|
class Node:
|
|
|
|
"""Abstract base class for ast nodes."""
|
2000-10-25 15:02:59 -03:00
|
|
|
def getChildren(self):
|
2001-08-29 15:08:02 -03:00
|
|
|
pass # implemented by subclasses
|
2004-09-07 12:28:01 -03:00
|
|
|
def __iter__(self):
|
|
|
|
for n in self.getChildren():
|
|
|
|
yield n
|
|
|
|
def asList(self): # for backwards compatibility
|
|
|
|
return self.getChildren()
|
2001-08-14 15:59:01 -03:00
|
|
|
def getChildNodes(self):
|
2001-08-29 15:08:02 -03:00
|
|
|
pass # implemented by subclasses
|
2000-02-03 20:25:23 -04:00
|
|
|
|
|
|
|
class EmptyNode(Node):
|
2001-08-29 15:08:02 -03:00
|
|
|
pass
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Expression(Node):
|
|
|
|
# Expression is an artificial node class to support "eval"
|
|
|
|
nodes["expression"] = "Expression"
|
|
|
|
def __init__(self, node):
|
|
|
|
self.node = node
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.node,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.node,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Expression(%s)" % (repr(self.node))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Add(Node):
|
2010-08-01 21:24:26 -03:00
|
|
|
def __init__(self, leftright, lineno=None):
|
|
|
|
self.left = leftright[0]
|
|
|
|
self.right = leftright[1]
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-09-17 17:17:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.left, self.right
|
2001-09-17 17:17:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.left, self.right
|
2001-09-17 17:17:02 -03:00
|
|
|
|
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Add((%s, %s))" % (repr(self.left), repr(self.right))
|
2001-09-17 17:17:02 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class And(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.nodes = nodes
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-09-07 12:28:01 -03:00
|
|
|
return tuple(flatten(self.nodes))
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "And(%s)" % (repr(self.nodes),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class AssAttr(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, attrname, flags, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.expr = expr
|
|
|
|
self.attrname = attrname
|
|
|
|
self.flags = flags
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.expr, self.attrname, self.flags
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.expr,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "AssAttr(%s, %s, %s)" % (repr(self.expr), repr(self.attrname), repr(self.flags))
|
2000-10-25 15:02:59 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class AssList(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, lineno=None):
|
2001-09-17 17:17:02 -03:00
|
|
|
self.nodes = nodes
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-09-07 12:28:01 -03:00
|
|
|
return tuple(flatten(self.nodes))
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "AssList(%s)" % (repr(self.nodes),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class AssName(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, name, flags, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.name = name
|
|
|
|
self.flags = flags
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.name, self.flags
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return ()
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "AssName(%s, %s)" % (repr(self.name), repr(self.flags))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class AssTuple(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.nodes = nodes
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-09-07 12:28:01 -03:00
|
|
|
return tuple(flatten(self.nodes))
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist = []
|
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "AssTuple(%s)" % (repr(self.nodes),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Assert(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, test, fail, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.test = test
|
|
|
|
self.fail = fail
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
children = []
|
|
|
|
children.append(self.test)
|
|
|
|
children.append(self.fail)
|
|
|
|
return tuple(children)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist = []
|
|
|
|
nodelist.append(self.test)
|
2004-09-07 12:28:01 -03:00
|
|
|
if self.fail is not None:
|
|
|
|
nodelist.append(self.fail)
|
2004-08-02 03:10:11 -03:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Assert(%s, %s)" % (repr(self.test), repr(self.fail))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Assign(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, expr, lineno=None):
|
2000-10-25 15:02:59 -03:00
|
|
|
self.nodes = nodes
|
2004-08-02 03:10:11 -03:00
|
|
|
self.expr = expr
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
children = []
|
|
|
|
children.extend(flatten(self.nodes))
|
2004-08-02 03:10:11 -03:00
|
|
|
children.append(self.expr)
|
2001-08-29 15:08:02 -03:00
|
|
|
return tuple(children)
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.append(self.expr)
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Assign(%s, %s)" % (repr(self.nodes), repr(self.expr))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class AugAssign(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, node, op, expr, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.node = node
|
|
|
|
self.op = op
|
|
|
|
self.expr = expr
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.node, self.op, self.expr
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.node, self.expr
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "AugAssign(%s, %s, %s)" % (repr(self.node), repr(self.op), repr(self.expr))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Backquote(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, lineno=None):
|
2000-10-25 15:02:59 -03:00
|
|
|
self.expr = expr
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.expr,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
return self.expr,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Backquote(%s)" % (repr(self.expr),)
|
2000-10-13 18:58:13 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Bitand(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.nodes = nodes
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-09-07 12:28:01 -03:00
|
|
|
return tuple(flatten(self.nodes))
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Bitand(%s)" % (repr(self.nodes),)
|
2000-10-25 15:02:59 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Bitor(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.nodes = nodes
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-09-07 12:28:01 -03:00
|
|
|
return tuple(flatten(self.nodes))
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist = []
|
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Bitor(%s)" % (repr(self.nodes),)
|
2000-10-13 18:58:13 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Bitxor(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.nodes = nodes
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-12-21 16:04:22 -04:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-09-07 12:28:01 -03:00
|
|
|
return tuple(flatten(self.nodes))
|
2001-12-21 16:04:22 -04:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist = []
|
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
|
|
|
return tuple(nodelist)
|
2001-12-21 16:04:22 -04:00
|
|
|
|
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Bitxor(%s)" % (repr(self.nodes),)
|
2001-12-21 16:04:22 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Break(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, lineno=None):
|
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return ()
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return ()
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Break()"
|
2000-10-13 18:58:13 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class CallFunc(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, node, args, star_args = None, dstar_args = None, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.node = node
|
|
|
|
self.args = args
|
|
|
|
self.star_args = star_args
|
|
|
|
self.dstar_args = dstar_args
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
children = []
|
2004-08-02 03:10:11 -03:00
|
|
|
children.append(self.node)
|
|
|
|
children.extend(flatten(self.args))
|
|
|
|
children.append(self.star_args)
|
|
|
|
children.append(self.dstar_args)
|
2001-09-17 17:17:02 -03:00
|
|
|
return tuple(children)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.append(self.node)
|
|
|
|
nodelist.extend(flatten_nodes(self.args))
|
2004-09-07 12:28:01 -03:00
|
|
|
if self.star_args is not None:
|
|
|
|
nodelist.append(self.star_args)
|
|
|
|
if self.dstar_args is not None:
|
|
|
|
nodelist.append(self.dstar_args)
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "CallFunc(%s, %s, %s, %s)" % (repr(self.node), repr(self.args), repr(self.star_args), repr(self.dstar_args))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Class(Node):
|
2008-02-25 14:06:00 -04:00
|
|
|
def __init__(self, name, bases, doc, code, decorators = None, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.name = name
|
|
|
|
self.bases = bases
|
|
|
|
self.doc = doc
|
|
|
|
self.code = code
|
2008-02-25 14:06:00 -04:00
|
|
|
self.decorators = decorators
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
children = []
|
2004-08-02 03:10:11 -03:00
|
|
|
children.append(self.name)
|
|
|
|
children.extend(flatten(self.bases))
|
|
|
|
children.append(self.doc)
|
|
|
|
children.append(self.code)
|
2008-02-25 14:06:00 -04:00
|
|
|
children.append(self.decorators)
|
2001-09-17 17:17:02 -03:00
|
|
|
return tuple(children)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.extend(flatten_nodes(self.bases))
|
|
|
|
nodelist.append(self.code)
|
2008-02-25 14:06:00 -04:00
|
|
|
if self.decorators is not None:
|
|
|
|
nodelist.append(self.decorators)
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2008-02-25 14:06:00 -04:00
|
|
|
return "Class(%s, %s, %s, %s, %s)" % (repr(self.name), repr(self.bases), repr(self.doc), repr(self.code), repr(self.decorators))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Compare(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, ops, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.expr = expr
|
|
|
|
self.ops = ops
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
children = []
|
2004-08-02 03:10:11 -03:00
|
|
|
children.append(self.expr)
|
|
|
|
children.extend(flatten(self.ops))
|
2001-09-17 17:17:02 -03:00
|
|
|
return tuple(children)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.append(self.expr)
|
|
|
|
nodelist.extend(flatten_nodes(self.ops))
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Compare(%s, %s)" % (repr(self.expr), repr(self.ops))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Const(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, value, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.value = value
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.value,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return ()
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Const(%s)" % (repr(self.value),)
|
2001-09-17 17:17:02 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Continue(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, lineno=None):
|
|
|
|
self.lineno = lineno
|
2001-09-17 17:17:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return ()
|
2001-09-17 17:17:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
return ()
|
|
|
|
|
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Continue()"
|
2000-10-25 15:02:59 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Decorators(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.nodes = nodes
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return tuple(flatten(self.nodes))
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-09-07 12:28:01 -03:00
|
|
|
nodelist = []
|
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Decorators(%s)" % (repr(self.nodes),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Dict(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, items, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.items = items
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-09-07 12:28:01 -03:00
|
|
|
return tuple(flatten(self.items))
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.extend(flatten_nodes(self.items))
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Dict(%s)" % (repr(self.items),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Discard(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.expr = expr
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.expr,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.expr,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Discard(%s)" % (repr(self.expr),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Div(Node):
|
2010-08-01 21:24:26 -03:00
|
|
|
def __init__(self, leftright, lineno=None):
|
|
|
|
self.left = leftright[0]
|
|
|
|
self.right = leftright[1]
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
return self.left, self.right
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
2000-10-25 15:02:59 -03:00
|
|
|
return self.left, self.right
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Div((%s, %s))" % (repr(self.left), repr(self.right))
|
|
|
|
|
|
|
|
class Ellipsis(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, lineno=None):
|
|
|
|
self.lineno = lineno
|
2004-08-02 03:10:11 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
return ()
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
return ()
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return "Ellipsis()"
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2001-09-17 17:17:02 -03:00
|
|
|
class Exec(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, locals, globals, lineno=None):
|
2001-09-17 17:17:02 -03:00
|
|
|
self.expr = expr
|
|
|
|
self.locals = locals
|
|
|
|
self.globals = globals
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
children = []
|
|
|
|
children.append(self.expr)
|
|
|
|
children.append(self.locals)
|
|
|
|
children.append(self.globals)
|
|
|
|
return tuple(children)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
|
|
|
nodelist.append(self.expr)
|
2004-09-07 12:28:01 -03:00
|
|
|
if self.locals is not None:
|
|
|
|
nodelist.append(self.locals)
|
|
|
|
if self.globals is not None:
|
|
|
|
nodelist.append(self.globals)
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2001-08-14 15:59:01 -03:00
|
|
|
def __repr__(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
return "Exec(%s, %s, %s)" % (repr(self.expr), repr(self.locals), repr(self.globals))
|
2001-08-14 15:59:01 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class FloorDiv(Node):
|
2010-08-01 21:24:26 -03:00
|
|
|
def __init__(self, leftright, lineno=None):
|
|
|
|
self.left = leftright[0]
|
|
|
|
self.right = leftright[1]
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.left, self.right
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.left, self.right
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "FloorDiv((%s, %s))" % (repr(self.left), repr(self.right))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class For(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, assign, list, body, else_, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.assign = assign
|
|
|
|
self.list = list
|
|
|
|
self.body = body
|
|
|
|
self.else_ = else_
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
children = []
|
2004-08-02 03:10:11 -03:00
|
|
|
children.append(self.assign)
|
|
|
|
children.append(self.list)
|
|
|
|
children.append(self.body)
|
|
|
|
children.append(self.else_)
|
2001-08-29 15:08:02 -03:00
|
|
|
return tuple(children)
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.append(self.assign)
|
|
|
|
nodelist.append(self.list)
|
|
|
|
nodelist.append(self.body)
|
2004-09-07 12:28:01 -03:00
|
|
|
if self.else_ is not None:
|
|
|
|
nodelist.append(self.else_)
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "For(%s, %s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.body), repr(self.else_))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class From(Node):
|
2006-03-03 14:16:20 -04:00
|
|
|
def __init__(self, modname, names, level, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.modname = modname
|
|
|
|
self.names = names
|
2006-03-03 14:16:20 -04:00
|
|
|
self.level = level
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2006-03-03 14:16:20 -04:00
|
|
|
return self.modname, self.names, self.level
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
return ()
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2006-03-03 14:16:20 -04:00
|
|
|
return "From(%s, %s, %s)" % (repr(self.modname), repr(self.names), repr(self.level))
|
2004-08-02 03:10:11 -03:00
|
|
|
|
|
|
|
class Function(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, decorators, name, argnames, defaults, flags, doc, code, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.decorators = decorators
|
|
|
|
self.name = name
|
|
|
|
self.argnames = argnames
|
|
|
|
self.defaults = defaults
|
|
|
|
self.flags = flags
|
|
|
|
self.doc = doc
|
|
|
|
self.code = code
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2004-08-02 03:10:11 -03:00
|
|
|
self.varargs = self.kwargs = None
|
|
|
|
if flags & CO_VARARGS:
|
|
|
|
self.varargs = 1
|
|
|
|
if flags & CO_VARKEYWORDS:
|
|
|
|
self.kwargs = 1
|
2006-03-03 22:43:44 -04:00
|
|
|
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2001-08-29 15:08:02 -03:00
|
|
|
def getChildren(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
children = []
|
2004-09-07 12:28:01 -03:00
|
|
|
children.append(self.decorators)
|
2004-08-02 03:10:11 -03:00
|
|
|
children.append(self.name)
|
|
|
|
children.append(self.argnames)
|
|
|
|
children.extend(flatten(self.defaults))
|
|
|
|
children.append(self.flags)
|
|
|
|
children.append(self.doc)
|
|
|
|
children.append(self.code)
|
2001-09-17 17:17:02 -03:00
|
|
|
return tuple(children)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-09-07 12:28:01 -03:00
|
|
|
if self.decorators is not None:
|
|
|
|
nodelist.append(self.decorators)
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.extend(flatten_nodes(self.defaults))
|
|
|
|
nodelist.append(self.code)
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Function(%s, %s, %s, %s, %s, %s, %s)" % (repr(self.decorators), repr(self.name), repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.doc), repr(self.code))
|
|
|
|
|
|
|
|
class GenExpr(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, code, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.code = code
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2006-08-16 20:38:05 -03:00
|
|
|
self.argnames = ['.0']
|
2004-08-02 03:10:11 -03:00
|
|
|
self.varargs = self.kwargs = None
|
2006-03-03 22:43:44 -04:00
|
|
|
|
2010-08-01 21:24:26 -03:00
|
|
|
|
2001-08-29 15:08:02 -03:00
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.code,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.code,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "GenExpr(%s)" % (repr(self.code),)
|
|
|
|
|
|
|
|
class GenExprFor(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, assign, iter, ifs, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.assign = assign
|
|
|
|
self.iter = iter
|
|
|
|
self.ifs = ifs
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2004-08-02 03:10:11 -03:00
|
|
|
self.is_outmost = False
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2001-08-29 15:08:02 -03:00
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
children = []
|
|
|
|
children.append(self.assign)
|
|
|
|
children.append(self.iter)
|
|
|
|
children.extend(flatten(self.ifs))
|
|
|
|
return tuple(children)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist = []
|
|
|
|
nodelist.append(self.assign)
|
|
|
|
nodelist.append(self.iter)
|
|
|
|
nodelist.extend(flatten_nodes(self.ifs))
|
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "GenExprFor(%s, %s, %s)" % (repr(self.assign), repr(self.iter), repr(self.ifs))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class GenExprIf(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, test, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.test = test
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.test,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.test,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "GenExprIf(%s)" % (repr(self.test),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class GenExprInner(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, quals, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.expr = expr
|
|
|
|
self.quals = quals
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
children = []
|
2004-08-02 03:10:11 -03:00
|
|
|
children.append(self.expr)
|
|
|
|
children.extend(flatten(self.quals))
|
2001-08-29 15:08:02 -03:00
|
|
|
return tuple(children)
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.append(self.expr)
|
|
|
|
nodelist.extend(flatten_nodes(self.quals))
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "GenExprInner(%s, %s)" % (repr(self.expr), repr(self.quals))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Getattr(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, attrname, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.expr = expr
|
|
|
|
self.attrname = attrname
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.expr, self.attrname
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.expr,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Getattr(%s, %s)" % (repr(self.expr), repr(self.attrname))
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Global(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, names, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.names = names
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.names,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return ()
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Global(%s)" % (repr(self.names),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class If(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, tests, else_, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.tests = tests
|
|
|
|
self.else_ = else_
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
children = []
|
2004-08-02 03:10:11 -03:00
|
|
|
children.extend(flatten(self.tests))
|
|
|
|
children.append(self.else_)
|
2001-08-29 15:08:02 -03:00
|
|
|
return tuple(children)
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.extend(flatten_nodes(self.tests))
|
2004-09-07 12:28:01 -03:00
|
|
|
if self.else_ is not None:
|
|
|
|
nodelist.append(self.else_)
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "If(%s, %s)" % (repr(self.tests), repr(self.else_))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2006-03-03 14:16:20 -04:00
|
|
|
class IfExp(Node):
|
|
|
|
def __init__(self, test, then, else_, lineno=None):
|
|
|
|
self.test = test
|
|
|
|
self.then = then
|
|
|
|
self.else_ = else_
|
|
|
|
self.lineno = lineno
|
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
return self.test, self.then, self.else_
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
return self.test, self.then, self.else_
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return "IfExp(%s, %s, %s)" % (repr(self.test), repr(self.then), repr(self.else_))
|
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Import(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, names, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.names = names
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2004-08-02 03:10:11 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
return self.names,
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
return ()
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return "Import(%s)" % (repr(self.names),)
|
|
|
|
|
|
|
|
class Invert(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, lineno=None):
|
2001-09-17 17:17:02 -03:00
|
|
|
self.expr = expr
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.expr,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
return self.expr,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Invert(%s)" % (repr(self.expr),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2001-09-17 17:17:02 -03:00
|
|
|
class Keyword(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, name, expr, lineno=None):
|
2001-09-17 17:17:02 -03:00
|
|
|
self.name = name
|
2000-10-25 15:02:59 -03:00
|
|
|
self.expr = expr
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
return self.name, self.expr
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
return self.expr,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
return "Keyword(%s, %s)" % (repr(self.name), repr(self.expr))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Lambda(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, argnames, defaults, flags, code, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.argnames = argnames
|
|
|
|
self.defaults = defaults
|
|
|
|
self.flags = flags
|
|
|
|
self.code = code
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2004-08-02 03:10:11 -03:00
|
|
|
self.varargs = self.kwargs = None
|
|
|
|
if flags & CO_VARARGS:
|
|
|
|
self.varargs = 1
|
|
|
|
if flags & CO_VARKEYWORDS:
|
|
|
|
self.kwargs = 1
|
2006-03-03 22:43:44 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
|
2001-08-29 15:08:02 -03:00
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
children = []
|
|
|
|
children.append(self.argnames)
|
|
|
|
children.extend(flatten(self.defaults))
|
|
|
|
children.append(self.flags)
|
|
|
|
children.append(self.code)
|
|
|
|
return tuple(children)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist = []
|
|
|
|
nodelist.extend(flatten_nodes(self.defaults))
|
|
|
|
nodelist.append(self.code)
|
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Lambda(%s, %s, %s, %s)" % (repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.code))
|
|
|
|
|
|
|
|
class LeftShift(Node):
|
2010-08-01 21:24:26 -03:00
|
|
|
def __init__(self, leftright, lineno=None):
|
|
|
|
self.left = leftright[0]
|
|
|
|
self.right = leftright[1]
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2004-08-02 03:10:11 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
return self.left, self.right
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
return self.left, self.right
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return "LeftShift((%s, %s))" % (repr(self.left), repr(self.right))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2001-09-17 17:17:02 -03:00
|
|
|
class List(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, lineno=None):
|
2001-09-17 17:17:02 -03:00
|
|
|
self.nodes = nodes
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-09-07 12:28:01 -03:00
|
|
|
return tuple(flatten(self.nodes))
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
return "List(%s)" % (repr(self.nodes),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class ListComp(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, quals, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.expr = expr
|
|
|
|
self.quals = quals
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
children = []
|
|
|
|
children.append(self.expr)
|
|
|
|
children.extend(flatten(self.quals))
|
|
|
|
return tuple(children)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist = []
|
|
|
|
nodelist.append(self.expr)
|
|
|
|
nodelist.extend(flatten_nodes(self.quals))
|
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "ListComp(%s, %s)" % (repr(self.expr), repr(self.quals))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class ListCompFor(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, assign, list, ifs, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.assign = assign
|
|
|
|
self.list = list
|
|
|
|
self.ifs = ifs
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2004-08-02 03:10:11 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
children = []
|
|
|
|
children.append(self.assign)
|
|
|
|
children.append(self.list)
|
|
|
|
children.extend(flatten(self.ifs))
|
|
|
|
return tuple(children)
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
nodelist = []
|
|
|
|
nodelist.append(self.assign)
|
|
|
|
nodelist.append(self.list)
|
|
|
|
nodelist.extend(flatten_nodes(self.ifs))
|
|
|
|
return tuple(nodelist)
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return "ListCompFor(%s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.ifs))
|
|
|
|
|
|
|
|
class ListCompIf(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, test, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.test = test
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2004-08-02 03:10:11 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
return self.test,
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
return self.test,
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return "ListCompIf(%s)" % (repr(self.test),)
|
|
|
|
|
|
|
|
class Mod(Node):
|
2010-08-01 21:24:26 -03:00
|
|
|
def __init__(self, leftright, lineno=None):
|
|
|
|
self.left = leftright[0]
|
|
|
|
self.right = leftright[1]
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2000-10-25 15:02:59 -03:00
|
|
|
return self.left, self.right
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
return self.left, self.right
|
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Mod((%s, %s))" % (repr(self.left), repr(self.right))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Module(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, doc, node, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.doc = doc
|
|
|
|
self.node = node
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.doc, self.node
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.node,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Module(%s, %s)" % (repr(self.doc), repr(self.node))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Mul(Node):
|
2010-08-01 21:24:26 -03:00
|
|
|
def __init__(self, leftright, lineno=None):
|
|
|
|
self.left = leftright[0]
|
|
|
|
self.right = leftright[1]
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.left, self.right
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.left, self.right
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Mul((%s, %s))" % (repr(self.left), repr(self.right))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Name(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, name, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.name = name
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-09-17 17:17:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.name,
|
2001-09-17 17:17:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
return ()
|
|
|
|
|
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Name(%s)" % (repr(self.name),)
|
2001-09-17 17:17:02 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Not(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, lineno=None):
|
2001-09-17 17:17:02 -03:00
|
|
|
self.expr = expr
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-09-17 17:17:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
return self.expr,
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
return self.expr,
|
|
|
|
|
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Not(%s)" % (repr(self.expr),)
|
2001-09-17 17:17:02 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Or(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.nodes = nodes
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-09-17 17:17:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-09-07 12:28:01 -03:00
|
|
|
return tuple(flatten(self.nodes))
|
2001-09-17 17:17:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist = []
|
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
|
|
|
return tuple(nodelist)
|
2001-09-17 17:17:02 -03:00
|
|
|
|
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Or(%s)" % (repr(self.nodes),)
|
2001-09-17 17:17:02 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Pass(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, lineno=None):
|
|
|
|
self.lineno = lineno
|
2004-08-02 03:10:11 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
return ()
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
return ()
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return "Pass()"
|
|
|
|
|
|
|
|
class Power(Node):
|
2010-08-01 21:24:26 -03:00
|
|
|
def __init__(self, leftright, lineno=None):
|
|
|
|
self.left = leftright[0]
|
|
|
|
self.right = leftright[1]
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-09-17 17:17:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
return self.left, self.right
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
return self.left, self.right
|
|
|
|
|
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Power((%s, %s))" % (repr(self.left), repr(self.right))
|
2001-09-17 17:17:02 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Print(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, dest, lineno=None):
|
2001-09-17 17:17:02 -03:00
|
|
|
self.nodes = nodes
|
2004-08-02 03:10:11 -03:00
|
|
|
self.dest = dest
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
children = []
|
2001-09-17 17:17:02 -03:00
|
|
|
children.extend(flatten(self.nodes))
|
2004-08-02 03:10:11 -03:00
|
|
|
children.append(self.dest)
|
2001-08-29 15:08:02 -03:00
|
|
|
return tuple(children)
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
2004-09-07 12:28:01 -03:00
|
|
|
if self.dest is not None:
|
|
|
|
nodelist.append(self.dest)
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Print(%s, %s)" % (repr(self.nodes), repr(self.dest))
|
2000-10-25 15:02:59 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Printnl(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, dest, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.nodes = nodes
|
|
|
|
self.dest = dest
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
children = []
|
2004-08-02 03:10:11 -03:00
|
|
|
children.extend(flatten(self.nodes))
|
|
|
|
children.append(self.dest)
|
2001-09-17 17:17:02 -03:00
|
|
|
return tuple(children)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
2004-09-07 12:28:01 -03:00
|
|
|
if self.dest is not None:
|
|
|
|
nodelist.append(self.dest)
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Printnl(%s, %s)" % (repr(self.nodes), repr(self.dest))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Raise(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr1, expr2, expr3, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.expr1 = expr1
|
|
|
|
self.expr2 = expr2
|
|
|
|
self.expr3 = expr3
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
children = []
|
2004-08-02 03:10:11 -03:00
|
|
|
children.append(self.expr1)
|
|
|
|
children.append(self.expr2)
|
|
|
|
children.append(self.expr3)
|
2001-08-29 15:08:02 -03:00
|
|
|
return tuple(children)
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-09-07 12:28:01 -03:00
|
|
|
if self.expr1 is not None:
|
|
|
|
nodelist.append(self.expr1)
|
|
|
|
if self.expr2 is not None:
|
|
|
|
nodelist.append(self.expr2)
|
|
|
|
if self.expr3 is not None:
|
|
|
|
nodelist.append(self.expr3)
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Raise(%s, %s, %s)" % (repr(self.expr1), repr(self.expr2), repr(self.expr3))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Return(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, value, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.value = value
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.value,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.value,
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Return(%s)" % (repr(self.value),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class RightShift(Node):
|
2010-08-01 21:24:26 -03:00
|
|
|
def __init__(self, leftright, lineno=None):
|
|
|
|
self.left = leftright[0]
|
|
|
|
self.right = leftright[1]
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2004-08-02 03:10:11 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
return self.left, self.right
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
return self.left, self.right
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return "RightShift((%s, %s))" % (repr(self.left), repr(self.right))
|
|
|
|
|
|
|
|
class Slice(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, flags, lower, upper, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.expr = expr
|
|
|
|
self.flags = flags
|
|
|
|
self.lower = lower
|
|
|
|
self.upper = upper
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
children = []
|
2004-08-02 03:10:11 -03:00
|
|
|
children.append(self.expr)
|
|
|
|
children.append(self.flags)
|
|
|
|
children.append(self.lower)
|
|
|
|
children.append(self.upper)
|
2001-08-29 15:08:02 -03:00
|
|
|
return tuple(children)
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.append(self.expr)
|
2004-09-07 12:28:01 -03:00
|
|
|
if self.lower is not None:
|
|
|
|
nodelist.append(self.lower)
|
|
|
|
if self.upper is not None:
|
|
|
|
nodelist.append(self.upper)
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Slice(%s, %s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.lower), repr(self.upper))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Sliceobj(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, lineno=None):
|
2001-09-17 17:17:02 -03:00
|
|
|
self.nodes = nodes
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-09-07 12:28:01 -03:00
|
|
|
return tuple(flatten(self.nodes))
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Sliceobj(%s)" % (repr(self.nodes),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Stmt(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.nodes = nodes
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-09-07 12:28:01 -03:00
|
|
|
return tuple(flatten(self.nodes))
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Stmt(%s)" % (repr(self.nodes),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2001-09-17 17:17:02 -03:00
|
|
|
class Sub(Node):
|
2010-08-01 21:24:26 -03:00
|
|
|
def __init__(self, leftright, lineno=None):
|
|
|
|
self.left = leftright[0]
|
|
|
|
self.right = leftright[1]
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
return self.left, self.right
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
return self.left, self.right
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2001-09-17 17:17:02 -03:00
|
|
|
return "Sub((%s, %s))" % (repr(self.left), repr(self.right))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Subscript(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, flags, subs, lineno=None):
|
2001-09-17 17:17:02 -03:00
|
|
|
self.expr = expr
|
2004-08-02 03:10:11 -03:00
|
|
|
self.flags = flags
|
|
|
|
self.subs = subs
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
children = []
|
|
|
|
children.append(self.expr)
|
|
|
|
children.append(self.flags)
|
|
|
|
children.extend(flatten(self.subs))
|
|
|
|
return tuple(children)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist = []
|
|
|
|
nodelist.append(self.expr)
|
|
|
|
nodelist.extend(flatten_nodes(self.subs))
|
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Subscript(%s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.subs))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class TryExcept(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, body, handlers, else_, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.body = body
|
|
|
|
self.handlers = handlers
|
2000-10-25 15:02:59 -03:00
|
|
|
self.else_ = else_
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
children = []
|
2004-08-02 03:10:11 -03:00
|
|
|
children.append(self.body)
|
|
|
|
children.extend(flatten(self.handlers))
|
2001-08-29 15:08:02 -03:00
|
|
|
children.append(self.else_)
|
|
|
|
return tuple(children)
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.append(self.body)
|
|
|
|
nodelist.extend(flatten_nodes(self.handlers))
|
2004-09-07 12:28:01 -03:00
|
|
|
if self.else_ is not None:
|
|
|
|
nodelist.append(self.else_)
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "TryExcept(%s, %s, %s)" % (repr(self.body), repr(self.handlers), repr(self.else_))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class TryFinally(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, body, final, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.body = body
|
|
|
|
self.final = final
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.body, self.final
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.body, self.final
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "TryFinally(%s, %s)" % (repr(self.body), repr(self.final))
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Tuple(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, nodes, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.nodes = nodes
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-09-07 12:28:01 -03:00
|
|
|
return tuple(flatten(self.nodes))
|
2001-08-29 15:08:02 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2002-02-23 18:35:33 -04:00
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.extend(flatten_nodes(self.nodes))
|
2002-02-23 18:35:33 -04:00
|
|
|
return tuple(nodelist)
|
2001-08-29 15:08:02 -03:00
|
|
|
|
2000-10-25 15:02:59 -03:00
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Tuple(%s)" % (repr(self.nodes),)
|
2000-02-03 20:25:23 -04:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class UnaryAdd(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.expr = expr
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2004-05-19 05:20:33 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.expr,
|
2004-05-19 05:20:33 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.expr,
|
2004-05-19 05:20:33 -03:00
|
|
|
|
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "UnaryAdd(%s)" % (repr(self.expr),)
|
2004-05-19 05:20:33 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class UnarySub(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, expr, lineno=None):
|
2004-05-19 05:20:33 -03:00
|
|
|
self.expr = expr
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2004-05-19 05:20:33 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.expr,
|
2004-05-19 05:20:33 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.expr,
|
2004-05-19 05:20:33 -03:00
|
|
|
|
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "UnarySub(%s)" % (repr(self.expr),)
|
2004-05-19 05:20:33 -03:00
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class While(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, test, body, else_, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.test = test
|
|
|
|
self.body = body
|
|
|
|
self.else_ = else_
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2004-05-19 05:20:33 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
children = []
|
2004-08-02 03:10:11 -03:00
|
|
|
children.append(self.test)
|
|
|
|
children.append(self.body)
|
|
|
|
children.append(self.else_)
|
2004-05-19 05:20:33 -03:00
|
|
|
return tuple(children)
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
nodelist = []
|
2004-08-02 03:10:11 -03:00
|
|
|
nodelist.append(self.test)
|
|
|
|
nodelist.append(self.body)
|
2004-09-07 12:28:01 -03:00
|
|
|
if self.else_ is not None:
|
|
|
|
nodelist.append(self.else_)
|
2004-05-19 05:20:33 -03:00
|
|
|
return tuple(nodelist)
|
|
|
|
|
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "While(%s, %s, %s)" % (repr(self.test), repr(self.body), repr(self.else_))
|
2004-05-19 05:20:33 -03:00
|
|
|
|
2006-02-27 18:32:47 -04:00
|
|
|
class With(Node):
|
|
|
|
def __init__(self, expr, vars, body, lineno=None):
|
|
|
|
self.expr = expr
|
|
|
|
self.vars = vars
|
|
|
|
self.body = body
|
|
|
|
self.lineno = lineno
|
|
|
|
|
|
|
|
def getChildren(self):
|
|
|
|
children = []
|
|
|
|
children.append(self.expr)
|
|
|
|
children.append(self.vars)
|
|
|
|
children.append(self.body)
|
|
|
|
return tuple(children)
|
|
|
|
|
|
|
|
def getChildNodes(self):
|
|
|
|
nodelist = []
|
|
|
|
nodelist.append(self.expr)
|
|
|
|
if self.vars is not None:
|
|
|
|
nodelist.append(self.vars)
|
|
|
|
nodelist.append(self.body)
|
|
|
|
return tuple(nodelist)
|
|
|
|
|
|
|
|
def __repr__(self):
|
|
|
|
return "With(%s, %s, %s)" % (repr(self.expr), repr(self.vars), repr(self.body))
|
|
|
|
|
2004-08-02 03:10:11 -03:00
|
|
|
class Yield(Node):
|
2004-09-07 12:28:01 -03:00
|
|
|
def __init__(self, value, lineno=None):
|
2004-08-02 03:10:11 -03:00
|
|
|
self.value = value
|
2004-09-07 12:28:01 -03:00
|
|
|
self.lineno = lineno
|
2004-05-19 05:20:33 -03:00
|
|
|
|
|
|
|
def getChildren(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.value,
|
2004-05-19 05:20:33 -03:00
|
|
|
|
|
|
|
def getChildNodes(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return self.value,
|
2004-05-19 05:20:33 -03:00
|
|
|
|
|
|
|
def __repr__(self):
|
2004-08-02 03:10:11 -03:00
|
|
|
return "Yield(%s)" % (repr(self.value),)
|
2004-05-19 05:20:33 -03:00
|
|
|
|
2004-09-07 12:28:01 -03:00
|
|
|
for name, obj in globals().items():
|
|
|
|
if isinstance(obj, type) and issubclass(obj, Node):
|
2004-09-12 00:49:31 -03:00
|
|
|
nodes[name.lower()] = obj
|