blob: a159edbdca360b9148c6422564f8f09988160929 [file] [log] [blame]
Neal Norwitz897ff812005-12-11 21:18:22 +00001/* File automatically generated by Parser/asdl_c.py */
Jeremy Hylton3e0055f2005-10-20 19:59:25 +00002
3#include "asdl.h"
4
5typedef struct _mod *mod_ty;
6
7typedef struct _stmt *stmt_ty;
8
9typedef struct _expr *expr_ty;
10
11typedef enum _expr_context { Load=1, Store=2, Del=3, AugLoad=4, AugStore=5,
12 Param=6 } expr_context_ty;
13
14typedef struct _slice *slice_ty;
15
16typedef enum _boolop { And=1, Or=2 } boolop_ty;
17
18typedef enum _operator { Add=1, Sub=2, Mult=3, Div=4, Mod=5, Pow=6, LShift=7,
19 RShift=8, BitOr=9, BitXor=10, BitAnd=11, FloorDiv=12 }
20 operator_ty;
21
22typedef enum _unaryop { Invert=1, Not=2, UAdd=3, USub=4 } unaryop_ty;
23
24typedef enum _cmpop { Eq=1, NotEq=2, Lt=3, LtE=4, Gt=5, GtE=6, Is=7, IsNot=8,
25 In=9, NotIn=10 } cmpop_ty;
26
27typedef struct _comprehension *comprehension_ty;
28
29typedef struct _excepthandler *excepthandler_ty;
30
31typedef struct _arguments *arguments_ty;
32
Neal Norwitzc1505362006-12-28 06:47:50 +000033typedef struct _arg *arg_ty;
34
Jeremy Hylton3e0055f2005-10-20 19:59:25 +000035typedef struct _keyword *keyword_ty;
36
37typedef struct _alias *alias_ty;
38
Neal Norwitz7b5a6042005-11-13 19:14:20 +000039
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000040enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3,
41 Suite_kind=4};
Jeremy Hylton3e0055f2005-10-20 19:59:25 +000042struct _mod {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000043 enum _mod_kind kind;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +000044 union {
45 struct {
46 asdl_seq *body;
47 } Module;
48
49 struct {
50 asdl_seq *body;
51 } Interactive;
52
53 struct {
54 expr_ty body;
55 } Expression;
56
57 struct {
58 asdl_seq *body;
59 } Suite;
60
61 } v;
62};
63
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000064enum _stmt_kind {FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3,
65 Delete_kind=4, Assign_kind=5, AugAssign_kind=6, Print_kind=7,
66 For_kind=8, While_kind=9, If_kind=10, With_kind=11,
67 Raise_kind=12, TryExcept_kind=13, TryFinally_kind=14,
68 Assert_kind=15, Import_kind=16, ImportFrom_kind=17,
Georg Brandl7cae87c2006-09-06 06:51:57 +000069 Global_kind=18, Expr_kind=19, Pass_kind=20, Break_kind=21,
70 Continue_kind=22};
Jeremy Hylton3e0055f2005-10-20 19:59:25 +000071struct _stmt {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000072 enum _stmt_kind kind;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +000073 union {
74 struct {
75 identifier name;
76 arguments_ty args;
77 asdl_seq *body;
78 asdl_seq *decorators;
Neal Norwitzc1505362006-12-28 06:47:50 +000079 expr_ty returns;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +000080 } FunctionDef;
81
82 struct {
83 identifier name;
84 asdl_seq *bases;
85 asdl_seq *body;
86 } ClassDef;
87
88 struct {
89 expr_ty value;
90 } Return;
91
92 struct {
93 asdl_seq *targets;
94 } Delete;
95
96 struct {
97 asdl_seq *targets;
98 expr_ty value;
99 } Assign;
100
101 struct {
102 expr_ty target;
103 operator_ty op;
104 expr_ty value;
105 } AugAssign;
106
107 struct {
108 expr_ty dest;
109 asdl_seq *values;
110 bool nl;
111 } Print;
112
113 struct {
114 expr_ty target;
115 expr_ty iter;
116 asdl_seq *body;
117 asdl_seq *orelse;
118 } For;
119
120 struct {
121 expr_ty test;
122 asdl_seq *body;
123 asdl_seq *orelse;
124 } While;
125
126 struct {
127 expr_ty test;
128 asdl_seq *body;
129 asdl_seq *orelse;
130 } If;
131
132 struct {
Guido van Rossumc2e20742006-02-27 22:32:47 +0000133 expr_ty context_expr;
134 expr_ty optional_vars;
135 asdl_seq *body;
136 } With;
137
138 struct {
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000139 expr_ty type;
140 expr_ty inst;
141 expr_ty tback;
142 } Raise;
143
144 struct {
145 asdl_seq *body;
146 asdl_seq *handlers;
147 asdl_seq *orelse;
148 } TryExcept;
149
150 struct {
151 asdl_seq *body;
152 asdl_seq *finalbody;
153 } TryFinally;
154
155 struct {
156 expr_ty test;
157 expr_ty msg;
158 } Assert;
159
160 struct {
161 asdl_seq *names;
162 } Import;
163
164 struct {
165 identifier module;
166 asdl_seq *names;
Thomas Woutersf7f438b2006-02-28 16:09:29 +0000167 int level;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000168 } ImportFrom;
169
170 struct {
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000171 asdl_seq *names;
172 } Global;
173
174 struct {
175 expr_ty value;
176 } Expr;
177
178 } v;
179 int lineno;
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000180 int col_offset;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000181};
182
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000183enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4,
Guido van Rossum86e58e22006-08-28 15:27:34 +0000184 IfExp_kind=5, Dict_kind=6, Set_kind=7, ListComp_kind=8,
185 GeneratorExp_kind=9, Yield_kind=10, Compare_kind=11,
Georg Brandl52318d62006-09-06 07:06:08 +0000186 Call_kind=12, Num_kind=13, Str_kind=14, Ellipsis_kind=15,
187 Attribute_kind=16, Subscript_kind=17, Name_kind=18,
188 List_kind=19, Tuple_kind=20};
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000189struct _expr {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000190 enum _expr_kind kind;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000191 union {
192 struct {
193 boolop_ty op;
194 asdl_seq *values;
195 } BoolOp;
196
197 struct {
198 expr_ty left;
199 operator_ty op;
200 expr_ty right;
201 } BinOp;
202
203 struct {
204 unaryop_ty op;
205 expr_ty operand;
206 } UnaryOp;
207
208 struct {
209 arguments_ty args;
210 expr_ty body;
211 } Lambda;
212
213 struct {
Thomas Woutersdca3b9c2006-02-27 00:24:13 +0000214 expr_ty test;
215 expr_ty body;
216 expr_ty orelse;
217 } IfExp;
218
219 struct {
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000220 asdl_seq *keys;
221 asdl_seq *values;
222 } Dict;
223
224 struct {
Guido van Rossum86e58e22006-08-28 15:27:34 +0000225 asdl_seq *elts;
226 } Set;
227
228 struct {
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000229 expr_ty elt;
230 asdl_seq *generators;
231 } ListComp;
232
233 struct {
234 expr_ty elt;
235 asdl_seq *generators;
236 } GeneratorExp;
237
238 struct {
239 expr_ty value;
240 } Yield;
241
242 struct {
243 expr_ty left;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000244 asdl_int_seq *ops;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000245 asdl_seq *comparators;
246 } Compare;
247
248 struct {
249 expr_ty func;
250 asdl_seq *args;
251 asdl_seq *keywords;
252 expr_ty starargs;
253 expr_ty kwargs;
254 } Call;
255
256 struct {
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000257 object n;
258 } Num;
259
260 struct {
261 string s;
262 } Str;
263
264 struct {
265 expr_ty value;
266 identifier attr;
267 expr_context_ty ctx;
268 } Attribute;
269
270 struct {
271 expr_ty value;
272 slice_ty slice;
273 expr_context_ty ctx;
274 } Subscript;
275
276 struct {
277 identifier id;
278 expr_context_ty ctx;
279 } Name;
280
281 struct {
282 asdl_seq *elts;
283 expr_context_ty ctx;
284 } List;
285
286 struct {
287 asdl_seq *elts;
288 expr_context_ty ctx;
289 } Tuple;
290
291 } v;
292 int lineno;
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000293 int col_offset;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000294};
295
Georg Brandl52318d62006-09-06 07:06:08 +0000296enum _slice_kind {Slice_kind=1, ExtSlice_kind=2, Index_kind=3};
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000297struct _slice {
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000298 enum _slice_kind kind;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000299 union {
300 struct {
301 expr_ty lower;
302 expr_ty upper;
303 expr_ty step;
304 } Slice;
305
306 struct {
307 asdl_seq *dims;
308 } ExtSlice;
309
310 struct {
311 expr_ty value;
312 } Index;
313
314 } v;
315};
316
317struct _comprehension {
318 expr_ty target;
319 expr_ty iter;
320 asdl_seq *ifs;
321};
322
323struct _excepthandler {
324 expr_ty type;
325 expr_ty name;
326 asdl_seq *body;
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000327 int lineno;
328 int col_offset;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000329};
330
331struct _arguments {
332 asdl_seq *args;
333 identifier vararg;
Neal Norwitzc1505362006-12-28 06:47:50 +0000334 expr_ty varargannotation;
Guido van Rossum4f72a782006-10-27 23:31:49 +0000335 asdl_seq *kwonlyargs;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000336 identifier kwarg;
Neal Norwitzc1505362006-12-28 06:47:50 +0000337 expr_ty kwargannotation;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000338 asdl_seq *defaults;
Guido van Rossum4f72a782006-10-27 23:31:49 +0000339 asdl_seq *kw_defaults;
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000340};
341
Neal Norwitzc1505362006-12-28 06:47:50 +0000342enum _arg_kind {SimpleArg_kind=1, NestedArgs_kind=2};
343struct _arg {
344 enum _arg_kind kind;
345 union {
346 struct {
347 identifier arg;
348 expr_ty annotation;
349 } SimpleArg;
350
351 struct {
352 asdl_seq *args;
353 } NestedArgs;
354
355 } v;
356};
357
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000358struct _keyword {
359 identifier arg;
360 expr_ty value;
361};
362
363struct _alias {
364 identifier name;
365 identifier asname;
366};
367
Neal Norwitz7b5a6042005-11-13 19:14:20 +0000368
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000369mod_ty Module(asdl_seq * body, PyArena *arena);
370mod_ty Interactive(asdl_seq * body, PyArena *arena);
371mod_ty Expression(expr_ty body, PyArena *arena);
372mod_ty Suite(asdl_seq * body, PyArena *arena);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000373stmt_ty FunctionDef(identifier name, arguments_ty args, asdl_seq * body,
Neal Norwitzc1505362006-12-28 06:47:50 +0000374 asdl_seq * decorators, expr_ty returns, int lineno, int
375 col_offset, PyArena *arena);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000376stmt_ty ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, int
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000377 lineno, int col_offset, PyArena *arena);
378stmt_ty Return(expr_ty value, int lineno, int col_offset, PyArena *arena);
379stmt_ty Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena);
380stmt_ty Assign(asdl_seq * targets, expr_ty value, int lineno, int col_offset,
381 PyArena *arena);
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000382stmt_ty AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno,
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000383 int col_offset, PyArena *arena);
384stmt_ty Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, int
385 col_offset, PyArena *arena);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000386stmt_ty For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse,
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000387 int lineno, int col_offset, PyArena *arena);
388stmt_ty While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
389 col_offset, PyArena *arena);
390stmt_ty If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
391 col_offset, PyArena *arena);
Guido van Rossumc2e20742006-02-27 22:32:47 +0000392stmt_ty With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body, int
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000393 lineno, int col_offset, PyArena *arena);
394stmt_ty Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int
395 col_offset, PyArena *arena);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000396stmt_ty TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000397 lineno, int col_offset, PyArena *arena);
398stmt_ty TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int
399 col_offset, PyArena *arena);
400stmt_ty Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena
401 *arena);
402stmt_ty Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena);
Thomas Woutersf7f438b2006-02-28 16:09:29 +0000403stmt_ty ImportFrom(identifier module, asdl_seq * names, int level, int lineno,
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000404 int col_offset, PyArena *arena);
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000405stmt_ty Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena);
406stmt_ty Expr(expr_ty value, int lineno, int col_offset, PyArena *arena);
407stmt_ty Pass(int lineno, int col_offset, PyArena *arena);
408stmt_ty Break(int lineno, int col_offset, PyArena *arena);
409stmt_ty Continue(int lineno, int col_offset, PyArena *arena);
410expr_ty BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset,
411 PyArena *arena);
412expr_ty BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
413 col_offset, PyArena *arena);
414expr_ty UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset,
415 PyArena *arena);
416expr_ty Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset,
417 PyArena *arena);
418expr_ty IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
419 col_offset, PyArena *arena);
420expr_ty Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset,
421 PyArena *arena);
Guido van Rossum86e58e22006-08-28 15:27:34 +0000422expr_ty Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena);
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000423expr_ty ListComp(expr_ty elt, asdl_seq * generators, int lineno, int
424 col_offset, PyArena *arena);
425expr_ty GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int
426 col_offset, PyArena *arena);
427expr_ty Yield(expr_ty value, int lineno, int col_offset, PyArena *arena);
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000428expr_ty Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000429 lineno, int col_offset, PyArena *arena);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000430expr_ty Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000431 starargs, expr_ty kwargs, int lineno, int col_offset, PyArena
432 *arena);
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000433expr_ty Num(object n, int lineno, int col_offset, PyArena *arena);
434expr_ty Str(string s, int lineno, int col_offset, PyArena *arena);
Georg Brandl52318d62006-09-06 07:06:08 +0000435expr_ty Ellipsis(int lineno, int col_offset, PyArena *arena);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000436expr_ty Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000437 lineno, int col_offset, PyArena *arena);
Jeremy Hylton3e0055f2005-10-20 19:59:25 +0000438expr_ty Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int
Martin v. Löwis49c5da12006-03-01 22:49:05 +0000439 lineno, int col_offset, PyArena *arena);
440expr_ty Name(identifier id, expr_context_ty ctx, int lineno, int col_offset,
441 PyArena *arena);
442expr_ty List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset,
443 PyArena *arena);
444expr_ty Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset,
445 PyArena *arena);
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000446slice_ty Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena);
447slice_ty ExtSlice(asdl_seq * dims, PyArena *arena);
448slice_ty Index(expr_ty value, PyArena *arena);
449comprehension_ty comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs,
450 PyArena *arena);
Thomas Wouters49fd7fa2006-04-21 10:40:58 +0000451excepthandler_ty excepthandler(expr_ty type, expr_ty name, asdl_seq * body, int
452 lineno, int col_offset, PyArena *arena);
Neal Norwitzc1505362006-12-28 06:47:50 +0000453arguments_ty arguments(asdl_seq * args, identifier vararg, expr_ty
454 varargannotation, asdl_seq * kwonlyargs, identifier
455 kwarg, expr_ty kwargannotation, asdl_seq * defaults,
Guido van Rossum4f72a782006-10-27 23:31:49 +0000456 asdl_seq * kw_defaults, PyArena *arena);
Neal Norwitzc1505362006-12-28 06:47:50 +0000457arg_ty SimpleArg(identifier arg, expr_ty annotation, PyArena *arena);
458arg_ty NestedArgs(asdl_seq * args, PyArena *arena);
Neal Norwitzadb69fc2005-12-17 20:54:49 +0000459keyword_ty keyword(identifier arg, expr_ty value, PyArena *arena);
460alias_ty alias(identifier name, identifier asname, PyArena *arena);
Neal Norwitz7b5a6042005-11-13 19:14:20 +0000461
Martin v. Löwisbd260da2006-02-26 19:42:26 +0000462PyObject* PyAST_mod2obj(mod_ty t);