"""Python abstract syntax node definitions
This file is automatically generated by Tools/compiler/astgen.py
from compiler.consts import CO_VARARGS, CO_VARKEYWORDS
if t is tuple or t is list:
for elt2 in flatten(elt):
return [n for n in flatten(seq) if isinstance(n, Node)]
"""Abstract base class for ast nodes."""
pass # implemented by subclasses
for n in self.getChildren():
def asList(self): # for backwards compatibility
return self.getChildren()
pass # implemented by subclasses
# Expression is an artificial node class to support "eval"
nodes["expression"] = "Expression"
def __init__(self, node):
return "Expression(%s)" % (repr(self.node))
def __init__(self, leftright, lineno=None):
self.right = leftright[1]
return self.left, self.right
return self.left, self.right
return "Add((%s, %s))" % (repr(self.left), repr(self.right))
def __init__(self, nodes, lineno=None):
return tuple(flatten(self.nodes))
nodelist.extend(flatten_nodes(self.nodes))
return "And(%s)" % (repr(self.nodes),)
def __init__(self, expr, attrname, flags, lineno=None):
return self.expr, self.attrname, self.flags
return "AssAttr(%s, %s, %s)" % (repr(self.expr), repr(self.attrname), repr(self.flags))
def __init__(self, nodes, lineno=None):
return tuple(flatten(self.nodes))
nodelist.extend(flatten_nodes(self.nodes))
return "AssList(%s)" % (repr(self.nodes),)
def __init__(self, name, flags, lineno=None):
return self.name, self.flags
return "AssName(%s, %s)" % (repr(self.name), repr(self.flags))
def __init__(self, nodes, lineno=None):
return tuple(flatten(self.nodes))
nodelist.extend(flatten_nodes(self.nodes))
return "AssTuple(%s)" % (repr(self.nodes),)
def __init__(self, test, fail, lineno=None):
children.append(self.test)
children.append(self.fail)
nodelist.append(self.test)
if self.fail is not None:
nodelist.append(self.fail)
return "Assert(%s, %s)" % (repr(self.test), repr(self.fail))
def __init__(self, nodes, expr, lineno=None):
children.extend(flatten(self.nodes))
children.append(self.expr)
nodelist.extend(flatten_nodes(self.nodes))
nodelist.append(self.expr)
return "Assign(%s, %s)" % (repr(self.nodes), repr(self.expr))
def __init__(self, node, op, expr, lineno=None):
return self.node, self.op, self.expr
return self.node, self.expr
return "AugAssign(%s, %s, %s)" % (repr(self.node), repr(self.op), repr(self.expr))
def __init__(self, expr, lineno=None):
return "Backquote(%s)" % (repr(self.expr),)
def __init__(self, nodes, lineno=None):
return tuple(flatten(self.nodes))
nodelist.extend(flatten_nodes(self.nodes))
return "Bitand(%s)" % (repr(self.nodes),)
def __init__(self, nodes, lineno=None):
return tuple(flatten(self.nodes))
nodelist.extend(flatten_nodes(self.nodes))
return "Bitor(%s)" % (repr(self.nodes),)
def __init__(self, nodes, lineno=None):
return tuple(flatten(self.nodes))
nodelist.extend(flatten_nodes(self.nodes))
return "Bitxor(%s)" % (repr(self.nodes),)
def __init__(self, lineno=None):
def __init__(self, node, args, star_args = None, dstar_args = None, lineno=None):
self.star_args = star_args
self.dstar_args = dstar_args
children.append(self.node)
children.extend(flatten(self.args))
children.append(self.star_args)
children.append(self.dstar_args)
nodelist.append(self.node)
nodelist.extend(flatten_nodes(self.args))
if self.star_args is not None:
nodelist.append(self.star_args)
if self.dstar_args is not None:
nodelist.append(self.dstar_args)
return "CallFunc(%s, %s, %s, %s)" % (repr(self.node), repr(self.args), repr(self.star_args), repr(self.dstar_args))
def __init__(self, name, bases, doc, code, decorators = None, lineno=None):
self.decorators = decorators
children.append(self.name)
children.extend(flatten(self.bases))
children.append(self.doc)
children.append(self.code)
children.append(self.decorators)
nodelist.extend(flatten_nodes(self.bases))
nodelist.append(self.code)
if self.decorators is not None:
nodelist.append(self.decorators)
return "Class(%s, %s, %s, %s, %s)" % (repr(self.name), repr(self.bases), repr(self.doc), repr(self.code), repr(self.decorators))
def __init__(self, expr, ops, lineno=None):
children.append(self.expr)
children.extend(flatten(self.ops))
nodelist.append(self.expr)
nodelist.extend(flatten_nodes(self.ops))
return "Compare(%s, %s)" % (repr(self.expr), repr(self.ops))
def __init__(self, value, lineno=None):
return "Const(%s)" % (repr(self.value),)
def __init__(self, lineno=None):
def __init__(self, nodes, lineno=None):
return tuple(flatten(self.nodes))
nodelist.extend(flatten_nodes(self.nodes))
return "Decorators(%s)" % (repr(self.nodes),)
def __init__(self, items, lineno=None):
return tuple(flatten(self.items))
nodelist.extend(flatten_nodes(self.items))
return "Dict(%s)" % (repr(self.items),)
def __init__(self, expr, lineno=None):
return "Discard(%s)" % (repr(self.expr),)
def __init__(self, leftright, lineno=None):
self.right = leftright[1]
return self.left, self.right
return self.left, self.right
return "Div((%s, %s))" % (repr(self.left), repr(self.right))
def __init__(self, lineno=None):
def __init__(self, expr, locals, globals, lineno=None):
children.append(self.expr)
children.append(self.locals)
children.append(self.globals)
nodelist.append(self.expr)
if self.locals is not None:
nodelist.append(self.locals)
if self.globals is not None:
nodelist.append(self.globals)
return "Exec(%s, %s, %s)" % (repr(self.expr), repr(self.locals), repr(self.globals))
def __init__(self, leftright, lineno=None):
self.right = leftright[1]
return self.left, self.right
return self.left, self.right
return "FloorDiv((%s, %s))" % (repr(self.left), repr(self.right))