| 1 | -- ASDL's 7 builtin types are:
 | 
| 2 | -- identifier, int, string, bytes, object, singleton, constant
 | 
| 3 | --
 | 
| 4 | -- singleton: None, True or False
 | 
| 5 | -- constant can be None, whereas None means "no value" for object.
 | 
| 6 | 
 | 
| 7 | module Python
 | 
| 8 | {
 | 
| 9 |     mod = Module(stmt* body)
 | 
| 10 |         | Interactive(stmt* body)
 | 
| 11 |         | Expression(expr body)
 | 
| 12 | 
 | 
| 13 |         -- not really an actual node but useful in Jython's typesystem.
 | 
| 14 |         | Suite(stmt* body)
 | 
| 15 | 
 | 
| 16 |     stmt = FunctionDef(identifier name, arguments args,
 | 
| 17 |                        stmt* body, expr* decorator_list, expr? returns)
 | 
| 18 |           | AsyncFunctionDef(identifier name, arguments args,
 | 
| 19 |                              stmt* body, expr* decorator_list, expr? returns)
 | 
| 20 | 
 | 
| 21 |           | ClassDef(identifier name,
 | 
| 22 |              expr* bases,
 | 
| 23 |              keyword* keywords,
 | 
| 24 |              stmt* body,
 | 
| 25 |              expr* decorator_list)
 | 
| 26 |           | Return(expr? value)
 | 
| 27 | 
 | 
| 28 |           | Delete(expr* targets)
 | 
| 29 |           | Assign(expr* targets, expr value)
 | 
| 30 |           | AugAssign(expr target, operator op, expr value)
 | 
| 31 |           -- 'simple' indicates that we annotate simple name without parens
 | 
| 32 |           | AnnAssign(expr target, expr annotation, expr? value, int simple)
 | 
| 33 | 
 | 
| 34 |           -- use 'orelse' because else is a keyword in target languages
 | 
| 35 |           | For(expr target, expr iter, stmt* body, stmt* orelse)
 | 
| 36 |           | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse)
 | 
| 37 |           | While(expr test, stmt* body, stmt* orelse)
 | 
| 38 |           | If(expr test, stmt* body, stmt* orelse)
 | 
| 39 |           | With(withitem* items, stmt* body)
 | 
| 40 |           | AsyncWith(withitem* items, stmt* body)
 | 
| 41 | 
 | 
| 42 |           | Raise(expr? exc, expr? cause)
 | 
| 43 |           | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)
 | 
| 44 |           | Assert(expr test, expr? msg)
 | 
| 45 | 
 | 
| 46 |           | Import(alias* names)
 | 
| 47 |           | ImportFrom(identifier? module, alias* names, int? level)
 | 
| 48 | 
 | 
| 49 |           | Global(identifier* names)
 | 
| 50 |           | Nonlocal(identifier* names)
 | 
| 51 |           | Expr(expr value)
 | 
| 52 |           | Pass | Break | Continue
 | 
| 53 | 
 | 
| 54 |           -- XXX Jython will be different
 | 
| 55 |           -- col_offset is the byte offset in the utf8 string the parser uses
 | 
| 56 |           attributes (int lineno, int col_offset)
 | 
| 57 | 
 | 
| 58 |           -- BoolOp() can use left & right?
 | 
| 59 |     expr = BoolOp(boolop op, expr* values)
 | 
| 60 |          | BinOp(expr left, operator op, expr right)
 | 
| 61 |          | UnaryOp(unaryop op, expr operand)
 | 
| 62 |          | Lambda(arguments args, expr body)
 | 
| 63 |          | IfExp(expr test, expr body, expr orelse)
 | 
| 64 |          | Dict(expr* keys, expr* values)
 | 
| 65 |          | Set(expr* elts)
 | 
| 66 |          | ListComp(expr elt, comprehension* generators)
 | 
| 67 |          | SetComp(expr elt, comprehension* generators)
 | 
| 68 |          | DictComp(expr key, expr value, comprehension* generators)
 | 
| 69 |          | GeneratorExp(expr elt, comprehension* generators)
 | 
| 70 |          -- the grammar constrains where yield expressions can occur
 | 
| 71 |          | Await(expr value)
 | 
| 72 |          | Yield(expr? value)
 | 
| 73 |          | YieldFrom(expr value)
 | 
| 74 |          -- need sequences for compare to distinguish between
 | 
| 75 |          -- x < 4 < 3 and (x < 4) < 3
 | 
| 76 |          | Compare(expr left, cmpop* ops, expr* comparators)
 | 
| 77 |          | Call(expr func, expr* args, keyword* keywords)
 | 
| 78 |          | Num(object n) -- a number as a PyObject.
 | 
| 79 |          | Str(string s) -- need to specify raw, unicode, etc?
 | 
| 80 |          | FormattedValue(expr value, int? conversion, expr? format_spec)
 | 
| 81 |          | JoinedStr(expr* values)
 | 
| 82 |          | Bytes(bytes s)
 | 
| 83 |          | NameConstant(singleton value)
 | 
| 84 |          | Ellipsis
 | 
| 85 |          | Constant(constant value)
 | 
| 86 | 
 | 
| 87 |          -- the following expression can appear in assignment context
 | 
| 88 |          | Attribute(expr value, identifier attr, expr_context ctx)
 | 
| 89 |          | Subscript(expr value, slice slice, expr_context ctx)
 | 
| 90 |          | Starred(expr value, expr_context ctx)
 | 
| 91 |          | Name(identifier id, expr_context ctx)
 | 
| 92 |          | List(expr* elts, expr_context ctx)
 | 
| 93 |          | Tuple(expr* elts, expr_context ctx)
 | 
| 94 | 
 | 
| 95 |           -- col_offset is the byte offset in the utf8 string the parser uses
 | 
| 96 |           attributes (int lineno, int col_offset)
 | 
| 97 | 
 | 
| 98 |     expr_context = Load | Store | Del | AugLoad | AugStore | Param
 | 
| 99 | 
 | 
| 100 |     slice = Slice(expr? lower, expr? upper, expr? step)
 | 
| 101 |           | ExtSlice(slice* dims)
 | 
| 102 |           | Index(expr value)
 | 
| 103 | 
 | 
| 104 |     boolop = And | Or
 | 
| 105 | 
 | 
| 106 |     operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift
 | 
| 107 |                  | RShift | BitOr | BitXor | BitAnd | FloorDiv
 | 
| 108 | 
 | 
| 109 |     unaryop = Invert | Not | UAdd | USub
 | 
| 110 | 
 | 
| 111 |     cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn
 | 
| 112 | 
 | 
| 113 |     comprehension = (expr target, expr iter, expr* ifs, int is_async)
 | 
| 114 | 
 | 
| 115 |     excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)
 | 
| 116 |                     attributes (int lineno, int col_offset)
 | 
| 117 | 
 | 
| 118 |     arguments = (arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults,
 | 
| 119 |                  arg? kwarg, expr* defaults)
 | 
| 120 | 
 | 
| 121 |     arg = (identifier arg, expr? annotation)
 | 
| 122 |            attributes (int lineno, int col_offset)
 | 
| 123 | 
 | 
| 124 |     -- keyword arguments supplied to call (NULL identifier for **kwargs)
 | 
| 125 |     keyword = (identifier? arg, expr value)
 | 
| 126 | 
 | 
| 127 |     -- import name with optional 'as' alias.
 | 
| 128 |     alias = (identifier name, identifier? asname)
 | 
| 129 | 
 | 
| 130 |     withitem = (expr context_expr, expr? optional_vars)
 | 
| 131 | }
 | 
| 132 | 
 |