annotate Lib/compiler/ast.py @ 54294:dba767bc3155 legacy-trunk

remove mention of old ctypes version
author Benjamin Peterson <benjamin@python.org>
date Sat, 23 May 2009 20:59:09 +0000
parents 144e84672ef9
children 751c6dd71b5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15328
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
1 """Python abstract syntax node definitions
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
2
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
3 This file is automatically generated by Tools/compiler/astgen.py
15328
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
4 """
37408
a60a9443e8da Use absolute imports
Neal Norwitz <nnorwitz@gmail.com>
parents: 36828
diff changeset
5 from compiler.consts import CO_VARARGS, CO_VARKEYWORDS
11703
34f53c36ba9a three files from the p2c cvs tree. the message here indicates the
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
6
34989
8b05a4732cf3 Fix compiler.ast.flatten function so that it works on lists.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 33463
diff changeset
7 def flatten(seq):
15328
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
8 l = []
34989
8b05a4732cf3 Fix compiler.ast.flatten function so that it works on lists.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 33463
diff changeset
9 for elt in seq:
15328
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
10 t = type(elt)
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
11 if t is tuple or t is list:
15328
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
12 for elt2 in flatten(elt):
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
13 l.append(elt2)
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
14 else:
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
15 l.append(elt)
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
16 return l
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
17
34989
8b05a4732cf3 Fix compiler.ast.flatten function so that it works on lists.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 33463
diff changeset
18 def flatten_nodes(seq):
8b05a4732cf3 Fix compiler.ast.flatten function so that it works on lists.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 33463
diff changeset
19 return [n for n in flatten(seq) if isinstance(n, Node)]
19557
2c2cc31bdf15 Revise implementations of getChildren() and getChildNodes().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19362
diff changeset
20
11703
34f53c36ba9a three files from the p2c cvs tree. the message here indicates the
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
21 nodes = {}
34f53c36ba9a three files from the p2c cvs tree. the message here indicates the
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
22
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
23 class Node:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
24 """Abstract base class for ast nodes."""
15328
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
25 def getChildren(self):
19557
2c2cc31bdf15 Revise implementations of getChildren() and getChildNodes().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19362
diff changeset
26 pass # implemented by subclasses
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
27 def __iter__(self):
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
28 for n in self.getChildren():
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
29 yield n
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
30 def asList(self): # for backwards compatibility
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
31 return self.getChildren()
19249
06f9027141ff Regenerated from new ast.txt and new astgen.py
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15328
diff changeset
32 def getChildNodes(self):
19557
2c2cc31bdf15 Revise implementations of getChildren() and getChildNodes().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19362
diff changeset
33 pass # implemented by subclasses
11703
34f53c36ba9a three files from the p2c cvs tree. the message here indicates the
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
34
34f53c36ba9a three files from the p2c cvs tree. the message here indicates the
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
35 class EmptyNode(Node):
19557
2c2cc31bdf15 Revise implementations of getChildren() and getChildNodes().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19362
diff changeset
36 pass
11703
34f53c36ba9a three files from the p2c cvs tree. the message here indicates the
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
37
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
38 class Expression(Node):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
39 # Expression is an artificial node class to support "eval"
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
40 nodes["expression"] = "Expression"
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
41 def __init__(self, node):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
42 self.node = node
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
43
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
44 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
45 return self.node,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
46
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
47 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
48 return self.node,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
49
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
50 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
51 return "Expression(%s)" % (repr(self.node))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
52
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
53 class Add(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
54 def __init__(self, (left, right), lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
55 self.left = left
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
56 self.right = right
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
57 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
58
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
59 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
60 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
61
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
62 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
63 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
64
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
65 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
66 return "Add((%s, %s))" % (repr(self.left), repr(self.right))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
67
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
68 class And(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
69 def __init__(self, nodes, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
70 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
71 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
72
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
73 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
74 return tuple(flatten(self.nodes))
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
75
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
76 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
77 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
78 nodelist.extend(flatten_nodes(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
79 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
80
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
81 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
82 return "And(%s)" % (repr(self.nodes),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
83
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
84 class AssAttr(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
85 def __init__(self, expr, attrname, flags, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
86 self.expr = expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
87 self.attrname = attrname
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
88 self.flags = flags
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
89 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
90
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
91 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
92 return self.expr, self.attrname, self.flags
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
93
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
94 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
95 return self.expr,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
96
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
97 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
98 return "AssAttr(%s, %s, %s)" % (repr(self.expr), repr(self.attrname), repr(self.flags))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
99
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
100 class AssList(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
101 def __init__(self, nodes, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
102 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
103 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
104
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
105 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
106 return tuple(flatten(self.nodes))
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
107
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
108 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
109 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
110 nodelist.extend(flatten_nodes(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
111 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
112
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
113 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
114 return "AssList(%s)" % (repr(self.nodes),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
115
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
116 class AssName(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
117 def __init__(self, name, flags, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
118 self.name = name
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
119 self.flags = flags
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
120 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
121
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
122 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
123 return self.name, self.flags
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
124
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
125 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
126 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
127
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
128 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
129 return "AssName(%s, %s)" % (repr(self.name), repr(self.flags))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
130
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
131 class AssTuple(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
132 def __init__(self, nodes, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
133 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
134 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
135
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
136 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
137 return tuple(flatten(self.nodes))
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
138
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
139 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
140 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
141 nodelist.extend(flatten_nodes(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
142 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
143
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
144 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
145 return "AssTuple(%s)" % (repr(self.nodes),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
146
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
147 class Assert(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
148 def __init__(self, test, fail, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
149 self.test = test
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
150 self.fail = fail
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
151 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
152
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
153 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
154 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
155 children.append(self.test)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
156 children.append(self.fail)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
157 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
158
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
159 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
160 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
161 nodelist.append(self.test)
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
162 if self.fail is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
163 nodelist.append(self.fail)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
164 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
165
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
166 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
167 return "Assert(%s, %s)" % (repr(self.test), repr(self.fail))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
168
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
169 class Assign(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
170 def __init__(self, nodes, expr, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
171 self.nodes = nodes
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
172 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
173 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
174
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
175 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
176 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
177 children.extend(flatten(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
178 children.append(self.expr)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
179 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
180
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
181 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
182 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
183 nodelist.extend(flatten_nodes(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
184 nodelist.append(self.expr)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
185 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
186
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
187 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
188 return "Assign(%s, %s)" % (repr(self.nodes), repr(self.expr))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
189
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
190 class AugAssign(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
191 def __init__(self, node, op, expr, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
192 self.node = node
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
193 self.op = op
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
194 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
195 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
196
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
197 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
198 return self.node, self.op, self.expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
199
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
200 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
201 return self.node, self.expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
202
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
203 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
204 return "AugAssign(%s, %s, %s)" % (repr(self.node), repr(self.op), repr(self.expr))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
205
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
206 class Backquote(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
207 def __init__(self, expr, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
208 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
209 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
210
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
211 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
212 return self.expr,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
213
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
214 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
215 return self.expr,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
216
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
217 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
218 return "Backquote(%s)" % (repr(self.expr),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
219
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
220 class Bitand(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
221 def __init__(self, nodes, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
222 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
223 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
224
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
225 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
226 return tuple(flatten(self.nodes))
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
227
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
228 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
229 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
230 nodelist.extend(flatten_nodes(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
231 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
232
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
233 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
234 return "Bitand(%s)" % (repr(self.nodes),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
235
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
236 class Bitor(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
237 def __init__(self, nodes, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
238 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
239 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
240
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
241 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
242 return tuple(flatten(self.nodes))
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
243
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
244 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
245 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
246 nodelist.extend(flatten_nodes(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
247 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
248
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
249 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
250 return "Bitor(%s)" % (repr(self.nodes),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
251
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
252 class Bitxor(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
253 def __init__(self, nodes, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
254 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
255 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
256
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
257 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
258 return tuple(flatten(self.nodes))
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
259
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
260 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
261 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
262 nodelist.extend(flatten_nodes(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
263 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
264
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
265 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
266 return "Bitxor(%s)" % (repr(self.nodes),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
267
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
268 class Break(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
269 def __init__(self, lineno=None):
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
270 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
271
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
272 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
273 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
274
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
275 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
276 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
277
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
278 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
279 return "Break()"
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
280
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
281 class CallFunc(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
282 def __init__(self, node, args, star_args = None, dstar_args = None, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
283 self.node = node
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
284 self.args = args
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
285 self.star_args = star_args
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
286 self.dstar_args = dstar_args
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
287 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
288
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
289 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
290 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
291 children.append(self.node)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
292 children.extend(flatten(self.args))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
293 children.append(self.star_args)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
294 children.append(self.dstar_args)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
295 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
296
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
297 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
298 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
299 nodelist.append(self.node)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
300 nodelist.extend(flatten_nodes(self.args))
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
301 if self.star_args is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
302 nodelist.append(self.star_args)
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
303 if self.dstar_args is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
304 nodelist.append(self.dstar_args)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
305 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
306
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
307 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
308 return "CallFunc(%s, %s, %s, %s)" % (repr(self.node), repr(self.args), repr(self.star_args), repr(self.dstar_args))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
309
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
310 class Class(Node):
45520
144e84672ef9 Issue 2117. Update compiler module to handle class decorators.
Facundo Batista <facundobatista@gmail.com>
parents: 39532
diff changeset
311 def __init__(self, name, bases, doc, code, decorators = None, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
312 self.name = name
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
313 self.bases = bases
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
314 self.doc = doc
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
315 self.code = code
45520
144e84672ef9 Issue 2117. Update compiler module to handle class decorators.
Facundo Batista <facundobatista@gmail.com>
parents: 39532
diff changeset
316 self.decorators = decorators
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
317 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
318
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
319 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
320 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
321 children.append(self.name)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
322 children.extend(flatten(self.bases))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
323 children.append(self.doc)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
324 children.append(self.code)
45520
144e84672ef9 Issue 2117. Update compiler module to handle class decorators.
Facundo Batista <facundobatista@gmail.com>
parents: 39532
diff changeset
325 children.append(self.decorators)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
326 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
327
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
328 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
329 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
330 nodelist.extend(flatten_nodes(self.bases))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
331 nodelist.append(self.code)
45520
144e84672ef9 Issue 2117. Update compiler module to handle class decorators.
Facundo Batista <facundobatista@gmail.com>
parents: 39532
diff changeset
332 if self.decorators is not None:
144e84672ef9 Issue 2117. Update compiler module to handle class decorators.
Facundo Batista <facundobatista@gmail.com>
parents: 39532
diff changeset
333 nodelist.append(self.decorators)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
334 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
335
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
336 def __repr__(self):
45520
144e84672ef9 Issue 2117. Update compiler module to handle class decorators.
Facundo Batista <facundobatista@gmail.com>
parents: 39532
diff changeset
337 return "Class(%s, %s, %s, %s, %s)" % (repr(self.name), repr(self.bases), repr(self.doc), repr(self.code), repr(self.decorators))
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
338
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
339 class Compare(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
340 def __init__(self, expr, ops, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
341 self.expr = expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
342 self.ops = ops
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
343 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
344
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
345 def getChildren(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
346 children = []
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
347 children.append(self.expr)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
348 children.extend(flatten(self.ops))
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
349 return tuple(children)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
350
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
351 def getChildNodes(self):
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
352 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
353 nodelist.append(self.expr)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
354 nodelist.extend(flatten_nodes(self.ops))
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
355 return tuple(nodelist)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
356
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
357 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
358 return "Compare(%s, %s)" % (repr(self.expr), repr(self.ops))
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
359
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
360 class Const(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
361 def __init__(self, value, lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
362 self.value = value
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
363 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
364
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
365 def getChildren(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
366 return self.value,
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
367
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
368 def getChildNodes(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
369 return ()
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
370
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
371 def __repr__(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
372 return "Const(%s)" % (repr(self.value),)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
373
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
374 class Continue(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
375 def __init__(self, lineno=None):
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
376 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
377
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
378 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
379 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
380
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
381 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
382 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
383
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
384 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
385 return "Continue()"
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
386
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
387 class Decorators(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
388 def __init__(self, nodes, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
389 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
390 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
391
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
392 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
393 return tuple(flatten(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
394
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
395 def getChildNodes(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
396 nodelist = []
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
397 nodelist.extend(flatten_nodes(self.nodes))
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
398 return tuple(nodelist)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
399
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
400 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
401 return "Decorators(%s)" % (repr(self.nodes),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
402
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
403 class Dict(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
404 def __init__(self, items, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
405 self.items = items
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
406 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
407
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
408 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
409 return tuple(flatten(self.items))
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
410
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
411 def getChildNodes(self):
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
412 nodelist = []
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
413 nodelist.extend(flatten_nodes(self.items))
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
414 return tuple(nodelist)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
415
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
416 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
417 return "Dict(%s)" % (repr(self.items),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
418
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
419 class Discard(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
420 def __init__(self, expr, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
421 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
422 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
423
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
424 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
425 return self.expr,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
426
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
427 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
428 return self.expr,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
429
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
430 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
431 return "Discard(%s)" % (repr(self.expr),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
432
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
433 class Div(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
434 def __init__(self, (left, right), lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
435 self.left = left
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
436 self.right = right
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
437 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
438
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
439 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
440 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
441
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
442 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
443 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
444
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
445 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
446 return "Div((%s, %s))" % (repr(self.left), repr(self.right))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
447
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
448 class Ellipsis(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
449 def __init__(self, lineno=None):
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
450 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
451
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
452 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
453 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
454
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
455 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
456 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
457
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
458 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
459 return "Ellipsis()"
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
460
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
461 class Exec(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
462 def __init__(self, expr, locals, globals, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
463 self.expr = expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
464 self.locals = locals
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
465 self.globals = globals
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
466 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
467
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
468 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
469 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
470 children.append(self.expr)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
471 children.append(self.locals)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
472 children.append(self.globals)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
473 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
474
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
475 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
476 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
477 nodelist.append(self.expr)
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
478 if self.locals is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
479 nodelist.append(self.locals)
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
480 if self.globals is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
481 nodelist.append(self.globals)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
482 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
483
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
484 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
485 return "Exec(%s, %s, %s)" % (repr(self.expr), repr(self.locals), repr(self.globals))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
486
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
487 class FloorDiv(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
488 def __init__(self, (left, right), lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
489 self.left = left
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
490 self.right = right
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
491 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
492
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
493 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
494 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
495
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
496 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
497 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
498
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
499 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
500 return "FloorDiv((%s, %s))" % (repr(self.left), repr(self.right))
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
501
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
502 class For(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
503 def __init__(self, assign, list, body, else_, lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
504 self.assign = assign
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
505 self.list = list
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
506 self.body = body
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
507 self.else_ = else_
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
508 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
509
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
510 def getChildren(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
511 children = []
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
512 children.append(self.assign)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
513 children.append(self.list)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
514 children.append(self.body)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
515 children.append(self.else_)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
516 return tuple(children)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
517
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
518 def getChildNodes(self):
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
519 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
520 nodelist.append(self.assign)
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
521 nodelist.append(self.list)
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
522 nodelist.append(self.body)
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
523 if self.else_ is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
524 nodelist.append(self.else_)
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
525 return tuple(nodelist)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
526
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
527 def __repr__(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
528 return "For(%s, %s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.body), repr(self.else_))
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
529
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
530 class From(Node):
36820
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
531 def __init__(self, modname, names, level, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
532 self.modname = modname
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
533 self.names = names
36820
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
534 self.level = level
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
535 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
536
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
537 def getChildren(self):
36820
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
538 return self.modname, self.names, self.level
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
539
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
540 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
541 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
542
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
543 def __repr__(self):
36820
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
544 return "From(%s, %s, %s)" % (repr(self.modname), repr(self.names), repr(self.level))
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
545
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
546 class Function(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
547 def __init__(self, decorators, name, argnames, defaults, flags, doc, code, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
548 self.decorators = decorators
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
549 self.name = name
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
550 self.argnames = argnames
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
551 self.defaults = defaults
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
552 self.flags = flags
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
553 self.doc = doc
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
554 self.code = code
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
555 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
556 self.varargs = self.kwargs = None
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
557 if flags & CO_VARARGS:
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
558 self.varargs = 1
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
559 if flags & CO_VARKEYWORDS:
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
560 self.kwargs = 1
36828
1f584164e013 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 36820
diff changeset
561
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
562
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
563
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
564 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
565 children = []
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
566 children.append(self.decorators)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
567 children.append(self.name)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
568 children.append(self.argnames)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
569 children.extend(flatten(self.defaults))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
570 children.append(self.flags)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
571 children.append(self.doc)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
572 children.append(self.code)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
573 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
574
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
575 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
576 nodelist = []
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
577 if self.decorators is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
578 nodelist.append(self.decorators)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
579 nodelist.extend(flatten_nodes(self.defaults))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
580 nodelist.append(self.code)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
581 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
582
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
583 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
584 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))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
585
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
586 class GenExpr(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
587 def __init__(self, code, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
588 self.code = code
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
589 self.lineno = lineno
39532
a6afe0eda711 Fix a bug in the ``compiler`` package that caused invalid code to be
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 37408
diff changeset
590 self.argnames = ['.0']
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
591 self.varargs = self.kwargs = None
36828
1f584164e013 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 36820
diff changeset
592
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
593 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
594 return self.code,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
595
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
596 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
597 return self.code,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
598
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
599 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
600 return "GenExpr(%s)" % (repr(self.code),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
601
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
602 class GenExprFor(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
603 def __init__(self, assign, iter, ifs, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
604 self.assign = assign
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
605 self.iter = iter
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
606 self.ifs = ifs
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
607 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
608 self.is_outmost = False
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
609
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
610
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
611 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
612 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
613 children.append(self.assign)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
614 children.append(self.iter)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
615 children.extend(flatten(self.ifs))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
616 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
617
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
618 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
619 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
620 nodelist.append(self.assign)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
621 nodelist.append(self.iter)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
622 nodelist.extend(flatten_nodes(self.ifs))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
623 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
624
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
625 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
626 return "GenExprFor(%s, %s, %s)" % (repr(self.assign), repr(self.iter), repr(self.ifs))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
627
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
628 class GenExprIf(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
629 def __init__(self, test, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
630 self.test = test
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
631 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
632
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
633 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
634 return self.test,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
635
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
636 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
637 return self.test,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
638
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
639 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
640 return "GenExprIf(%s)" % (repr(self.test),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
641
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
642 class GenExprInner(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
643 def __init__(self, expr, quals, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
644 self.expr = expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
645 self.quals = quals
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
646 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
647
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
648 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
649 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
650 children.append(self.expr)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
651 children.extend(flatten(self.quals))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
652 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
653
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
654 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
655 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
656 nodelist.append(self.expr)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
657 nodelist.extend(flatten_nodes(self.quals))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
658 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
659
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
660 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
661 return "GenExprInner(%s, %s)" % (repr(self.expr), repr(self.quals))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
662
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
663 class Getattr(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
664 def __init__(self, expr, attrname, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
665 self.expr = expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
666 self.attrname = attrname
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
667 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
668
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
669 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
670 return self.expr, self.attrname
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
671
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
672 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
673 return self.expr,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
674
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
675 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
676 return "Getattr(%s, %s)" % (repr(self.expr), repr(self.attrname))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
677
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
678 class Global(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
679 def __init__(self, names, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
680 self.names = names
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
681 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
682
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
683 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
684 return self.names,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
685
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
686 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
687 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
688
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
689 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
690 return "Global(%s)" % (repr(self.names),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
691
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
692 class If(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
693 def __init__(self, tests, else_, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
694 self.tests = tests
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
695 self.else_ = else_
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
696 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
697
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
698 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
699 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
700 children.extend(flatten(self.tests))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
701 children.append(self.else_)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
702 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
703
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
704 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
705 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
706 nodelist.extend(flatten_nodes(self.tests))
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
707 if self.else_ is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
708 nodelist.append(self.else_)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
709 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
710
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
711 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
712 return "If(%s, %s)" % (repr(self.tests), repr(self.else_))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
713
36820
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
714 class IfExp(Node):
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
715 def __init__(self, test, then, else_, lineno=None):
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
716 self.test = test
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
717 self.then = then
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
718 self.else_ = else_
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
719 self.lineno = lineno
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
720
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
721 def getChildren(self):
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
722 return self.test, self.then, self.else_
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
723
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
724 def getChildNodes(self):
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
725 return self.test, self.then, self.else_
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
726
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
727 def __repr__(self):
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
728 return "IfExp(%s, %s, %s)" % (repr(self.test), repr(self.then), repr(self.else_))
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
729
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
730 class Import(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
731 def __init__(self, names, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
732 self.names = names
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
733 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
734
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
735 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
736 return self.names,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
737
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
738 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
739 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
740
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
741 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
742 return "Import(%s)" % (repr(self.names),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
743
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
744 class Invert(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
745 def __init__(self, expr, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
746 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
747 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
748
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
749 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
750 return self.expr,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
751
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
752 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
753 return self.expr,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
754
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
755 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
756 return "Invert(%s)" % (repr(self.expr),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
757
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
758 class Keyword(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
759 def __init__(self, name, expr, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
760 self.name = name
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
761 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
762 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
763
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
764 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
765 return self.name, self.expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
766
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
767 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
768 return self.expr,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
769
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
770 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
771 return "Keyword(%s, %s)" % (repr(self.name), repr(self.expr))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
772
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
773 class Lambda(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
774 def __init__(self, argnames, defaults, flags, code, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
775 self.argnames = argnames
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
776 self.defaults = defaults
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
777 self.flags = flags
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
778 self.code = code
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
779 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
780 self.varargs = self.kwargs = None
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
781 if flags & CO_VARARGS:
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
782 self.varargs = 1
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
783 if flags & CO_VARKEYWORDS:
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
784 self.kwargs = 1
36828
1f584164e013 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 36820
diff changeset
785
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
786
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
787
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
788 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
789 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
790 children.append(self.argnames)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
791 children.extend(flatten(self.defaults))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
792 children.append(self.flags)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
793 children.append(self.code)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
794 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
795
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
796 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
797 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
798 nodelist.extend(flatten_nodes(self.defaults))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
799 nodelist.append(self.code)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
800 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
801
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
802 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
803 return "Lambda(%s, %s, %s, %s)" % (repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.code))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
804
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
805 class LeftShift(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
806 def __init__(self, (left, right), lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
807 self.left = left
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
808 self.right = right
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
809 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
810
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
811 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
812 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
813
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
814 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
815 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
816
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
817 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
818 return "LeftShift((%s, %s))" % (repr(self.left), repr(self.right))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
819
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
820 class List(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
821 def __init__(self, nodes, lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
822 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
823 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
824
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
825 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
826 return tuple(flatten(self.nodes))
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
827
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
828 def getChildNodes(self):
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
829 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
830 nodelist.extend(flatten_nodes(self.nodes))
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
831 return tuple(nodelist)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
832
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
833 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
834 return "List(%s)" % (repr(self.nodes),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
835
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
836 class ListComp(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
837 def __init__(self, expr, quals, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
838 self.expr = expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
839 self.quals = quals
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
840 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
841
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
842 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
843 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
844 children.append(self.expr)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
845 children.extend(flatten(self.quals))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
846 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
847
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
848 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
849 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
850 nodelist.append(self.expr)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
851 nodelist.extend(flatten_nodes(self.quals))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
852 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
853
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
854 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
855 return "ListComp(%s, %s)" % (repr(self.expr), repr(self.quals))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
856
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
857 class ListCompFor(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
858 def __init__(self, assign, list, ifs, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
859 self.assign = assign
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
860 self.list = list
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
861 self.ifs = ifs
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
862 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
863
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
864 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
865 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
866 children.append(self.assign)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
867 children.append(self.list)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
868 children.extend(flatten(self.ifs))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
869 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
870
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
871 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
872 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
873 nodelist.append(self.assign)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
874 nodelist.append(self.list)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
875 nodelist.extend(flatten_nodes(self.ifs))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
876 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
877
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
878 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
879 return "ListCompFor(%s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.ifs))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
880
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
881 class ListCompIf(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
882 def __init__(self, test, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
883 self.test = test
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
884 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
885
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
886 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
887 return self.test,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
889 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
890 return self.test,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
891
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
892 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
893 return "ListCompIf(%s)" % (repr(self.test),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
894
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
895 class Mod(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
896 def __init__(self, (left, right), lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
897 self.left = left
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
898 self.right = right
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
899 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
900
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
901 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
902 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
903
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
904 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
905 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
906
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
907 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
908 return "Mod((%s, %s))" % (repr(self.left), repr(self.right))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
909
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
910 class Module(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
911 def __init__(self, doc, node, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
912 self.doc = doc
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
913 self.node = node
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
914 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
915
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
916 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
917 return self.doc, self.node
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
918
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
919 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
920 return self.node,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
921
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
922 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
923 return "Module(%s, %s)" % (repr(self.doc), repr(self.node))
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
924
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
925 class Mul(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
926 def __init__(self, (left, right), lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
927 self.left = left
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
928 self.right = right
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
929 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
930
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
931 def getChildren(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
932 return self.left, self.right
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
933
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
934 def getChildNodes(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
935 return self.left, self.right
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
936
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
937 def __repr__(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
938 return "Mul((%s, %s))" % (repr(self.left), repr(self.right))
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
939
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
940 class Name(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
941 def __init__(self, name, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
942 self.name = name
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
943 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
944
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
945 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
946 return self.name,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
947
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
948 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
949 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
950
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
951 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
952 return "Name(%s)" % (repr(self.name),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
953
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
954 class Not(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
955 def __init__(self, expr, lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
956 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
957 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
958
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
959 def getChildren(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
960 return self.expr,
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
961
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
962 def getChildNodes(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
963 return self.expr,
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
964
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
965 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
966 return "Not(%s)" % (repr(self.expr),)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
967
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
968 class Or(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
969 def __init__(self, nodes, lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
970 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
971 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
972
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
973 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
974 return tuple(flatten(self.nodes))
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
975
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
976 def getChildNodes(self):
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
977 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
978 nodelist.extend(flatten_nodes(self.nodes))
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
979 return tuple(nodelist)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
980
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
981 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
982 return "Or(%s)" % (repr(self.nodes),)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
983
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
984 class Pass(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
985 def __init__(self, lineno=None):
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
986 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
987
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
988 def getChildren(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
989 return ()
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
990
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
991 def getChildNodes(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
992 return ()
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
993
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
994 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
995 return "Pass()"
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
996
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
997 class Power(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
998 def __init__(self, (left, right), lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
999 self.left = left
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1000 self.right = right
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1001 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1002
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1003 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1004 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1005
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1006 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1007 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1008
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1009 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1010 return "Power((%s, %s))" % (repr(self.left), repr(self.right))
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1011
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1012 class Print(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1013 def __init__(self, nodes, dest, lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1014 self.nodes = nodes
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1015 self.dest = dest
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1016 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1017
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1018 def getChildren(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1019 children = []
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1020 children.extend(flatten(self.nodes))
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1021 children.append(self.dest)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1022 return tuple(children)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1023
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1024 def getChildNodes(self):
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1025 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1026 nodelist.extend(flatten_nodes(self.nodes))
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1027 if self.dest is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1028 nodelist.append(self.dest)
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1029 return tuple(nodelist)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1030
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1031 def __repr__(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1032 return "Print(%s, %s)" % (repr(self.nodes), repr(self.dest))
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1033
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1034 class Printnl(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1035 def __init__(self, nodes, dest, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1036 self.nodes = nodes
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1037 self.dest = dest
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1038 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1039
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1040 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1041 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1042 children.extend(flatten(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1043 children.append(self.dest)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1044 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1045
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1046 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1047 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1048 nodelist.extend(flatten_nodes(self.nodes))
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1049 if self.dest is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1050 nodelist.append(self.dest)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1051 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1052
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1053 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1054 return "Printnl(%s, %s)" % (repr(self.nodes), repr(self.dest))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1055
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1056 class Raise(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1057 def __init__(self, expr1, expr2, expr3, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1058 self.expr1 = expr1
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1059 self.expr2 = expr2
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1060 self.expr3 = expr3
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1061 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1062
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1063 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1064 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1065 children.append(self.expr1)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1066 children.append(self.expr2)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1067 children.append(self.expr3)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1068 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1069
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1070 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1071 nodelist = []
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1072 if self.expr1 is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1073 nodelist.append(self.expr1)
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1074 if self.expr2 is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1075 nodelist.append(self.expr2)
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1076 if self.expr3 is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1077 nodelist.append(self.expr3)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1078 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1079
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1080 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1081 return "Raise(%s, %s, %s)" % (repr(self.expr1), repr(self.expr2), repr(self.expr3))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1082
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1083 class Return(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1084 def __init__(self, value, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1085 self.value = value
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1086 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1087
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1088 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1089 return self.value,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1090
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1091 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1092 return self.value,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1093
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1094 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1095 return "Return(%s)" % (repr(self.value),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1096
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1097 class RightShift(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1098 def __init__(self, (left, right), lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1099 self.left = left
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1100 self.right = right
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1101 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1102
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1103 def getChildren(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1104 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1105
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1106 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1107 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1108
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1109 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1110 return "RightShift((%s, %s))" % (repr(self.left), repr(self.right))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1111
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1112 class Slice(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1113 def __init__(self, expr, flags, lower, upper, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1114 self.expr = expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1115 self.flags = flags
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1116 self.lower = lower
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1117 self.upper = upper
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1118 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1119
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1120 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1121 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1122 children.append(self.expr)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1123 children.append(self.flags)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1124 children.append(self.lower)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1125 children.append(self.upper)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1126 return tuple(children)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1127
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1128 def getChildNodes(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1129 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1130 nodelist.append(self.expr)
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1131 if self.lower is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1132 nodelist.append(self.lower)
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1133 if self.upper is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1134 nodelist.append(self.upper)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1135 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1136
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1137 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1138 return "Slice(%s, %s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.lower), repr(self.upper))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1139
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1140 class Sliceobj(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1141 def __init__(self, nodes, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1142 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1143 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1144
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1145 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1146 return tuple(flatten(self.nodes))
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1147
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1148 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1149 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1150 nodelist.extend(flatten_nodes(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1151 return tuple(nodelist)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1152
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1153 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1154 return "Sliceobj(%s)" % (repr(self.nodes),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1155
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1156 class Stmt(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1157 def __init__(self, nodes, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1158 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1159 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1160
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1161 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1162 return tuple(flatten(self.nodes))
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1163
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1164 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1165 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1166 nodelist.extend(flatten_nodes(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1167 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1168
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1169 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1170 return "Stmt(%s)" % (repr(self.nodes),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1171
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1172 class Sub(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1173 def __init__(self, (left, right), lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1174 self.left = left
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1175 self.right = right
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1176 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1177
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1178 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1179 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1180
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1181 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1182 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1183
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1184 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1185 return "Sub((%s, %s))" % (repr(self.left), repr(self.right))
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1186
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1187 class Subscript(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1188 def __init__(self, expr, flags, subs, lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1189 self.expr = expr
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1190 self.flags = flags
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1191 self.subs = subs
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1192 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1193
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1194 def getChildren(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1195 children = []
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1196 children.append(self.expr)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1197 children.append(self.flags)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1198 children.extend(flatten(self.subs))
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1199 return tuple(children)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1200
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1201 def getChildNodes(self):
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1202 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1203 nodelist.append(self.expr)
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1204 nodelist.extend(flatten_nodes(self.subs))
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1205 return tuple(nodelist)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1206
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1207 def __repr__(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1208 return "Subscript(%s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.subs))
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1209
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1210 class TryExcept(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1211 def __init__(self, body, handlers, else_, lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1212 self.body = body
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1213 self.handlers = handlers
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1214 self.else_ = else_
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1215 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1216
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1217 def getChildren(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1218 children = []
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1219 children.append(self.body)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1220 children.extend(flatten(self.handlers))
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1221 children.append(self.else_)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1222 return tuple(children)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1223
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1224 def getChildNodes(self):
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1225 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1226 nodelist.append(self.body)
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1227 nodelist.extend(flatten_nodes(self.handlers))
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1228 if self.else_ is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1229 nodelist.append(self.else_)
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1230 return tuple(nodelist)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1231
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1232 def __repr__(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1233 return "TryExcept(%s, %s, %s)" % (repr(self.body), repr(self.handlers), repr(self.else_))
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1234
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1235 class TryFinally(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1236 def __init__(self, body, final, lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1237 self.body = body
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1238 self.final = final
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1239 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1240
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1241 def getChildren(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1242 return self.body, self.final
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1243
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1244 def getChildNodes(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1245 return self.body, self.final
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1246
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1247 def __repr__(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1248 return "TryFinally(%s, %s)" % (repr(self.body), repr(self.final))
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1249
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1250 class Tuple(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1251 def __init__(self, nodes, lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1252 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1253 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1254
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1255 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1256 return tuple(flatten(self.nodes))
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1257
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1258 def getChildNodes(self):
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1259 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1260 nodelist.extend(flatten_nodes(self.nodes))
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1261 return tuple(nodelist)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1262
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1263 def __repr__(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1264 return "Tuple(%s)" % (repr(self.nodes),)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1265
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1266 class UnaryAdd(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1267 def __init__(self, expr, lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1268 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1269 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1270
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1271 def getChildren(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1272 return self.expr,
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1273
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1274 def getChildNodes(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1275 return self.expr,
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1276
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1277 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1278 return "UnaryAdd(%s)" % (repr(self.expr),)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1279
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1280 class UnarySub(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1281 def __init__(self, expr, lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1282 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1283 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1284
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1285 def getChildren(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1286 return self.expr,
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1287
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1288 def getChildNodes(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1289 return self.expr,
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1290
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1291 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1292 return "UnarySub(%s)" % (repr(self.expr),)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1293
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1294 class While(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1295 def __init__(self, test, body, else_, lineno=None):
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1296 self.test = test
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1297 self.body = body
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1298 self.else_ = else_
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1299 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1300
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1301 def getChildren(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1302 children = []
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1303 children.append(self.test)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1304 children.append(self.body)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1305 children.append(self.else_)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1306 return tuple(children)
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1307
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1308 def getChildNodes(self):
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1309 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1310 nodelist.append(self.test)
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1311 nodelist.append(self.body)
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1312 if self.else_ is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1313 nodelist.append(self.else_)
22010
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1314 return tuple(nodelist)
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1315
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1316 def __repr__(self):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1317 return "While(%s, %s, %s)" % (repr(self.test), repr(self.body), repr(self.else_))
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1318
36695
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1319 class With(Node):
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1320 def __init__(self, expr, vars, body, lineno=None):
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1321 self.expr = expr
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1322 self.vars = vars
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1323 self.body = body
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1324 self.lineno = lineno
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1325
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1326 def getChildren(self):
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1327 children = []
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1328 children.append(self.expr)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1329 children.append(self.vars)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1330 children.append(self.body)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1331 return tuple(children)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1332
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1333 def getChildNodes(self):
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1334 nodelist = []
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1335 nodelist.append(self.expr)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1336 if self.vars is not None:
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1337 nodelist.append(self.vars)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1338 nodelist.append(self.body)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1339 return tuple(nodelist)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1340
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1341 def __repr__(self):
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1342 return "With(%s, %s, %s)" % (repr(self.expr), repr(self.vars), repr(self.body))
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1343
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1344 class Yield(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1345 def __init__(self, value, lineno=None):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1346 self.value = value
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1347 self.lineno = lineno
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1348
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1349 def getChildren(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1350 return self.value,
19945
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1351
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1352 def getChildNodes(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1353 return self.value,
19557
2c2cc31bdf15 Revise implementations of getChildren() and getChildNodes().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19362
diff changeset
1354
15328
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
1355 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1356 return "Yield(%s)" % (repr(self.value),)
32121
302d399cfd37 SF patch #872326: Generator expression implementation
Raymond Hettinger <python@rcn.com>
parents: 30130
diff changeset
1357
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1358 for name, obj in globals().items():
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1359 if isinstance(obj, type) and issubclass(obj, Node):
33463
28ef5fe0b8b5 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 33421
diff changeset
1360 nodes[name.lower()] = obj