Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 1 | # This file describes the nodes of the AST in ast.py. The module is |
| 2 | # generated by astgen.py. |
| 3 | # The descriptions use the following special notation to describe |
| 4 | # properties of the children: |
| 5 | # * this child is not a node |
| 6 | # ! this child is a sequence that contains nodes in it |
| 7 | # & this child may be set to None |
| 8 | # = ... a default value for the node constructor (optional args) |
Andrew M. Kuchling | a6d4b68 | 2005-11-22 15:01:13 +0000 | [diff] [blame] | 9 | # |
| 10 | # If you add node types here, please be sure to update the list of |
| 11 | # Node types in Doc/lib/asttable.tex. |
Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 12 | Module: doc*, node |
| 13 | Stmt: nodes! |
Anthony Baxter | c2a5a63 | 2004-08-02 06:10:11 +0000 | [diff] [blame] | 14 | Decorators: nodes! |
Neal Norwitz | c150536 | 2006-12-28 06:47:50 +0000 | [diff] [blame] | 15 | Function: decorators&, name*, arguments!, defaults!, kwonlyargs!, returns&, flags*, doc*, code |
| 16 | Lambda: arguments!, defaults!, kwonlyargs!, flags*, code |
| 17 | SimpleArg: name*, annotation& |
| 18 | NestedArgs: args! |
| 19 | Kwarg: arg, expr |
Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 20 | Class: name*, bases!, doc*, code |
Jeremy Hylton | 821eee3 | 2000-10-25 17:59:17 +0000 | [diff] [blame] | 21 | Pass: |
| 22 | Break: |
| 23 | Continue: |
Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 24 | For: assign, list, body, else_& |
| 25 | While: test, body, else_& |
Guido van Rossum | c2e2074 | 2006-02-27 22:32:47 +0000 | [diff] [blame] | 26 | With: expr, vars&, body |
Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 27 | If: tests!, else_& |
Thomas Wouters | 7e2ac25 | 2006-03-03 18:11:37 +0000 | [diff] [blame] | 28 | IfExp: test, then, else_ |
Thomas Wouters | 7e2ac25 | 2006-03-03 18:11:37 +0000 | [diff] [blame] | 29 | From: modname*, names*, level* |
Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 30 | Import: names* |
| 31 | Raise: expr1&, expr2&, expr3& |
Jeremy Hylton | 821eee3 | 2000-10-25 17:59:17 +0000 | [diff] [blame] | 32 | TryFinally: body, final |
Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 33 | TryExcept: body, handlers!, else_& |
Jeremy Hylton | 821eee3 | 2000-10-25 17:59:17 +0000 | [diff] [blame] | 34 | Return: value |
Jeremy Hylton | 34aeeff | 2001-08-14 18:57:43 +0000 | [diff] [blame] | 35 | Yield: value |
Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 36 | Const: value* |
| 37 | Print: nodes!, dest& |
| 38 | Printnl: nodes!, dest& |
Jeremy Hylton | 821eee3 | 2000-10-25 17:59:17 +0000 | [diff] [blame] | 39 | Discard: expr |
Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 40 | AugAssign: node, op*, expr |
| 41 | Assign: nodes!, expr |
| 42 | AssTuple: nodes! |
| 43 | AssList: nodes! |
| 44 | AssName: name*, flags* |
| 45 | AssAttr: expr, attrname*, flags* |
| 46 | ListComp: expr, quals! |
| 47 | ListCompFor: assign, list, ifs! |
Jeremy Hylton | 821eee3 | 2000-10-25 17:59:17 +0000 | [diff] [blame] | 48 | ListCompIf: test |
Guido van Rossum | c2e2074 | 2006-02-27 22:32:47 +0000 | [diff] [blame] | 49 | GenExpr: code |
Raymond Hettinger | 354433a | 2004-05-19 08:20:33 +0000 | [diff] [blame] | 50 | GenExprInner: expr, quals! |
| 51 | GenExprFor: assign, iter, ifs! |
| 52 | GenExprIf: test |
Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 53 | List: nodes! |
| 54 | Dict: items! |
Guido van Rossum | 86e58e2 | 2006-08-28 15:27:34 +0000 | [diff] [blame] | 55 | Set: items! |
Jeremy Hylton | 821eee3 | 2000-10-25 17:59:17 +0000 | [diff] [blame] | 56 | Not: expr |
Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 57 | Compare: expr, ops! |
| 58 | Name: name* |
Jeremy Hylton | fff252d | 2001-09-14 22:40:36 +0000 | [diff] [blame] | 59 | Global: names* |
Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 60 | Getattr: expr, attrname* |
| 61 | CallFunc: node, args!, star_args& = None, dstar_args& = None |
| 62 | Keyword: name*, expr |
| 63 | Subscript: expr, flags*, subs! |
Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 64 | Sliceobj: nodes! |
| 65 | Slice: expr, flags*, lower&, upper& |
| 66 | Assert: test, fail& |
| 67 | Tuple: nodes! |
| 68 | Or: nodes! |
| 69 | And: nodes! |
| 70 | Bitor: nodes! |
| 71 | Bitxor: nodes! |
| 72 | Bitand: nodes! |
Jeremy Hylton | 821eee3 | 2000-10-25 17:59:17 +0000 | [diff] [blame] | 73 | LeftShift: (left, right) |
| 74 | RightShift: (left, right) |
| 75 | Add: (left, right) |
| 76 | Sub: (left, right) |
| 77 | Mul: (left, right) |
| 78 | Div: (left, right) |
| 79 | Mod: (left, right) |
| 80 | Power: (left, right) |
Jeremy Hylton | 5477f52 | 2001-08-29 18:08:02 +0000 | [diff] [blame] | 81 | FloorDiv: (left, right) |
Jeremy Hylton | 821eee3 | 2000-10-25 17:59:17 +0000 | [diff] [blame] | 82 | UnaryAdd: expr |
| 83 | UnarySub: expr |
| 84 | Invert: expr |
| 85 | |
| 86 | init(Function): |
| 87 | self.varargs = self.kwargs = None |
| 88 | if flags & CO_VARARGS: |
| 89 | self.varargs = 1 |
| 90 | if flags & CO_VARKEYWORDS: |
| 91 | self.kwargs = 1 |
| 92 | |
| 93 | init(Lambda): |
| 94 | self.varargs = self.kwargs = None |
| 95 | if flags & CO_VARARGS: |
| 96 | self.varargs = 1 |
| 97 | if flags & CO_VARKEYWORDS: |
| 98 | self.kwargs = 1 |
Neal Norwitz | c150536 | 2006-12-28 06:47:50 +0000 | [diff] [blame] | 99 | self.returns = None |
Raymond Hettinger | 354433a | 2004-05-19 08:20:33 +0000 | [diff] [blame] | 100 | |
| 101 | init(GenExpr): |
Neal Norwitz | c150536 | 2006-12-28 06:47:50 +0000 | [diff] [blame] | 102 | self.arguments = [SimpleArg('.0', None)] |
Raymond Hettinger | 354433a | 2004-05-19 08:20:33 +0000 | [diff] [blame] | 103 | self.varargs = self.kwargs = None |
Guido van Rossum | 4f72a78 | 2006-10-27 23:31:49 +0000 | [diff] [blame] | 104 | self.kwonlyargs = () |
Raymond Hettinger | 354433a | 2004-05-19 08:20:33 +0000 | [diff] [blame] | 105 | |
| 106 | init(GenExprFor): |
| 107 | self.is_outmost = False |