1 -- ASDL's five builtin types are identifier, int, string, object, bool
3 module Python version "$Revision$"
5 mod = Module(stmt* body)
6 | Interactive(stmt* body)
7 | Expression(expr body)
9 -- not really an actual node but useful in Jython's typesystem.
12 stmt = FunctionDef(identifier name, arguments args,
13 stmt* body, expr* decorator_list)
14 | ClassDef(identifier name, expr* bases, stmt* body, expr *decorator_list)
17 | Delete(expr* targets)
18 | Assign(expr* targets, expr value)
19 | AugAssign(expr target, operator op, expr value)
21 -- not sure if bool is allowed, can always use int
22 | Print(expr? dest, expr* values, bool nl)
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)
28 | With(expr context_expr, expr? optional_vars, stmt* body)
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)
36 | Import(alias* names)
37 | ImportFrom(identifier? module, alias* names, int? level)
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)
44 | Global(identifier* names)
46 | Pass | Break | Continue
48 -- XXX Jython will be different
49 -- col_offset is the byte offset in the utf8 string the parser uses
50 attributes (int lineno, int col_offset)
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)
57 | IfExp(expr test, expr body, expr orelse)
58 | Dict(expr* keys, expr* values)
60 | ListComp(expr elt, comprehension* generators)
61 | GeneratorExp(expr elt, comprehension* generators)
62 -- the grammar constrains where yield expressions can occur
64 -- need sequences for compare to distinguish between
65 -- x < 4 < 3 and (x < 4) < 3
66 | Compare(expr left, cmpop* ops, expr* comparators)
67 | Call(expr func, expr* args, keyword* keywords,
68 expr? starargs, expr? kwargs)
70 | Num(object n) -- a number as a PyObject.
71 | Str(string s) -- need to specify raw, unicode, etc?
72 -- other literals? bools?
74 -- the following expression can appear in assignment context
75 | Attribute(expr value, identifier attr, expr_context ctx)
76 | Subscript(expr value, slice slice, expr_context ctx)
77 | Name(identifier id, expr_context ctx)
78 | List(expr* elts, expr_context ctx)
79 | Tuple(expr* elts, expr_context ctx)
81 -- col_offset is the byte offset in the utf8 string the parser uses
82 attributes (int lineno, int col_offset)
84 expr_context = Load | Store | Del | AugLoad | AugStore | Param
86 slice = Ellipsis | Slice(expr? lower, expr? upper, expr? step)
87 | ExtSlice(slice* dims)
92 operator = Add | Sub | Mult | Div | Mod | Pow | LShift
93 | RShift | BitOr | BitXor | BitAnd | FloorDiv
95 unaryop = Invert | Not | UAdd | USub
97 cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn
99 comprehension = (expr target, expr iter, expr* ifs)
101 -- not sure what to call the first argument for raise and except
102 excepthandler = ExceptHandler(expr? type, expr? name, stmt* body)
103 attributes (int lineno, int col_offset)
105 arguments = (expr* args, identifier? vararg,
106 identifier? kwarg, expr* defaults)
108 -- keyword arguments supplied to call
109 keyword = (identifier arg, expr value)
111 -- import name with optional 'as' alias.
112 alias = (identifier name, identifier? asname)