| Neal Norwitz | 19b0f40 | 2005-11-15 04:52:16 +0000 | [diff] [blame] | 1 | -- ASDL's five builtin types are identifier, int, string, object, bool | 
| Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 2 |  | 
| Martin v. Löwis | eae93b7 | 2006-02-28 00:12:47 +0000 | [diff] [blame] | 3 | module Python version "$Revision$" | 
| Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 4 | { | 
|  | 5 | mod = Module(stmt* body) | 
|  | 6 | | Interactive(stmt* body) | 
|  | 7 | | Expression(expr body) | 
|  | 8 |  | 
|  | 9 | -- not really an actual node but useful in Jython's typesystem. | 
|  | 10 | | Suite(stmt* body) | 
|  | 11 |  | 
|  | 12 | stmt = FunctionDef(identifier name, arguments args, | 
| Christian Heimes | 5224d28 | 2008-02-23 15:01:05 +0000 | [diff] [blame] | 13 | stmt* body, expr* decorator_list) | 
| Benjamin Peterson | c009735 | 2010-06-22 19:45:51 +0000 | [diff] [blame] | 14 | | ClassDef(identifier name, expr* bases, stmt* body, expr* decorator_list) | 
| Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 15 | | Return(expr? value) | 
|  | 16 |  | 
|  | 17 | | Delete(expr* targets) | 
|  | 18 | | Assign(expr* targets, expr value) | 
|  | 19 | | AugAssign(expr target, operator op, expr value) | 
|  | 20 |  | 
|  | 21 | -- not sure if bool is allowed, can always use int | 
|  | 22 | | Print(expr? dest, expr* values, bool nl) | 
|  | 23 |  | 
|  | 24 | -- use 'orelse' because else is a keyword in target languages | 
|  | 25 | | For(expr target, expr iter, stmt* body, stmt* orelse) | 
|  | 26 | | While(expr test, stmt* body, stmt* orelse) | 
|  | 27 | | If(expr test, stmt* body, stmt* orelse) | 
| Guido van Rossum | c2e2074 | 2006-02-27 22:32:47 +0000 | [diff] [blame] | 28 | | With(expr context_expr, expr? optional_vars, stmt* body) | 
| Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 29 |  | 
|  | 30 | -- 'type' is a bad name | 
|  | 31 | | Raise(expr? type, expr? inst, expr? tback) | 
|  | 32 | | TryExcept(stmt* body, excepthandler* handlers, stmt* orelse) | 
|  | 33 | | TryFinally(stmt* body, stmt* finalbody) | 
|  | 34 | | Assert(expr test, expr? msg) | 
|  | 35 |  | 
|  | 36 | | Import(alias* names) | 
| Benjamin Peterson | a72be3b | 2009-06-13 20:23:33 +0000 | [diff] [blame] | 37 | | ImportFrom(identifier? module, alias* names, int? level) | 
| Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 38 |  | 
|  | 39 | -- Doesn't capture requirement that locals must be | 
|  | 40 | -- defined if globals is | 
|  | 41 | -- still supports use as a function! | 
|  | 42 | | Exec(expr body, expr? globals, expr? locals) | 
|  | 43 |  | 
|  | 44 | | Global(identifier* names) | 
|  | 45 | | Expr(expr value) | 
|  | 46 | | Pass | Break | Continue | 
|  | 47 |  | 
|  | 48 | -- XXX Jython will be different | 
| Martin v. Löwis | 49c5da1 | 2006-03-01 22:49:05 +0000 | [diff] [blame] | 49 | -- col_offset is the byte offset in the utf8 string the parser uses | 
|  | 50 | attributes (int lineno, int col_offset) | 
| Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 51 |  | 
|  | 52 | -- BoolOp() can use left & right? | 
|  | 53 | expr = BoolOp(boolop op, expr* values) | 
|  | 54 | | BinOp(expr left, operator op, expr right) | 
|  | 55 | | UnaryOp(unaryop op, expr operand) | 
|  | 56 | | Lambda(arguments args, expr body) | 
| Thomas Wouters | dca3b9c | 2006-02-27 00:24:13 +0000 | [diff] [blame] | 57 | | IfExp(expr test, expr body, expr orelse) | 
| Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 58 | | Dict(expr* keys, expr* values) | 
| Alexandre Vassalotti | ee936a2 | 2010-01-09 23:35:54 +0000 | [diff] [blame] | 59 | | Set(expr* elts) | 
| Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 60 | | ListComp(expr elt, comprehension* generators) | 
| Alexandre Vassalotti | b646547 | 2010-01-11 22:36:12 +0000 | [diff] [blame] | 61 | | SetComp(expr elt, comprehension* generators) | 
|  | 62 | | DictComp(expr key, expr value, comprehension* generators) | 
| Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 63 | | GeneratorExp(expr elt, comprehension* generators) | 
| Jeremy Hylton | c960f26 | 2006-01-27 15:18:39 +0000 | [diff] [blame] | 64 | -- the grammar constrains where yield expressions can occur | 
| Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 65 | | Yield(expr? value) | 
|  | 66 | -- need sequences for compare to distinguish between | 
|  | 67 | -- x < 4 < 3 and (x < 4) < 3 | 
|  | 68 | | Compare(expr left, cmpop* ops, expr* comparators) | 
|  | 69 | | Call(expr func, expr* args, keyword* keywords, | 
|  | 70 | expr? starargs, expr? kwargs) | 
|  | 71 | | Repr(expr value) | 
|  | 72 | | Num(object n) -- a number as a PyObject. | 
|  | 73 | | Str(string s) -- need to specify raw, unicode, etc? | 
|  | 74 | -- other literals? bools? | 
|  | 75 |  | 
|  | 76 | -- the following expression can appear in assignment context | 
|  | 77 | | Attribute(expr value, identifier attr, expr_context ctx) | 
|  | 78 | | Subscript(expr value, slice slice, expr_context ctx) | 
|  | 79 | | Name(identifier id, expr_context ctx) | 
|  | 80 | | List(expr* elts, expr_context ctx) | 
| Brett Cannon | 1fbe3ab | 2007-02-11 05:36:00 +0000 | [diff] [blame] | 81 | | Tuple(expr* elts, expr_context ctx) | 
| Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 82 |  | 
| Martin v. Löwis | 49c5da1 | 2006-03-01 22:49:05 +0000 | [diff] [blame] | 83 | -- col_offset is the byte offset in the utf8 string the parser uses | 
|  | 84 | attributes (int lineno, int col_offset) | 
| Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 85 |  | 
|  | 86 | expr_context = Load | Store | Del | AugLoad | AugStore | Param | 
|  | 87 |  | 
|  | 88 | slice = Ellipsis | Slice(expr? lower, expr? upper, expr? step) | 
|  | 89 | | ExtSlice(slice* dims) | 
|  | 90 | | Index(expr value) | 
|  | 91 |  | 
|  | 92 | boolop = And | Or | 
|  | 93 |  | 
|  | 94 | operator = Add | Sub | Mult | Div | Mod | Pow | LShift | 
|  | 95 | | RShift | BitOr | BitXor | BitAnd | FloorDiv | 
|  | 96 |  | 
|  | 97 | unaryop = Invert | Not | UAdd | USub | 
|  | 98 |  | 
|  | 99 | cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn | 
|  | 100 |  | 
|  | 101 | comprehension = (expr target, expr iter, expr* ifs) | 
|  | 102 |  | 
|  | 103 | -- not sure what to call the first argument for raise and except | 
| Georg Brandl | a48f3ab | 2008-03-30 06:40:17 +0000 | [diff] [blame] | 104 | excepthandler = ExceptHandler(expr? type, expr? name, stmt* body) | 
|  | 105 | attributes (int lineno, int col_offset) | 
| Jeremy Hylton | 3e0055f | 2005-10-20 19:59:25 +0000 | [diff] [blame] | 106 |  | 
|  | 107 | arguments = (expr* args, identifier? vararg, | 
|  | 108 | identifier? kwarg, expr* defaults) | 
|  | 109 |  | 
|  | 110 | -- keyword arguments supplied to call | 
|  | 111 | keyword = (identifier arg, expr value) | 
|  | 112 |  | 
|  | 113 | -- import name with optional 'as' alias. | 
|  | 114 | alias = (identifier name, identifier? asname) | 
|  | 115 | } |