Python-ast.h revision 16be03e4a206c24b00dc1d2d3c740dffbbfc4ac9
1/* File automatically generated by Parser/asdl_c.py */
2
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
33typedef struct _arg *arg_ty;
34
35typedef struct _keyword *keyword_ty;
36
37typedef struct _alias *alias_ty;
38
39
40enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3,
41                 Suite_kind=4};
42struct _mod {
43        enum _mod_kind kind;
44        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
64enum _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,
69                  Global_kind=18, Expr_kind=19, Pass_kind=20, Break_kind=21,
70                  Continue_kind=22};
71struct _stmt {
72        enum _stmt_kind kind;
73        union {
74                struct {
75                        identifier name;
76                        arguments_ty args;
77                        asdl_seq *body;
78                        asdl_seq *decorators;
79                        expr_ty returns;
80                } 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 {
133                        expr_ty context_expr;
134                        expr_ty optional_vars;
135                        asdl_seq *body;
136                } With;
137
138                struct {
139                        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;
167                        int level;
168                } ImportFrom;
169
170                struct {
171                        asdl_seq *names;
172                } Global;
173
174                struct {
175                        expr_ty value;
176                } Expr;
177
178        } v;
179        int lineno;
180        int col_offset;
181};
182
183enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4,
184                  IfExp_kind=5, Dict_kind=6, Set_kind=7, ListComp_kind=8,
185                  GeneratorExp_kind=9, Yield_kind=10, Compare_kind=11,
186                  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};
189struct _expr {
190        enum _expr_kind kind;
191        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 {
214                        expr_ty test;
215                        expr_ty body;
216                        expr_ty orelse;
217                } IfExp;
218
219                struct {
220                        asdl_seq *keys;
221                        asdl_seq *values;
222                } Dict;
223
224                struct {
225                        asdl_seq *elts;
226                } Set;
227
228                struct {
229                        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;
244                        asdl_int_seq *ops;
245                        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 {
257                        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;
293        int col_offset;
294};
295
296enum _slice_kind {Slice_kind=1, ExtSlice_kind=2, Index_kind=3};
297struct _slice {
298        enum _slice_kind kind;
299        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        identifier name;
326        asdl_seq *body;
327        int lineno;
328        int col_offset;
329};
330
331struct _arguments {
332        asdl_seq *args;
333        identifier vararg;
334        expr_ty varargannotation;
335        asdl_seq *kwonlyargs;
336        identifier kwarg;
337        expr_ty kwargannotation;
338        asdl_seq *defaults;
339        asdl_seq *kw_defaults;
340};
341
342enum _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
358struct _keyword {
359        identifier arg;
360        expr_ty value;
361};
362
363struct _alias {
364        identifier name;
365        identifier asname;
366};
367
368
369mod_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);
373stmt_ty FunctionDef(identifier name, arguments_ty args, asdl_seq * body,
374                    asdl_seq * decorators, expr_ty returns, int lineno, int
375                    col_offset, PyArena *arena);
376stmt_ty ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, int
377                 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);
382stmt_ty AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno,
383                  int col_offset, PyArena *arena);
384stmt_ty Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, int
385              col_offset, PyArena *arena);
386stmt_ty For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse,
387            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);
392stmt_ty With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body, int
393             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);
396stmt_ty TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int
397                  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);
403stmt_ty ImportFrom(identifier module, asdl_seq * names, int level, int lineno,
404                   int col_offset, PyArena *arena);
405stmt_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);
422expr_ty Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena);
423expr_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);
428expr_ty Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int
429                lineno, int col_offset, PyArena *arena);
430expr_ty Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty
431             starargs, expr_ty kwargs, int lineno, int col_offset, PyArena
432             *arena);
433expr_ty Num(object n, int lineno, int col_offset, PyArena *arena);
434expr_ty Str(string s, int lineno, int col_offset, PyArena *arena);
435expr_ty Ellipsis(int lineno, int col_offset, PyArena *arena);
436expr_ty Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
437                  lineno, int col_offset, PyArena *arena);
438expr_ty Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int
439                  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);
446slice_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);
451excepthandler_ty excepthandler(expr_ty type, identifier name, asdl_seq * body,
452                               int lineno, int col_offset, PyArena *arena);
453arguments_ty arguments(asdl_seq * args, identifier vararg, expr_ty
454                       varargannotation, asdl_seq * kwonlyargs, identifier
455                       kwarg, expr_ty kwargannotation, asdl_seq * defaults,
456                       asdl_seq * kw_defaults, PyArena *arena);
457arg_ty SimpleArg(identifier arg, expr_ty annotation, PyArena *arena);
458arg_ty NestedArgs(asdl_seq * args, PyArena *arena);
459keyword_ty keyword(identifier arg, expr_ty value, PyArena *arena);
460alias_ty alias(identifier name, identifier asname, PyArena *arena);
461
462PyObject* PyAST_mod2obj(mod_ty t);
463