annotate Lib/compiler/ast.py @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents edfed0e32ced
children
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):
63528
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
54 def __init__(self, leftright, lineno=None):
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
55 self.left = leftright[0]
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
56 self.right = leftright[1]
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):
63528
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
434 def __init__(self, leftright, lineno=None):
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
435 self.left = leftright[0]
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
436 self.right = leftright[1]
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):
63528
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
488 def __init__(self, leftright, lineno=None):
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
489 self.left = leftright[0]
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
490 self.right = leftright[1]
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 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
564 children = []
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
565 children.append(self.decorators)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
566 children.append(self.name)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
567 children.append(self.argnames)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
568 children.extend(flatten(self.defaults))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
569 children.append(self.flags)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
570 children.append(self.doc)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
571 children.append(self.code)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
572 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
573
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
574 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
575 nodelist = []
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
576 if self.decorators is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
577 nodelist.append(self.decorators)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
578 nodelist.extend(flatten_nodes(self.defaults))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
579 nodelist.append(self.code)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
580 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
581
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
582 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
583 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
584
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
585 class GenExpr(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
586 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
587 self.code = code
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
588 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
589 self.argnames = ['.0']
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
590 self.varargs = self.kwargs = None
36828
1f584164e013 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 36820
diff changeset
591
63528
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
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 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
611 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
612 children.append(self.assign)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
613 children.append(self.iter)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
614 children.extend(flatten(self.ifs))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
615 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
616
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
617 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
618 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
619 nodelist.append(self.assign)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
620 nodelist.append(self.iter)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
621 nodelist.extend(flatten_nodes(self.ifs))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
622 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
623
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
624 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
625 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
626
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
627 class GenExprIf(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
628 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
629 self.test = test
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
630 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
631
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
632 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
633 return self.test,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
634
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
635 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
636 return self.test,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
637
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
638 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
639 return "GenExprIf(%s)" % (repr(self.test),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
640
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
641 class GenExprInner(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
642 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
643 self.expr = expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
644 self.quals = quals
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
645 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
646
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
647 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
648 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
649 children.append(self.expr)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
650 children.extend(flatten(self.quals))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
651 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
652
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
653 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
654 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
655 nodelist.append(self.expr)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
656 nodelist.extend(flatten_nodes(self.quals))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
657 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
658
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
659 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
660 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
661
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
662 class Getattr(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
663 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
664 self.expr = expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
665 self.attrname = attrname
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
666 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
667
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
668 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
669 return self.expr, self.attrname
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
670
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
671 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
672 return self.expr,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
673
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
674 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
675 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
676
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
677 class Global(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
678 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
679 self.names = names
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
680 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
681
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
682 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
683 return self.names,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
684
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
685 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
686 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
687
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
688 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
689 return "Global(%s)" % (repr(self.names),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
690
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
691 class If(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
692 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
693 self.tests = tests
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
694 self.else_ = else_
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
695 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
696
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
697 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
698 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
699 children.extend(flatten(self.tests))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
700 children.append(self.else_)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
701 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
702
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
703 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
704 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
705 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
706 if self.else_ is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
707 nodelist.append(self.else_)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
708 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
709
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
710 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
711 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
712
36820
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
713 class IfExp(Node):
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
714 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
715 self.test = test
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
716 self.then = then
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
717 self.else_ = else_
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
718 self.lineno = lineno
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
719
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
720 def getChildren(self):
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
721 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
722
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
723 def getChildNodes(self):
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
724 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
725
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
726 def __repr__(self):
c1c46210b4b7 Add support for absolute/relative imports and if/else expressions:
Thomas Wouters <thomas@python.org>
parents: 36721
diff changeset
727 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
728
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
729 class Import(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
730 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
731 self.names = names
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
732 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
733
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
734 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
735 return self.names,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
736
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
737 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
738 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
739
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
740 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
741 return "Import(%s)" % (repr(self.names),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
742
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
743 class Invert(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
744 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
745 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
746 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
747
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
748 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
749 return self.expr,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
750
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
751 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
752 return self.expr,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
753
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
754 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
755 return "Invert(%s)" % (repr(self.expr),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
756
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
757 class Keyword(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
758 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
759 self.name = name
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
760 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
761 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
762
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
763 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
764 return self.name, self.expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
765
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
766 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
767 return self.expr,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
768
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
769 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
770 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
771
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
772 class Lambda(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
773 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
774 self.argnames = argnames
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
775 self.defaults = defaults
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
776 self.flags = flags
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
777 self.code = code
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
778 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
779 self.varargs = self.kwargs = None
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
780 if flags & CO_VARARGS:
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
781 self.varargs = 1
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
782 if flags & CO_VARKEYWORDS:
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
783 self.kwargs = 1
36828
1f584164e013 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 36820
diff changeset
784
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
785
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
786 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
787 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
788 children.append(self.argnames)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
789 children.extend(flatten(self.defaults))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
790 children.append(self.flags)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
791 children.append(self.code)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
792 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
793
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
794 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
795 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
796 nodelist.extend(flatten_nodes(self.defaults))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
797 nodelist.append(self.code)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
798 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
799
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
800 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
801 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
802
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
803 class LeftShift(Node):
63528
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
804 def __init__(self, leftright, lineno=None):
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
805 self.left = leftright[0]
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
806 self.right = leftright[1]
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
807 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
808
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
809 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
810 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
811
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
812 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
813 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
814
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
815 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
816 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
817
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
818 class List(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
819 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
820 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
821 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
822
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
823 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
824 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
825
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
826 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
827 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
828 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
829 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
830
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
831 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
832 return "List(%s)" % (repr(self.nodes),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
833
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
834 class ListComp(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
835 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
836 self.expr = expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
837 self.quals = quals
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
838 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
839
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
840 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
841 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
842 children.append(self.expr)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
843 children.extend(flatten(self.quals))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
844 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
845
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
846 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
847 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
848 nodelist.append(self.expr)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
849 nodelist.extend(flatten_nodes(self.quals))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
850 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
851
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
852 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
853 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
854
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
855 class ListCompFor(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
856 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
857 self.assign = assign
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
858 self.list = list
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
859 self.ifs = ifs
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
860 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
861
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
862 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
863 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
864 children.append(self.assign)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
865 children.append(self.list)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
866 children.extend(flatten(self.ifs))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
867 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
868
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
869 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
870 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
871 nodelist.append(self.assign)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
872 nodelist.append(self.list)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
873 nodelist.extend(flatten_nodes(self.ifs))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
874 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
875
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
876 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
877 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
878
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
879 class ListCompIf(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
880 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
881 self.test = test
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
882 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
883
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
884 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
885 return self.test,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
886
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
887 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
888 return self.test,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
889
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
890 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
891 return "ListCompIf(%s)" % (repr(self.test),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
892
58250
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
893 class SetComp(Node):
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
894 def __init__(self, expr, quals, lineno=None):
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
895 self.expr = expr
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
896 self.quals = quals
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
897 self.lineno = lineno
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
898
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
899 def getChildren(self):
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
900 children = []
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
901 children.append(self.expr)
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
902 children.extend(flatten(self.quals))
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
903 return tuple(children)
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
904
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
905 def getChildNodes(self):
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
906 nodelist = []
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
907 nodelist.append(self.expr)
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
908 nodelist.extend(flatten_nodes(self.quals))
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
909 return tuple(nodelist)
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
910
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
911 def __repr__(self):
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
912 return "SetComp(%s, %s)" % (repr(self.expr), repr(self.quals))
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
913
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
914 class DictComp(Node):
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
915 def __init__(self, key, value, quals, lineno=None):
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
916 self.key = key
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
917 self.value = value
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
918 self.quals = quals
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
919 self.lineno = lineno
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
920
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
921 def getChildren(self):
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
922 children = []
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
923 children.append(self.key)
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
924 children.append(self.value)
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
925 children.extend(flatten(self.quals))
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
926 return tuple(children)
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
927
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
928 def getChildNodes(self):
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
929 nodelist = []
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
930 nodelist.append(self.key)
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
931 nodelist.append(self.value)
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
932 nodelist.extend(flatten_nodes(self.quals))
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
933 return tuple(nodelist)
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
934
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
935 def __repr__(self):
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
936 return "DictComp(%s, %s, %s)" % (repr(self.key), repr(self.value), repr(self.quals))
edfed0e32ced Issue #2333: Backport set and dict comprehensions syntax.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 58229
diff changeset
937
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
938 class Mod(Node):
63528
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
939 def __init__(self, leftright, lineno=None):
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
940 self.left = leftright[0]
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
941 self.right = leftright[1]
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
942 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
943
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
944 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
945 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
946
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
947 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
948 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
949
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
950 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
951 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
952
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
953 class Module(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
954 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
955 self.doc = doc
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
956 self.node = node
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
957 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
958
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
959 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
960 return self.doc, self.node
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
961
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
962 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
963 return self.node,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
964
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
965 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
966 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
967
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
968 class Mul(Node):
63528
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
969 def __init__(self, leftright, lineno=None):
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
970 self.left = leftright[0]
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
971 self.right = leftright[1]
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
972 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
973
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
974 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
975 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
976
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
977 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
978 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
979
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
980 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
981 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
982
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
983 class Name(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
984 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
985 self.name = name
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
986 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
987
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
988 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
989 return self.name,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
990
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
991 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
992 return ()
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
993
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
994 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
995 return "Name(%s)" % (repr(self.name),)
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 Not(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
998 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
999 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1000 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
1001
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1002 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
1003 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
1004
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1005 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
1006 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
1007
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1008 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1009 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
1010
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1011 class Or(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1012 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
1013 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1014 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
1015
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1016 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1017 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
1018
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1019 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
1020 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1021 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
1022 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
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 __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1025 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
1026
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1027 class Pass(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1028 def __init__(self, lineno=None):
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1029 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
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 getChildren(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 ()
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1033
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1034 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
1035 return ()
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1036
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1037 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1038 return "Pass()"
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 class Power(Node):
63528
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
1041 def __init__(self, leftright, lineno=None):
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
1042 self.left = leftright[0]
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
1043 self.right = leftright[1]
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1044 self.lineno = lineno
32888
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 getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1047 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1048
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1049 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1050 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1051
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1052 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1053 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
1054
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1055 class Print(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1056 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
1057 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
1058 self.dest = dest
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1059 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
1060
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1061 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
1062 children = []
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1063 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
1064 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
1065 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
1066
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1067 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
1068 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1069 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
1070 if self.dest is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1071 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
1072 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
1073
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1074 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
1075 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
1076
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1077 class Printnl(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1078 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
1079 self.nodes = nodes
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1080 self.dest = dest
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1081 self.lineno = lineno
32888
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 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1084 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1085 children.extend(flatten(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1086 children.append(self.dest)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1087 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1088
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1089 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1090 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1091 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
1092 if self.dest is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1093 nodelist.append(self.dest)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1094 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1095
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1096 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1097 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
1098
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1099 class Raise(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1100 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
1101 self.expr1 = expr1
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1102 self.expr2 = expr2
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1103 self.expr3 = expr3
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1104 self.lineno = lineno
32888
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 getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1107 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1108 children.append(self.expr1)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1109 children.append(self.expr2)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1110 children.append(self.expr3)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1111 return tuple(children)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1112
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1113 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1114 nodelist = []
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1115 if self.expr1 is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1116 nodelist.append(self.expr1)
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1117 if self.expr2 is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1118 nodelist.append(self.expr2)
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1119 if self.expr3 is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1120 nodelist.append(self.expr3)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1121 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1122
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1123 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1124 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
1125
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1126 class Return(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1127 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
1128 self.value = value
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1129 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1130
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1131 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1132 return self.value,
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1133
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1134 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1135 return self.value,
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 "Return(%s)" % (repr(self.value),)
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 RightShift(Node):
63528
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
1141 def __init__(self, leftright, lineno=None):
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
1142 self.left = leftright[0]
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
1143 self.right = leftright[1]
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1144 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
1145
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1146 def getChildren(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1147 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1148
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1149 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1150 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1151
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1152 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1153 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
1154
58229
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1155 class Set(Node):
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1156 def __init__(self, nodes, lineno=None):
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1157 self.nodes = nodes
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1158 self.lineno = lineno
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1159
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1160 def getChildren(self):
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1161 return tuple(flatten(self.nodes))
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1162
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1163 def getChildNodes(self):
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1164 nodelist = []
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1165 nodelist.extend(flatten_nodes(self.nodes))
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1166 return tuple(nodelist)
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1167
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1168 def __repr__(self):
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1169 return "Set(%s)" % (repr(self.nodes),)
c2fdf25329ff Issue #2335: Backport set literals syntax from Python 3.x.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 63528
diff changeset
1170
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1171 class Slice(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1172 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
1173 self.expr = expr
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1174 self.flags = flags
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1175 self.lower = lower
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1176 self.upper = upper
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1177 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1178
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1179 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1180 children = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1181 children.append(self.expr)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1182 children.append(self.flags)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1183 children.append(self.lower)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1184 children.append(self.upper)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1185 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
1186
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1187 def getChildNodes(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1188 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1189 nodelist.append(self.expr)
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1190 if self.lower is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1191 nodelist.append(self.lower)
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1192 if self.upper is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1193 nodelist.append(self.upper)
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1194 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1195
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1196 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1197 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
1198
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1199 class Sliceobj(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1200 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
1201 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1202 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1203
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1204 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1205 return tuple(flatten(self.nodes))
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1206
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1207 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1208 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1209 nodelist.extend(flatten_nodes(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1210 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
1211
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1212 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1213 return "Sliceobj(%s)" % (repr(self.nodes),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1214
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1215 class Stmt(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1216 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
1217 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1218 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1219
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1220 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1221 return tuple(flatten(self.nodes))
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1222
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1223 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1224 nodelist = []
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1225 nodelist.extend(flatten_nodes(self.nodes))
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1226 return tuple(nodelist)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1227
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1228 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1229 return "Stmt(%s)" % (repr(self.nodes),)
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1230
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1231 class Sub(Node):
63528
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
1232 def __init__(self, leftright, lineno=None):
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
1233 self.left = leftright[0]
751c6dd71b5e Merged revisions 77310-77311 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 45520
diff changeset
1234 self.right = leftright[1]
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1235 self.lineno = lineno
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1236
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1237 def getChildren(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1238 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1239
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1240 def getChildNodes(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1241 return self.left, self.right
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1242
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1243 def __repr__(self):
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1244 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
1245
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1246 class Subscript(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1247 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
1248 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
1249 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
1250 self.subs = subs
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1251 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
1252
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1253 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
1254 children = []
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1255 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
1256 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
1257 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
1258 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
1259
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1260 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
1261 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1262 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
1263 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
1264 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
1265
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1266 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
1267 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
1268
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1269 class TryExcept(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1270 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
1271 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
1272 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
1273 self.else_ = else_
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1274 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
1275
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1276 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
1277 children = []
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1278 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
1279 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
1280 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
1281 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
1282
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1283 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
1284 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1285 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
1286 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
1287 if self.else_ is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1288 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
1289 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
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):
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1292 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
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 TryFinally(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1295 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
1296 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
1297 self.final = final
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1298 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
1299
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1300 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
1301 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
1302
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1303 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
1304 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
1305
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1306 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
1307 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
1308
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1309 class Tuple(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1310 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
1311 self.nodes = nodes
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1312 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
1313
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1314 def getChildren(self):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1315 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
1316
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1317 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
1318 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1319 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
1320 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
1321
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1322 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
1323 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
1324
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1325 class UnaryAdd(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1326 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
1327 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1328 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
1329
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1330 def getChildren(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1331 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
1332
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1333 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
1334 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
1335
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1336 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1337 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
1338
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1339 class UnarySub(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1340 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
1341 self.expr = expr
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1342 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
1343
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1344 def getChildren(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1345 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
1346
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1347 def getChildNodes(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1348 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
1349
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1350 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1351 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
1352
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1353 class While(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1354 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
1355 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
1356 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
1357 self.else_ = else_
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1358 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
1359
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1360 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
1361 children = []
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1362 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
1363 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
1364 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
1365 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
1366
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1367 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
1368 nodelist = []
82fb0f99e2da Patch #521714: fix pychecker warnings in ast.py.
Martin v. Löwis <martin@v.loewis.de>
parents: 21522
diff changeset
1369 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
1370 nodelist.append(self.body)
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1371 if self.else_ is not None:
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1372 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
1373 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
1374
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1375 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
1376 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
1377
36695
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1378 class With(Node):
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1379 def __init__(self, expr, vars, body, lineno=None):
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1380 self.expr = expr
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1381 self.vars = vars
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1382 self.body = body
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1383 self.lineno = lineno
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1384
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1385 def getChildren(self):
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1386 children = []
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1387 children.append(self.expr)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1388 children.append(self.vars)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1389 children.append(self.body)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1390 return tuple(children)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1391
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1392 def getChildNodes(self):
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1393 nodelist = []
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1394 nodelist.append(self.expr)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1395 if self.vars is not None:
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1396 nodelist.append(self.vars)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1397 nodelist.append(self.body)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1398 return tuple(nodelist)
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1399
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1400 def __repr__(self):
b6d2f6fd3e11 PEP 343 -- the with-statement.
Guido van Rossum <guido@python.org>
parents: 34989
diff changeset
1401 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
1402
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1403 class Yield(Node):
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1404 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
1405 self.value = value
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1406 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
1407
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1408 def getChildren(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1409 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
1410
be4baafa4c52 Re-created after change to astgen to calculate hardest_arg correctly
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19917
diff changeset
1411 def getChildNodes(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1412 return self.value,
19557
2c2cc31bdf15 Revise implementations of getChildren() and getChildNodes().
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 19362
diff changeset
1413
15328
0d63c0ca7ae4 Generated from rev 1.1 of ast.txt
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 15205
diff changeset
1414 def __repr__(self):
32888
c7e03cf8333e PEP-0318, @decorator-style. In Guido's words:
Anthony Baxter <anthonybaxter@gmail.com>
parents: 32121
diff changeset
1415 return "Yield(%s)" % (repr(self.value),)
32121
302d399cfd37 SF patch #872326: Generator expression implementation
Raymond Hettinger <python@rcn.com>
parents: 30130
diff changeset
1416
33421
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1417 for name, obj in globals().items():
b6e875aa508b compiler.transformer: correct lineno attribute when possible
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 32949
diff changeset
1418 if isinstance(obj, type) and issubclass(obj, Node):
33463
28ef5fe0b8b5 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 33421
diff changeset
1419 nodes[name.lower()] = obj