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