1 /* File automatically generated by Parser/asdl_c.py. */
7 This module must be committed separately after each AST grammar change;
8 The __version__ number is set to the revision number of the commit
9 containing the grammar change.
13 #include "Python-ast.h"
15 static PyTypeObject
* AST_type
;
16 static PyTypeObject
*mod_type
;
17 static PyObject
* ast2obj_mod(void*);
18 static PyTypeObject
*Module_type
;
19 static char *Module_fields
[]={
22 static PyTypeObject
*Interactive_type
;
23 static char *Interactive_fields
[]={
26 static PyTypeObject
*Expression_type
;
27 static char *Expression_fields
[]={
30 static PyTypeObject
*Suite_type
;
31 static char *Suite_fields
[]={
34 static PyTypeObject
*stmt_type
;
35 static char *stmt_attributes
[] = {
39 static PyObject
* ast2obj_stmt(void*);
40 static PyTypeObject
*FunctionDef_type
;
41 static char *FunctionDef_fields
[]={
47 static PyTypeObject
*ClassDef_type
;
48 static char *ClassDef_fields
[]={
53 static PyTypeObject
*Return_type
;
54 static char *Return_fields
[]={
57 static PyTypeObject
*Delete_type
;
58 static char *Delete_fields
[]={
61 static PyTypeObject
*Assign_type
;
62 static char *Assign_fields
[]={
66 static PyTypeObject
*AugAssign_type
;
67 static char *AugAssign_fields
[]={
72 static PyTypeObject
*Print_type
;
73 static char *Print_fields
[]={
78 static PyTypeObject
*For_type
;
79 static char *For_fields
[]={
85 static PyTypeObject
*While_type
;
86 static char *While_fields
[]={
91 static PyTypeObject
*If_type
;
92 static char *If_fields
[]={
97 static PyTypeObject
*With_type
;
98 static char *With_fields
[]={
103 static PyTypeObject
*Raise_type
;
104 static char *Raise_fields
[]={
109 static PyTypeObject
*TryExcept_type
;
110 static char *TryExcept_fields
[]={
115 static PyTypeObject
*TryFinally_type
;
116 static char *TryFinally_fields
[]={
120 static PyTypeObject
*Assert_type
;
121 static char *Assert_fields
[]={
125 static PyTypeObject
*Import_type
;
126 static char *Import_fields
[]={
129 static PyTypeObject
*ImportFrom_type
;
130 static char *ImportFrom_fields
[]={
135 static PyTypeObject
*Exec_type
;
136 static char *Exec_fields
[]={
141 static PyTypeObject
*Global_type
;
142 static char *Global_fields
[]={
145 static PyTypeObject
*Expr_type
;
146 static char *Expr_fields
[]={
149 static PyTypeObject
*Pass_type
;
150 static PyTypeObject
*Break_type
;
151 static PyTypeObject
*Continue_type
;
152 static PyTypeObject
*expr_type
;
153 static char *expr_attributes
[] = {
157 static PyObject
* ast2obj_expr(void*);
158 static PyTypeObject
*BoolOp_type
;
159 static char *BoolOp_fields
[]={
163 static PyTypeObject
*BinOp_type
;
164 static char *BinOp_fields
[]={
169 static PyTypeObject
*UnaryOp_type
;
170 static char *UnaryOp_fields
[]={
174 static PyTypeObject
*Lambda_type
;
175 static char *Lambda_fields
[]={
179 static PyTypeObject
*IfExp_type
;
180 static char *IfExp_fields
[]={
185 static PyTypeObject
*Dict_type
;
186 static char *Dict_fields
[]={
190 static PyTypeObject
*ListComp_type
;
191 static char *ListComp_fields
[]={
195 static PyTypeObject
*GeneratorExp_type
;
196 static char *GeneratorExp_fields
[]={
200 static PyTypeObject
*Yield_type
;
201 static char *Yield_fields
[]={
204 static PyTypeObject
*Compare_type
;
205 static char *Compare_fields
[]={
210 static PyTypeObject
*Call_type
;
211 static char *Call_fields
[]={
218 static PyTypeObject
*Repr_type
;
219 static char *Repr_fields
[]={
222 static PyTypeObject
*Num_type
;
223 static char *Num_fields
[]={
226 static PyTypeObject
*Str_type
;
227 static char *Str_fields
[]={
230 static PyTypeObject
*Attribute_type
;
231 static char *Attribute_fields
[]={
236 static PyTypeObject
*Subscript_type
;
237 static char *Subscript_fields
[]={
242 static PyTypeObject
*Name_type
;
243 static char *Name_fields
[]={
247 static PyTypeObject
*List_type
;
248 static char *List_fields
[]={
252 static PyTypeObject
*Tuple_type
;
253 static char *Tuple_fields
[]={
257 static PyTypeObject
*expr_context_type
;
258 static PyObject
*Load_singleton
, *Store_singleton
, *Del_singleton
,
259 *AugLoad_singleton
, *AugStore_singleton
, *Param_singleton
;
260 static PyObject
* ast2obj_expr_context(expr_context_ty
);
261 static PyTypeObject
*Load_type
;
262 static PyTypeObject
*Store_type
;
263 static PyTypeObject
*Del_type
;
264 static PyTypeObject
*AugLoad_type
;
265 static PyTypeObject
*AugStore_type
;
266 static PyTypeObject
*Param_type
;
267 static PyTypeObject
*slice_type
;
268 static PyObject
* ast2obj_slice(void*);
269 static PyTypeObject
*Ellipsis_type
;
270 static PyTypeObject
*Slice_type
;
271 static char *Slice_fields
[]={
276 static PyTypeObject
*ExtSlice_type
;
277 static char *ExtSlice_fields
[]={
280 static PyTypeObject
*Index_type
;
281 static char *Index_fields
[]={
284 static PyTypeObject
*boolop_type
;
285 static PyObject
*And_singleton
, *Or_singleton
;
286 static PyObject
* ast2obj_boolop(boolop_ty
);
287 static PyTypeObject
*And_type
;
288 static PyTypeObject
*Or_type
;
289 static PyTypeObject
*operator_type
;
290 static PyObject
*Add_singleton
, *Sub_singleton
, *Mult_singleton
,
291 *Div_singleton
, *Mod_singleton
, *Pow_singleton
, *LShift_singleton
,
292 *RShift_singleton
, *BitOr_singleton
, *BitXor_singleton
, *BitAnd_singleton
,
294 static PyObject
* ast2obj_operator(operator_ty
);
295 static PyTypeObject
*Add_type
;
296 static PyTypeObject
*Sub_type
;
297 static PyTypeObject
*Mult_type
;
298 static PyTypeObject
*Div_type
;
299 static PyTypeObject
*Mod_type
;
300 static PyTypeObject
*Pow_type
;
301 static PyTypeObject
*LShift_type
;
302 static PyTypeObject
*RShift_type
;
303 static PyTypeObject
*BitOr_type
;
304 static PyTypeObject
*BitXor_type
;
305 static PyTypeObject
*BitAnd_type
;
306 static PyTypeObject
*FloorDiv_type
;
307 static PyTypeObject
*unaryop_type
;
308 static PyObject
*Invert_singleton
, *Not_singleton
, *UAdd_singleton
,
310 static PyObject
* ast2obj_unaryop(unaryop_ty
);
311 static PyTypeObject
*Invert_type
;
312 static PyTypeObject
*Not_type
;
313 static PyTypeObject
*UAdd_type
;
314 static PyTypeObject
*USub_type
;
315 static PyTypeObject
*cmpop_type
;
316 static PyObject
*Eq_singleton
, *NotEq_singleton
, *Lt_singleton
, *LtE_singleton
,
317 *Gt_singleton
, *GtE_singleton
, *Is_singleton
, *IsNot_singleton
, *In_singleton
,
319 static PyObject
* ast2obj_cmpop(cmpop_ty
);
320 static PyTypeObject
*Eq_type
;
321 static PyTypeObject
*NotEq_type
;
322 static PyTypeObject
*Lt_type
;
323 static PyTypeObject
*LtE_type
;
324 static PyTypeObject
*Gt_type
;
325 static PyTypeObject
*GtE_type
;
326 static PyTypeObject
*Is_type
;
327 static PyTypeObject
*IsNot_type
;
328 static PyTypeObject
*In_type
;
329 static PyTypeObject
*NotIn_type
;
330 static PyTypeObject
*comprehension_type
;
331 static PyObject
* ast2obj_comprehension(void*);
332 static char *comprehension_fields
[]={
337 static PyTypeObject
*excepthandler_type
;
338 static PyObject
* ast2obj_excepthandler(void*);
339 static char *excepthandler_fields
[]={
346 static PyTypeObject
*arguments_type
;
347 static PyObject
* ast2obj_arguments(void*);
348 static char *arguments_fields
[]={
354 static PyTypeObject
*keyword_type
;
355 static PyObject
* ast2obj_keyword(void*);
356 static char *keyword_fields
[]={
360 static PyTypeObject
*alias_type
;
361 static PyObject
* ast2obj_alias(void*);
362 static char *alias_fields
[]={
368 static PyTypeObject
* make_type(char *type
, PyTypeObject
* base
, char**fields
, int num_fields
)
370 PyObject
*fnames
, *result
;
373 fnames
= PyTuple_New(num_fields
);
374 if (!fnames
) return NULL
;
379 for(i
=0; i
< num_fields
; i
++) {
380 PyObject
*field
= PyString_FromString(fields
[i
]);
385 PyTuple_SET_ITEM(fnames
, i
, field
);
387 result
= PyObject_CallFunction((PyObject
*)&PyType_Type
, "s(O){sOss}",
388 type
, base
, "_fields", fnames
, "__module__", "_ast");
390 return (PyTypeObject
*)result
;
393 static int add_attributes(PyTypeObject
* type
, char**attrs
, int num_fields
)
396 PyObject
*s
, *l
= PyList_New(num_fields
);
398 for(i
= 0; i
< num_fields
; i
++) {
399 s
= PyString_FromString(attrs
[i
]);
404 PyList_SET_ITEM(l
, i
, s
);
406 result
= PyObject_SetAttrString((PyObject
*)type
, "_attributes", l
) >= 0;
411 static PyObject
* ast2obj_list(asdl_seq
*seq
, PyObject
* (*func
)(void*))
413 int i
, n
= asdl_seq_LEN(seq
);
414 PyObject
*result
= PyList_New(n
);
418 for (i
= 0; i
< n
; i
++) {
419 value
= func(asdl_seq_GET(seq
, i
));
424 PyList_SET_ITEM(result
, i
, value
);
429 static PyObject
* ast2obj_object(void *o
)
433 Py_INCREF((PyObject
*)o
);
436 #define ast2obj_identifier ast2obj_object
437 #define ast2obj_string ast2obj_object
438 static PyObject
* ast2obj_bool(bool b
)
440 return PyBool_FromLong(b
);
443 static PyObject
* ast2obj_int(long b
)
445 return PyInt_FromLong(b
);
448 static int init_types(void)
450 static int initialized
;
451 if (initialized
) return 1;
452 AST_type
= make_type("AST", &PyBaseObject_Type
, NULL
, 0);
453 mod_type
= make_type("mod", AST_type
, NULL
, 0);
454 if (!mod_type
) return 0;
455 if (!add_attributes(mod_type
, NULL
, 0)) return 0;
456 Module_type
= make_type("Module", mod_type
, Module_fields
, 1);
457 if (!Module_type
) return 0;
458 Interactive_type
= make_type("Interactive", mod_type
,
459 Interactive_fields
, 1);
460 if (!Interactive_type
) return 0;
461 Expression_type
= make_type("Expression", mod_type
, Expression_fields
,
463 if (!Expression_type
) return 0;
464 Suite_type
= make_type("Suite", mod_type
, Suite_fields
, 1);
465 if (!Suite_type
) return 0;
466 stmt_type
= make_type("stmt", AST_type
, NULL
, 0);
467 if (!stmt_type
) return 0;
468 if (!add_attributes(stmt_type
, stmt_attributes
, 2)) return 0;
469 FunctionDef_type
= make_type("FunctionDef", stmt_type
,
470 FunctionDef_fields
, 4);
471 if (!FunctionDef_type
) return 0;
472 ClassDef_type
= make_type("ClassDef", stmt_type
, ClassDef_fields
, 3);
473 if (!ClassDef_type
) return 0;
474 Return_type
= make_type("Return", stmt_type
, Return_fields
, 1);
475 if (!Return_type
) return 0;
476 Delete_type
= make_type("Delete", stmt_type
, Delete_fields
, 1);
477 if (!Delete_type
) return 0;
478 Assign_type
= make_type("Assign", stmt_type
, Assign_fields
, 2);
479 if (!Assign_type
) return 0;
480 AugAssign_type
= make_type("AugAssign", stmt_type
, AugAssign_fields
, 3);
481 if (!AugAssign_type
) return 0;
482 Print_type
= make_type("Print", stmt_type
, Print_fields
, 3);
483 if (!Print_type
) return 0;
484 For_type
= make_type("For", stmt_type
, For_fields
, 4);
485 if (!For_type
) return 0;
486 While_type
= make_type("While", stmt_type
, While_fields
, 3);
487 if (!While_type
) return 0;
488 If_type
= make_type("If", stmt_type
, If_fields
, 3);
489 if (!If_type
) return 0;
490 With_type
= make_type("With", stmt_type
, With_fields
, 3);
491 if (!With_type
) return 0;
492 Raise_type
= make_type("Raise", stmt_type
, Raise_fields
, 3);
493 if (!Raise_type
) return 0;
494 TryExcept_type
= make_type("TryExcept", stmt_type
, TryExcept_fields
, 3);
495 if (!TryExcept_type
) return 0;
496 TryFinally_type
= make_type("TryFinally", stmt_type
, TryFinally_fields
,
498 if (!TryFinally_type
) return 0;
499 Assert_type
= make_type("Assert", stmt_type
, Assert_fields
, 2);
500 if (!Assert_type
) return 0;
501 Import_type
= make_type("Import", stmt_type
, Import_fields
, 1);
502 if (!Import_type
) return 0;
503 ImportFrom_type
= make_type("ImportFrom", stmt_type
, ImportFrom_fields
,
505 if (!ImportFrom_type
) return 0;
506 Exec_type
= make_type("Exec", stmt_type
, Exec_fields
, 3);
507 if (!Exec_type
) return 0;
508 Global_type
= make_type("Global", stmt_type
, Global_fields
, 1);
509 if (!Global_type
) return 0;
510 Expr_type
= make_type("Expr", stmt_type
, Expr_fields
, 1);
511 if (!Expr_type
) return 0;
512 Pass_type
= make_type("Pass", stmt_type
, NULL
, 0);
513 if (!Pass_type
) return 0;
514 Break_type
= make_type("Break", stmt_type
, NULL
, 0);
515 if (!Break_type
) return 0;
516 Continue_type
= make_type("Continue", stmt_type
, NULL
, 0);
517 if (!Continue_type
) return 0;
518 expr_type
= make_type("expr", AST_type
, NULL
, 0);
519 if (!expr_type
) return 0;
520 if (!add_attributes(expr_type
, expr_attributes
, 2)) return 0;
521 BoolOp_type
= make_type("BoolOp", expr_type
, BoolOp_fields
, 2);
522 if (!BoolOp_type
) return 0;
523 BinOp_type
= make_type("BinOp", expr_type
, BinOp_fields
, 3);
524 if (!BinOp_type
) return 0;
525 UnaryOp_type
= make_type("UnaryOp", expr_type
, UnaryOp_fields
, 2);
526 if (!UnaryOp_type
) return 0;
527 Lambda_type
= make_type("Lambda", expr_type
, Lambda_fields
, 2);
528 if (!Lambda_type
) return 0;
529 IfExp_type
= make_type("IfExp", expr_type
, IfExp_fields
, 3);
530 if (!IfExp_type
) return 0;
531 Dict_type
= make_type("Dict", expr_type
, Dict_fields
, 2);
532 if (!Dict_type
) return 0;
533 ListComp_type
= make_type("ListComp", expr_type
, ListComp_fields
, 2);
534 if (!ListComp_type
) return 0;
535 GeneratorExp_type
= make_type("GeneratorExp", expr_type
,
536 GeneratorExp_fields
, 2);
537 if (!GeneratorExp_type
) return 0;
538 Yield_type
= make_type("Yield", expr_type
, Yield_fields
, 1);
539 if (!Yield_type
) return 0;
540 Compare_type
= make_type("Compare", expr_type
, Compare_fields
, 3);
541 if (!Compare_type
) return 0;
542 Call_type
= make_type("Call", expr_type
, Call_fields
, 5);
543 if (!Call_type
) return 0;
544 Repr_type
= make_type("Repr", expr_type
, Repr_fields
, 1);
545 if (!Repr_type
) return 0;
546 Num_type
= make_type("Num", expr_type
, Num_fields
, 1);
547 if (!Num_type
) return 0;
548 Str_type
= make_type("Str", expr_type
, Str_fields
, 1);
549 if (!Str_type
) return 0;
550 Attribute_type
= make_type("Attribute", expr_type
, Attribute_fields
, 3);
551 if (!Attribute_type
) return 0;
552 Subscript_type
= make_type("Subscript", expr_type
, Subscript_fields
, 3);
553 if (!Subscript_type
) return 0;
554 Name_type
= make_type("Name", expr_type
, Name_fields
, 2);
555 if (!Name_type
) return 0;
556 List_type
= make_type("List", expr_type
, List_fields
, 2);
557 if (!List_type
) return 0;
558 Tuple_type
= make_type("Tuple", expr_type
, Tuple_fields
, 2);
559 if (!Tuple_type
) return 0;
560 expr_context_type
= make_type("expr_context", AST_type
, NULL
, 0);
561 if (!expr_context_type
) return 0;
562 if (!add_attributes(expr_context_type
, NULL
, 0)) return 0;
563 Load_type
= make_type("Load", expr_context_type
, NULL
, 0);
564 if (!Load_type
) return 0;
565 Load_singleton
= PyType_GenericNew(Load_type
, NULL
, NULL
);
566 if (!Load_singleton
) return 0;
567 Store_type
= make_type("Store", expr_context_type
, NULL
, 0);
568 if (!Store_type
) return 0;
569 Store_singleton
= PyType_GenericNew(Store_type
, NULL
, NULL
);
570 if (!Store_singleton
) return 0;
571 Del_type
= make_type("Del", expr_context_type
, NULL
, 0);
572 if (!Del_type
) return 0;
573 Del_singleton
= PyType_GenericNew(Del_type
, NULL
, NULL
);
574 if (!Del_singleton
) return 0;
575 AugLoad_type
= make_type("AugLoad", expr_context_type
, NULL
, 0);
576 if (!AugLoad_type
) return 0;
577 AugLoad_singleton
= PyType_GenericNew(AugLoad_type
, NULL
, NULL
);
578 if (!AugLoad_singleton
) return 0;
579 AugStore_type
= make_type("AugStore", expr_context_type
, NULL
, 0);
580 if (!AugStore_type
) return 0;
581 AugStore_singleton
= PyType_GenericNew(AugStore_type
, NULL
, NULL
);
582 if (!AugStore_singleton
) return 0;
583 Param_type
= make_type("Param", expr_context_type
, NULL
, 0);
584 if (!Param_type
) return 0;
585 Param_singleton
= PyType_GenericNew(Param_type
, NULL
, NULL
);
586 if (!Param_singleton
) return 0;
587 slice_type
= make_type("slice", AST_type
, NULL
, 0);
588 if (!slice_type
) return 0;
589 if (!add_attributes(slice_type
, NULL
, 0)) return 0;
590 Ellipsis_type
= make_type("Ellipsis", slice_type
, NULL
, 0);
591 if (!Ellipsis_type
) return 0;
592 Slice_type
= make_type("Slice", slice_type
, Slice_fields
, 3);
593 if (!Slice_type
) return 0;
594 ExtSlice_type
= make_type("ExtSlice", slice_type
, ExtSlice_fields
, 1);
595 if (!ExtSlice_type
) return 0;
596 Index_type
= make_type("Index", slice_type
, Index_fields
, 1);
597 if (!Index_type
) return 0;
598 boolop_type
= make_type("boolop", AST_type
, NULL
, 0);
599 if (!boolop_type
) return 0;
600 if (!add_attributes(boolop_type
, NULL
, 0)) return 0;
601 And_type
= make_type("And", boolop_type
, NULL
, 0);
602 if (!And_type
) return 0;
603 And_singleton
= PyType_GenericNew(And_type
, NULL
, NULL
);
604 if (!And_singleton
) return 0;
605 Or_type
= make_type("Or", boolop_type
, NULL
, 0);
606 if (!Or_type
) return 0;
607 Or_singleton
= PyType_GenericNew(Or_type
, NULL
, NULL
);
608 if (!Or_singleton
) return 0;
609 operator_type
= make_type("operator", AST_type
, NULL
, 0);
610 if (!operator_type
) return 0;
611 if (!add_attributes(operator_type
, NULL
, 0)) return 0;
612 Add_type
= make_type("Add", operator_type
, NULL
, 0);
613 if (!Add_type
) return 0;
614 Add_singleton
= PyType_GenericNew(Add_type
, NULL
, NULL
);
615 if (!Add_singleton
) return 0;
616 Sub_type
= make_type("Sub", operator_type
, NULL
, 0);
617 if (!Sub_type
) return 0;
618 Sub_singleton
= PyType_GenericNew(Sub_type
, NULL
, NULL
);
619 if (!Sub_singleton
) return 0;
620 Mult_type
= make_type("Mult", operator_type
, NULL
, 0);
621 if (!Mult_type
) return 0;
622 Mult_singleton
= PyType_GenericNew(Mult_type
, NULL
, NULL
);
623 if (!Mult_singleton
) return 0;
624 Div_type
= make_type("Div", operator_type
, NULL
, 0);
625 if (!Div_type
) return 0;
626 Div_singleton
= PyType_GenericNew(Div_type
, NULL
, NULL
);
627 if (!Div_singleton
) return 0;
628 Mod_type
= make_type("Mod", operator_type
, NULL
, 0);
629 if (!Mod_type
) return 0;
630 Mod_singleton
= PyType_GenericNew(Mod_type
, NULL
, NULL
);
631 if (!Mod_singleton
) return 0;
632 Pow_type
= make_type("Pow", operator_type
, NULL
, 0);
633 if (!Pow_type
) return 0;
634 Pow_singleton
= PyType_GenericNew(Pow_type
, NULL
, NULL
);
635 if (!Pow_singleton
) return 0;
636 LShift_type
= make_type("LShift", operator_type
, NULL
, 0);
637 if (!LShift_type
) return 0;
638 LShift_singleton
= PyType_GenericNew(LShift_type
, NULL
, NULL
);
639 if (!LShift_singleton
) return 0;
640 RShift_type
= make_type("RShift", operator_type
, NULL
, 0);
641 if (!RShift_type
) return 0;
642 RShift_singleton
= PyType_GenericNew(RShift_type
, NULL
, NULL
);
643 if (!RShift_singleton
) return 0;
644 BitOr_type
= make_type("BitOr", operator_type
, NULL
, 0);
645 if (!BitOr_type
) return 0;
646 BitOr_singleton
= PyType_GenericNew(BitOr_type
, NULL
, NULL
);
647 if (!BitOr_singleton
) return 0;
648 BitXor_type
= make_type("BitXor", operator_type
, NULL
, 0);
649 if (!BitXor_type
) return 0;
650 BitXor_singleton
= PyType_GenericNew(BitXor_type
, NULL
, NULL
);
651 if (!BitXor_singleton
) return 0;
652 BitAnd_type
= make_type("BitAnd", operator_type
, NULL
, 0);
653 if (!BitAnd_type
) return 0;
654 BitAnd_singleton
= PyType_GenericNew(BitAnd_type
, NULL
, NULL
);
655 if (!BitAnd_singleton
) return 0;
656 FloorDiv_type
= make_type("FloorDiv", operator_type
, NULL
, 0);
657 if (!FloorDiv_type
) return 0;
658 FloorDiv_singleton
= PyType_GenericNew(FloorDiv_type
, NULL
, NULL
);
659 if (!FloorDiv_singleton
) return 0;
660 unaryop_type
= make_type("unaryop", AST_type
, NULL
, 0);
661 if (!unaryop_type
) return 0;
662 if (!add_attributes(unaryop_type
, NULL
, 0)) return 0;
663 Invert_type
= make_type("Invert", unaryop_type
, NULL
, 0);
664 if (!Invert_type
) return 0;
665 Invert_singleton
= PyType_GenericNew(Invert_type
, NULL
, NULL
);
666 if (!Invert_singleton
) return 0;
667 Not_type
= make_type("Not", unaryop_type
, NULL
, 0);
668 if (!Not_type
) return 0;
669 Not_singleton
= PyType_GenericNew(Not_type
, NULL
, NULL
);
670 if (!Not_singleton
) return 0;
671 UAdd_type
= make_type("UAdd", unaryop_type
, NULL
, 0);
672 if (!UAdd_type
) return 0;
673 UAdd_singleton
= PyType_GenericNew(UAdd_type
, NULL
, NULL
);
674 if (!UAdd_singleton
) return 0;
675 USub_type
= make_type("USub", unaryop_type
, NULL
, 0);
676 if (!USub_type
) return 0;
677 USub_singleton
= PyType_GenericNew(USub_type
, NULL
, NULL
);
678 if (!USub_singleton
) return 0;
679 cmpop_type
= make_type("cmpop", AST_type
, NULL
, 0);
680 if (!cmpop_type
) return 0;
681 if (!add_attributes(cmpop_type
, NULL
, 0)) return 0;
682 Eq_type
= make_type("Eq", cmpop_type
, NULL
, 0);
683 if (!Eq_type
) return 0;
684 Eq_singleton
= PyType_GenericNew(Eq_type
, NULL
, NULL
);
685 if (!Eq_singleton
) return 0;
686 NotEq_type
= make_type("NotEq", cmpop_type
, NULL
, 0);
687 if (!NotEq_type
) return 0;
688 NotEq_singleton
= PyType_GenericNew(NotEq_type
, NULL
, NULL
);
689 if (!NotEq_singleton
) return 0;
690 Lt_type
= make_type("Lt", cmpop_type
, NULL
, 0);
691 if (!Lt_type
) return 0;
692 Lt_singleton
= PyType_GenericNew(Lt_type
, NULL
, NULL
);
693 if (!Lt_singleton
) return 0;
694 LtE_type
= make_type("LtE", cmpop_type
, NULL
, 0);
695 if (!LtE_type
) return 0;
696 LtE_singleton
= PyType_GenericNew(LtE_type
, NULL
, NULL
);
697 if (!LtE_singleton
) return 0;
698 Gt_type
= make_type("Gt", cmpop_type
, NULL
, 0);
699 if (!Gt_type
) return 0;
700 Gt_singleton
= PyType_GenericNew(Gt_type
, NULL
, NULL
);
701 if (!Gt_singleton
) return 0;
702 GtE_type
= make_type("GtE", cmpop_type
, NULL
, 0);
703 if (!GtE_type
) return 0;
704 GtE_singleton
= PyType_GenericNew(GtE_type
, NULL
, NULL
);
705 if (!GtE_singleton
) return 0;
706 Is_type
= make_type("Is", cmpop_type
, NULL
, 0);
707 if (!Is_type
) return 0;
708 Is_singleton
= PyType_GenericNew(Is_type
, NULL
, NULL
);
709 if (!Is_singleton
) return 0;
710 IsNot_type
= make_type("IsNot", cmpop_type
, NULL
, 0);
711 if (!IsNot_type
) return 0;
712 IsNot_singleton
= PyType_GenericNew(IsNot_type
, NULL
, NULL
);
713 if (!IsNot_singleton
) return 0;
714 In_type
= make_type("In", cmpop_type
, NULL
, 0);
715 if (!In_type
) return 0;
716 In_singleton
= PyType_GenericNew(In_type
, NULL
, NULL
);
717 if (!In_singleton
) return 0;
718 NotIn_type
= make_type("NotIn", cmpop_type
, NULL
, 0);
719 if (!NotIn_type
) return 0;
720 NotIn_singleton
= PyType_GenericNew(NotIn_type
, NULL
, NULL
);
721 if (!NotIn_singleton
) return 0;
722 comprehension_type
= make_type("comprehension", AST_type
,
723 comprehension_fields
, 3);
724 if (!comprehension_type
) return 0;
725 excepthandler_type
= make_type("excepthandler", AST_type
,
726 excepthandler_fields
, 5);
727 if (!excepthandler_type
) return 0;
728 arguments_type
= make_type("arguments", AST_type
, arguments_fields
, 4);
729 if (!arguments_type
) return 0;
730 keyword_type
= make_type("keyword", AST_type
, keyword_fields
, 2);
731 if (!keyword_type
) return 0;
732 alias_type
= make_type("alias", AST_type
, alias_fields
, 2);
733 if (!alias_type
) return 0;
739 Module(asdl_seq
* body
, PyArena
*arena
)
742 p
= (mod_ty
)PyArena_Malloc(arena
, sizeof(*p
));
745 p
->kind
= Module_kind
;
746 p
->v
.Module
.body
= body
;
751 Interactive(asdl_seq
* body
, PyArena
*arena
)
754 p
= (mod_ty
)PyArena_Malloc(arena
, sizeof(*p
));
757 p
->kind
= Interactive_kind
;
758 p
->v
.Interactive
.body
= body
;
763 Expression(expr_ty body
, PyArena
*arena
)
767 PyErr_SetString(PyExc_ValueError
,
768 "field body is required for Expression");
771 p
= (mod_ty
)PyArena_Malloc(arena
, sizeof(*p
));
774 p
->kind
= Expression_kind
;
775 p
->v
.Expression
.body
= body
;
780 Suite(asdl_seq
* body
, PyArena
*arena
)
783 p
= (mod_ty
)PyArena_Malloc(arena
, sizeof(*p
));
786 p
->kind
= Suite_kind
;
787 p
->v
.Suite
.body
= body
;
792 FunctionDef(identifier name
, arguments_ty args
, asdl_seq
* body
, asdl_seq
*
793 decorators
, int lineno
, int col_offset
, PyArena
*arena
)
797 PyErr_SetString(PyExc_ValueError
,
798 "field name is required for FunctionDef");
802 PyErr_SetString(PyExc_ValueError
,
803 "field args is required for FunctionDef");
806 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
809 p
->kind
= FunctionDef_kind
;
810 p
->v
.FunctionDef
.name
= name
;
811 p
->v
.FunctionDef
.args
= args
;
812 p
->v
.FunctionDef
.body
= body
;
813 p
->v
.FunctionDef
.decorators
= decorators
;
815 p
->col_offset
= col_offset
;
820 ClassDef(identifier name
, asdl_seq
* bases
, asdl_seq
* body
, int lineno
, int
821 col_offset
, PyArena
*arena
)
825 PyErr_SetString(PyExc_ValueError
,
826 "field name is required for ClassDef");
829 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
832 p
->kind
= ClassDef_kind
;
833 p
->v
.ClassDef
.name
= name
;
834 p
->v
.ClassDef
.bases
= bases
;
835 p
->v
.ClassDef
.body
= body
;
837 p
->col_offset
= col_offset
;
842 Return(expr_ty value
, int lineno
, int col_offset
, PyArena
*arena
)
845 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
848 p
->kind
= Return_kind
;
849 p
->v
.Return
.value
= value
;
851 p
->col_offset
= col_offset
;
856 Delete(asdl_seq
* targets
, int lineno
, int col_offset
, PyArena
*arena
)
859 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
862 p
->kind
= Delete_kind
;
863 p
->v
.Delete
.targets
= targets
;
865 p
->col_offset
= col_offset
;
870 Assign(asdl_seq
* targets
, expr_ty value
, int lineno
, int col_offset
, PyArena
875 PyErr_SetString(PyExc_ValueError
,
876 "field value is required for Assign");
879 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
882 p
->kind
= Assign_kind
;
883 p
->v
.Assign
.targets
= targets
;
884 p
->v
.Assign
.value
= value
;
886 p
->col_offset
= col_offset
;
891 AugAssign(expr_ty target
, operator_ty op
, expr_ty value
, int lineno
, int
892 col_offset
, PyArena
*arena
)
896 PyErr_SetString(PyExc_ValueError
,
897 "field target is required for AugAssign");
901 PyErr_SetString(PyExc_ValueError
,
902 "field op is required for AugAssign");
906 PyErr_SetString(PyExc_ValueError
,
907 "field value is required for AugAssign");
910 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
913 p
->kind
= AugAssign_kind
;
914 p
->v
.AugAssign
.target
= target
;
915 p
->v
.AugAssign
.op
= op
;
916 p
->v
.AugAssign
.value
= value
;
918 p
->col_offset
= col_offset
;
923 Print(expr_ty dest
, asdl_seq
* values
, bool nl
, int lineno
, int col_offset
,
927 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
930 p
->kind
= Print_kind
;
931 p
->v
.Print
.dest
= dest
;
932 p
->v
.Print
.values
= values
;
935 p
->col_offset
= col_offset
;
940 For(expr_ty target
, expr_ty iter
, asdl_seq
* body
, asdl_seq
* orelse
, int
941 lineno
, int col_offset
, PyArena
*arena
)
945 PyErr_SetString(PyExc_ValueError
,
946 "field target is required for For");
950 PyErr_SetString(PyExc_ValueError
,
951 "field iter is required for For");
954 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
958 p
->v
.For
.target
= target
;
959 p
->v
.For
.iter
= iter
;
960 p
->v
.For
.body
= body
;
961 p
->v
.For
.orelse
= orelse
;
963 p
->col_offset
= col_offset
;
968 While(expr_ty test
, asdl_seq
* body
, asdl_seq
* orelse
, int lineno
, int
969 col_offset
, PyArena
*arena
)
973 PyErr_SetString(PyExc_ValueError
,
974 "field test is required for While");
977 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
980 p
->kind
= While_kind
;
981 p
->v
.While
.test
= test
;
982 p
->v
.While
.body
= body
;
983 p
->v
.While
.orelse
= orelse
;
985 p
->col_offset
= col_offset
;
990 If(expr_ty test
, asdl_seq
* body
, asdl_seq
* orelse
, int lineno
, int
991 col_offset
, PyArena
*arena
)
995 PyErr_SetString(PyExc_ValueError
,
996 "field test is required for If");
999 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1003 p
->v
.If
.test
= test
;
1004 p
->v
.If
.body
= body
;
1005 p
->v
.If
.orelse
= orelse
;
1007 p
->col_offset
= col_offset
;
1012 With(expr_ty context_expr
, expr_ty optional_vars
, asdl_seq
* body
, int lineno
,
1013 int col_offset
, PyArena
*arena
)
1016 if (!context_expr
) {
1017 PyErr_SetString(PyExc_ValueError
,
1018 "field context_expr is required for With");
1021 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1024 p
->kind
= With_kind
;
1025 p
->v
.With
.context_expr
= context_expr
;
1026 p
->v
.With
.optional_vars
= optional_vars
;
1027 p
->v
.With
.body
= body
;
1029 p
->col_offset
= col_offset
;
1034 Raise(expr_ty type
, expr_ty inst
, expr_ty tback
, int lineno
, int col_offset
,
1038 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1041 p
->kind
= Raise_kind
;
1042 p
->v
.Raise
.type
= type
;
1043 p
->v
.Raise
.inst
= inst
;
1044 p
->v
.Raise
.tback
= tback
;
1046 p
->col_offset
= col_offset
;
1051 TryExcept(asdl_seq
* body
, asdl_seq
* handlers
, asdl_seq
* orelse
, int lineno
,
1052 int col_offset
, PyArena
*arena
)
1055 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1058 p
->kind
= TryExcept_kind
;
1059 p
->v
.TryExcept
.body
= body
;
1060 p
->v
.TryExcept
.handlers
= handlers
;
1061 p
->v
.TryExcept
.orelse
= orelse
;
1063 p
->col_offset
= col_offset
;
1068 TryFinally(asdl_seq
* body
, asdl_seq
* finalbody
, int lineno
, int col_offset
,
1072 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1075 p
->kind
= TryFinally_kind
;
1076 p
->v
.TryFinally
.body
= body
;
1077 p
->v
.TryFinally
.finalbody
= finalbody
;
1079 p
->col_offset
= col_offset
;
1084 Assert(expr_ty test
, expr_ty msg
, int lineno
, int col_offset
, PyArena
*arena
)
1088 PyErr_SetString(PyExc_ValueError
,
1089 "field test is required for Assert");
1092 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1095 p
->kind
= Assert_kind
;
1096 p
->v
.Assert
.test
= test
;
1097 p
->v
.Assert
.msg
= msg
;
1099 p
->col_offset
= col_offset
;
1104 Import(asdl_seq
* names
, int lineno
, int col_offset
, PyArena
*arena
)
1107 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1110 p
->kind
= Import_kind
;
1111 p
->v
.Import
.names
= names
;
1113 p
->col_offset
= col_offset
;
1118 ImportFrom(identifier module
, asdl_seq
* names
, int level
, int lineno
, int
1119 col_offset
, PyArena
*arena
)
1123 PyErr_SetString(PyExc_ValueError
,
1124 "field module is required for ImportFrom");
1127 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1130 p
->kind
= ImportFrom_kind
;
1131 p
->v
.ImportFrom
.module
= module
;
1132 p
->v
.ImportFrom
.names
= names
;
1133 p
->v
.ImportFrom
.level
= level
;
1135 p
->col_offset
= col_offset
;
1140 Exec(expr_ty body
, expr_ty globals
, expr_ty locals
, int lineno
, int col_offset
,
1145 PyErr_SetString(PyExc_ValueError
,
1146 "field body is required for Exec");
1149 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1152 p
->kind
= Exec_kind
;
1153 p
->v
.Exec
.body
= body
;
1154 p
->v
.Exec
.globals
= globals
;
1155 p
->v
.Exec
.locals
= locals
;
1157 p
->col_offset
= col_offset
;
1162 Global(asdl_seq
* names
, int lineno
, int col_offset
, PyArena
*arena
)
1165 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1168 p
->kind
= Global_kind
;
1169 p
->v
.Global
.names
= names
;
1171 p
->col_offset
= col_offset
;
1176 Expr(expr_ty value
, int lineno
, int col_offset
, PyArena
*arena
)
1180 PyErr_SetString(PyExc_ValueError
,
1181 "field value is required for Expr");
1184 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1187 p
->kind
= Expr_kind
;
1188 p
->v
.Expr
.value
= value
;
1190 p
->col_offset
= col_offset
;
1195 Pass(int lineno
, int col_offset
, PyArena
*arena
)
1198 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1201 p
->kind
= Pass_kind
;
1203 p
->col_offset
= col_offset
;
1208 Break(int lineno
, int col_offset
, PyArena
*arena
)
1211 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1214 p
->kind
= Break_kind
;
1216 p
->col_offset
= col_offset
;
1221 Continue(int lineno
, int col_offset
, PyArena
*arena
)
1224 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1227 p
->kind
= Continue_kind
;
1229 p
->col_offset
= col_offset
;
1234 BoolOp(boolop_ty op
, asdl_seq
* values
, int lineno
, int col_offset
, PyArena
1239 PyErr_SetString(PyExc_ValueError
,
1240 "field op is required for BoolOp");
1243 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1246 p
->kind
= BoolOp_kind
;
1247 p
->v
.BoolOp
.op
= op
;
1248 p
->v
.BoolOp
.values
= values
;
1250 p
->col_offset
= col_offset
;
1255 BinOp(expr_ty left
, operator_ty op
, expr_ty right
, int lineno
, int col_offset
,
1260 PyErr_SetString(PyExc_ValueError
,
1261 "field left is required for BinOp");
1265 PyErr_SetString(PyExc_ValueError
,
1266 "field op is required for BinOp");
1270 PyErr_SetString(PyExc_ValueError
,
1271 "field right is required for BinOp");
1274 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1277 p
->kind
= BinOp_kind
;
1278 p
->v
.BinOp
.left
= left
;
1280 p
->v
.BinOp
.right
= right
;
1282 p
->col_offset
= col_offset
;
1287 UnaryOp(unaryop_ty op
, expr_ty operand
, int lineno
, int col_offset
, PyArena
1292 PyErr_SetString(PyExc_ValueError
,
1293 "field op is required for UnaryOp");
1297 PyErr_SetString(PyExc_ValueError
,
1298 "field operand is required for UnaryOp");
1301 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1304 p
->kind
= UnaryOp_kind
;
1305 p
->v
.UnaryOp
.op
= op
;
1306 p
->v
.UnaryOp
.operand
= operand
;
1308 p
->col_offset
= col_offset
;
1313 Lambda(arguments_ty args
, expr_ty body
, int lineno
, int col_offset
, PyArena
1318 PyErr_SetString(PyExc_ValueError
,
1319 "field args is required for Lambda");
1323 PyErr_SetString(PyExc_ValueError
,
1324 "field body is required for Lambda");
1327 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1330 p
->kind
= Lambda_kind
;
1331 p
->v
.Lambda
.args
= args
;
1332 p
->v
.Lambda
.body
= body
;
1334 p
->col_offset
= col_offset
;
1339 IfExp(expr_ty test
, expr_ty body
, expr_ty orelse
, int lineno
, int col_offset
,
1344 PyErr_SetString(PyExc_ValueError
,
1345 "field test is required for IfExp");
1349 PyErr_SetString(PyExc_ValueError
,
1350 "field body is required for IfExp");
1354 PyErr_SetString(PyExc_ValueError
,
1355 "field orelse is required for IfExp");
1358 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1361 p
->kind
= IfExp_kind
;
1362 p
->v
.IfExp
.test
= test
;
1363 p
->v
.IfExp
.body
= body
;
1364 p
->v
.IfExp
.orelse
= orelse
;
1366 p
->col_offset
= col_offset
;
1371 Dict(asdl_seq
* keys
, asdl_seq
* values
, int lineno
, int col_offset
, PyArena
1375 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1378 p
->kind
= Dict_kind
;
1379 p
->v
.Dict
.keys
= keys
;
1380 p
->v
.Dict
.values
= values
;
1382 p
->col_offset
= col_offset
;
1387 ListComp(expr_ty elt
, asdl_seq
* generators
, int lineno
, int col_offset
,
1392 PyErr_SetString(PyExc_ValueError
,
1393 "field elt is required for ListComp");
1396 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1399 p
->kind
= ListComp_kind
;
1400 p
->v
.ListComp
.elt
= elt
;
1401 p
->v
.ListComp
.generators
= generators
;
1403 p
->col_offset
= col_offset
;
1408 GeneratorExp(expr_ty elt
, asdl_seq
* generators
, int lineno
, int col_offset
,
1413 PyErr_SetString(PyExc_ValueError
,
1414 "field elt is required for GeneratorExp");
1417 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1420 p
->kind
= GeneratorExp_kind
;
1421 p
->v
.GeneratorExp
.elt
= elt
;
1422 p
->v
.GeneratorExp
.generators
= generators
;
1424 p
->col_offset
= col_offset
;
1429 Yield(expr_ty value
, int lineno
, int col_offset
, PyArena
*arena
)
1432 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1435 p
->kind
= Yield_kind
;
1436 p
->v
.Yield
.value
= value
;
1438 p
->col_offset
= col_offset
;
1443 Compare(expr_ty left
, asdl_int_seq
* ops
, asdl_seq
* comparators
, int lineno
,
1444 int col_offset
, PyArena
*arena
)
1448 PyErr_SetString(PyExc_ValueError
,
1449 "field left is required for Compare");
1452 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1455 p
->kind
= Compare_kind
;
1456 p
->v
.Compare
.left
= left
;
1457 p
->v
.Compare
.ops
= ops
;
1458 p
->v
.Compare
.comparators
= comparators
;
1460 p
->col_offset
= col_offset
;
1465 Call(expr_ty func
, asdl_seq
* args
, asdl_seq
* keywords
, expr_ty starargs
,
1466 expr_ty kwargs
, int lineno
, int col_offset
, PyArena
*arena
)
1470 PyErr_SetString(PyExc_ValueError
,
1471 "field func is required for Call");
1474 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1477 p
->kind
= Call_kind
;
1478 p
->v
.Call
.func
= func
;
1479 p
->v
.Call
.args
= args
;
1480 p
->v
.Call
.keywords
= keywords
;
1481 p
->v
.Call
.starargs
= starargs
;
1482 p
->v
.Call
.kwargs
= kwargs
;
1484 p
->col_offset
= col_offset
;
1489 Repr(expr_ty value
, int lineno
, int col_offset
, PyArena
*arena
)
1493 PyErr_SetString(PyExc_ValueError
,
1494 "field value is required for Repr");
1497 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1500 p
->kind
= Repr_kind
;
1501 p
->v
.Repr
.value
= value
;
1503 p
->col_offset
= col_offset
;
1508 Num(object n
, int lineno
, int col_offset
, PyArena
*arena
)
1512 PyErr_SetString(PyExc_ValueError
,
1513 "field n is required for Num");
1516 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1522 p
->col_offset
= col_offset
;
1527 Str(string s
, int lineno
, int col_offset
, PyArena
*arena
)
1531 PyErr_SetString(PyExc_ValueError
,
1532 "field s is required for Str");
1535 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1541 p
->col_offset
= col_offset
;
1546 Attribute(expr_ty value
, identifier attr
, expr_context_ty ctx
, int lineno
, int
1547 col_offset
, PyArena
*arena
)
1551 PyErr_SetString(PyExc_ValueError
,
1552 "field value is required for Attribute");
1556 PyErr_SetString(PyExc_ValueError
,
1557 "field attr is required for Attribute");
1561 PyErr_SetString(PyExc_ValueError
,
1562 "field ctx is required for Attribute");
1565 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1568 p
->kind
= Attribute_kind
;
1569 p
->v
.Attribute
.value
= value
;
1570 p
->v
.Attribute
.attr
= attr
;
1571 p
->v
.Attribute
.ctx
= ctx
;
1573 p
->col_offset
= col_offset
;
1578 Subscript(expr_ty value
, slice_ty slice
, expr_context_ty ctx
, int lineno
, int
1579 col_offset
, PyArena
*arena
)
1583 PyErr_SetString(PyExc_ValueError
,
1584 "field value is required for Subscript");
1588 PyErr_SetString(PyExc_ValueError
,
1589 "field slice is required for Subscript");
1593 PyErr_SetString(PyExc_ValueError
,
1594 "field ctx is required for Subscript");
1597 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1600 p
->kind
= Subscript_kind
;
1601 p
->v
.Subscript
.value
= value
;
1602 p
->v
.Subscript
.slice
= slice
;
1603 p
->v
.Subscript
.ctx
= ctx
;
1605 p
->col_offset
= col_offset
;
1610 Name(identifier id
, expr_context_ty ctx
, int lineno
, int col_offset
, PyArena
1615 PyErr_SetString(PyExc_ValueError
,
1616 "field id is required for Name");
1620 PyErr_SetString(PyExc_ValueError
,
1621 "field ctx is required for Name");
1624 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1627 p
->kind
= Name_kind
;
1629 p
->v
.Name
.ctx
= ctx
;
1631 p
->col_offset
= col_offset
;
1636 List(asdl_seq
* elts
, expr_context_ty ctx
, int lineno
, int col_offset
, PyArena
1641 PyErr_SetString(PyExc_ValueError
,
1642 "field ctx is required for List");
1645 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1648 p
->kind
= List_kind
;
1649 p
->v
.List
.elts
= elts
;
1650 p
->v
.List
.ctx
= ctx
;
1652 p
->col_offset
= col_offset
;
1657 Tuple(asdl_seq
* elts
, expr_context_ty ctx
, int lineno
, int col_offset
, PyArena
1662 PyErr_SetString(PyExc_ValueError
,
1663 "field ctx is required for Tuple");
1666 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1669 p
->kind
= Tuple_kind
;
1670 p
->v
.Tuple
.elts
= elts
;
1671 p
->v
.Tuple
.ctx
= ctx
;
1673 p
->col_offset
= col_offset
;
1678 Ellipsis(PyArena
*arena
)
1681 p
= (slice_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1684 p
->kind
= Ellipsis_kind
;
1689 Slice(expr_ty lower
, expr_ty upper
, expr_ty step
, PyArena
*arena
)
1692 p
= (slice_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1695 p
->kind
= Slice_kind
;
1696 p
->v
.Slice
.lower
= lower
;
1697 p
->v
.Slice
.upper
= upper
;
1698 p
->v
.Slice
.step
= step
;
1703 ExtSlice(asdl_seq
* dims
, PyArena
*arena
)
1706 p
= (slice_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1709 p
->kind
= ExtSlice_kind
;
1710 p
->v
.ExtSlice
.dims
= dims
;
1715 Index(expr_ty value
, PyArena
*arena
)
1719 PyErr_SetString(PyExc_ValueError
,
1720 "field value is required for Index");
1723 p
= (slice_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1726 p
->kind
= Index_kind
;
1727 p
->v
.Index
.value
= value
;
1732 comprehension(expr_ty target
, expr_ty iter
, asdl_seq
* ifs
, PyArena
*arena
)
1736 PyErr_SetString(PyExc_ValueError
,
1737 "field target is required for comprehension");
1741 PyErr_SetString(PyExc_ValueError
,
1742 "field iter is required for comprehension");
1745 p
= (comprehension_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1755 excepthandler(expr_ty type
, expr_ty name
, asdl_seq
* body
, int lineno
, int
1756 col_offset
, PyArena
*arena
)
1759 p
= (excepthandler_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1766 p
->col_offset
= col_offset
;
1771 arguments(asdl_seq
* args
, identifier vararg
, identifier kwarg
, asdl_seq
*
1772 defaults
, PyArena
*arena
)
1775 p
= (arguments_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1781 p
->defaults
= defaults
;
1786 keyword(identifier arg
, expr_ty value
, PyArena
*arena
)
1790 PyErr_SetString(PyExc_ValueError
,
1791 "field arg is required for keyword");
1795 PyErr_SetString(PyExc_ValueError
,
1796 "field value is required for keyword");
1799 p
= (keyword_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1808 alias(identifier name
, identifier asname
, PyArena
*arena
)
1812 PyErr_SetString(PyExc_ValueError
,
1813 "field name is required for alias");
1816 p
= (alias_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1826 ast2obj_mod(void* _o
)
1828 mod_ty o
= (mod_ty
)_o
;
1829 PyObject
*result
= NULL
, *value
= NULL
;
1837 result
= PyType_GenericNew(Module_type
, NULL
, NULL
);
1838 if (!result
) goto failed
;
1839 value
= ast2obj_list(o
->v
.Module
.body
, ast2obj_stmt
);
1840 if (!value
) goto failed
;
1841 if (PyObject_SetAttrString(result
, "body", value
) == -1)
1845 case Interactive_kind
:
1846 result
= PyType_GenericNew(Interactive_type
, NULL
, NULL
);
1847 if (!result
) goto failed
;
1848 value
= ast2obj_list(o
->v
.Interactive
.body
, ast2obj_stmt
);
1849 if (!value
) goto failed
;
1850 if (PyObject_SetAttrString(result
, "body", value
) == -1)
1854 case Expression_kind
:
1855 result
= PyType_GenericNew(Expression_type
, NULL
, NULL
);
1856 if (!result
) goto failed
;
1857 value
= ast2obj_expr(o
->v
.Expression
.body
);
1858 if (!value
) goto failed
;
1859 if (PyObject_SetAttrString(result
, "body", value
) == -1)
1864 result
= PyType_GenericNew(Suite_type
, NULL
, NULL
);
1865 if (!result
) goto failed
;
1866 value
= ast2obj_list(o
->v
.Suite
.body
, ast2obj_stmt
);
1867 if (!value
) goto failed
;
1868 if (PyObject_SetAttrString(result
, "body", value
) == -1)
1881 ast2obj_stmt(void* _o
)
1883 stmt_ty o
= (stmt_ty
)_o
;
1884 PyObject
*result
= NULL
, *value
= NULL
;
1891 case FunctionDef_kind
:
1892 result
= PyType_GenericNew(FunctionDef_type
, NULL
, NULL
);
1893 if (!result
) goto failed
;
1894 value
= ast2obj_identifier(o
->v
.FunctionDef
.name
);
1895 if (!value
) goto failed
;
1896 if (PyObject_SetAttrString(result
, "name", value
) == -1)
1899 value
= ast2obj_arguments(o
->v
.FunctionDef
.args
);
1900 if (!value
) goto failed
;
1901 if (PyObject_SetAttrString(result
, "args", value
) == -1)
1904 value
= ast2obj_list(o
->v
.FunctionDef
.body
, ast2obj_stmt
);
1905 if (!value
) goto failed
;
1906 if (PyObject_SetAttrString(result
, "body", value
) == -1)
1909 value
= ast2obj_list(o
->v
.FunctionDef
.decorators
, ast2obj_expr
);
1910 if (!value
) goto failed
;
1911 if (PyObject_SetAttrString(result
, "decorators", value
) == -1)
1916 result
= PyType_GenericNew(ClassDef_type
, NULL
, NULL
);
1917 if (!result
) goto failed
;
1918 value
= ast2obj_identifier(o
->v
.ClassDef
.name
);
1919 if (!value
) goto failed
;
1920 if (PyObject_SetAttrString(result
, "name", value
) == -1)
1923 value
= ast2obj_list(o
->v
.ClassDef
.bases
, ast2obj_expr
);
1924 if (!value
) goto failed
;
1925 if (PyObject_SetAttrString(result
, "bases", value
) == -1)
1928 value
= ast2obj_list(o
->v
.ClassDef
.body
, ast2obj_stmt
);
1929 if (!value
) goto failed
;
1930 if (PyObject_SetAttrString(result
, "body", value
) == -1)
1935 result
= PyType_GenericNew(Return_type
, NULL
, NULL
);
1936 if (!result
) goto failed
;
1937 value
= ast2obj_expr(o
->v
.Return
.value
);
1938 if (!value
) goto failed
;
1939 if (PyObject_SetAttrString(result
, "value", value
) == -1)
1944 result
= PyType_GenericNew(Delete_type
, NULL
, NULL
);
1945 if (!result
) goto failed
;
1946 value
= ast2obj_list(o
->v
.Delete
.targets
, ast2obj_expr
);
1947 if (!value
) goto failed
;
1948 if (PyObject_SetAttrString(result
, "targets", value
) == -1)
1953 result
= PyType_GenericNew(Assign_type
, NULL
, NULL
);
1954 if (!result
) goto failed
;
1955 value
= ast2obj_list(o
->v
.Assign
.targets
, ast2obj_expr
);
1956 if (!value
) goto failed
;
1957 if (PyObject_SetAttrString(result
, "targets", value
) == -1)
1960 value
= ast2obj_expr(o
->v
.Assign
.value
);
1961 if (!value
) goto failed
;
1962 if (PyObject_SetAttrString(result
, "value", value
) == -1)
1966 case AugAssign_kind
:
1967 result
= PyType_GenericNew(AugAssign_type
, NULL
, NULL
);
1968 if (!result
) goto failed
;
1969 value
= ast2obj_expr(o
->v
.AugAssign
.target
);
1970 if (!value
) goto failed
;
1971 if (PyObject_SetAttrString(result
, "target", value
) == -1)
1974 value
= ast2obj_operator(o
->v
.AugAssign
.op
);
1975 if (!value
) goto failed
;
1976 if (PyObject_SetAttrString(result
, "op", value
) == -1)
1979 value
= ast2obj_expr(o
->v
.AugAssign
.value
);
1980 if (!value
) goto failed
;
1981 if (PyObject_SetAttrString(result
, "value", value
) == -1)
1986 result
= PyType_GenericNew(Print_type
, NULL
, NULL
);
1987 if (!result
) goto failed
;
1988 value
= ast2obj_expr(o
->v
.Print
.dest
);
1989 if (!value
) goto failed
;
1990 if (PyObject_SetAttrString(result
, "dest", value
) == -1)
1993 value
= ast2obj_list(o
->v
.Print
.values
, ast2obj_expr
);
1994 if (!value
) goto failed
;
1995 if (PyObject_SetAttrString(result
, "values", value
) == -1)
1998 value
= ast2obj_bool(o
->v
.Print
.nl
);
1999 if (!value
) goto failed
;
2000 if (PyObject_SetAttrString(result
, "nl", value
) == -1)
2005 result
= PyType_GenericNew(For_type
, NULL
, NULL
);
2006 if (!result
) goto failed
;
2007 value
= ast2obj_expr(o
->v
.For
.target
);
2008 if (!value
) goto failed
;
2009 if (PyObject_SetAttrString(result
, "target", value
) == -1)
2012 value
= ast2obj_expr(o
->v
.For
.iter
);
2013 if (!value
) goto failed
;
2014 if (PyObject_SetAttrString(result
, "iter", value
) == -1)
2017 value
= ast2obj_list(o
->v
.For
.body
, ast2obj_stmt
);
2018 if (!value
) goto failed
;
2019 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2022 value
= ast2obj_list(o
->v
.For
.orelse
, ast2obj_stmt
);
2023 if (!value
) goto failed
;
2024 if (PyObject_SetAttrString(result
, "orelse", value
) == -1)
2029 result
= PyType_GenericNew(While_type
, NULL
, NULL
);
2030 if (!result
) goto failed
;
2031 value
= ast2obj_expr(o
->v
.While
.test
);
2032 if (!value
) goto failed
;
2033 if (PyObject_SetAttrString(result
, "test", value
) == -1)
2036 value
= ast2obj_list(o
->v
.While
.body
, ast2obj_stmt
);
2037 if (!value
) goto failed
;
2038 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2041 value
= ast2obj_list(o
->v
.While
.orelse
, ast2obj_stmt
);
2042 if (!value
) goto failed
;
2043 if (PyObject_SetAttrString(result
, "orelse", value
) == -1)
2048 result
= PyType_GenericNew(If_type
, NULL
, NULL
);
2049 if (!result
) goto failed
;
2050 value
= ast2obj_expr(o
->v
.If
.test
);
2051 if (!value
) goto failed
;
2052 if (PyObject_SetAttrString(result
, "test", value
) == -1)
2055 value
= ast2obj_list(o
->v
.If
.body
, ast2obj_stmt
);
2056 if (!value
) goto failed
;
2057 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2060 value
= ast2obj_list(o
->v
.If
.orelse
, ast2obj_stmt
);
2061 if (!value
) goto failed
;
2062 if (PyObject_SetAttrString(result
, "orelse", value
) == -1)
2067 result
= PyType_GenericNew(With_type
, NULL
, NULL
);
2068 if (!result
) goto failed
;
2069 value
= ast2obj_expr(o
->v
.With
.context_expr
);
2070 if (!value
) goto failed
;
2071 if (PyObject_SetAttrString(result
, "context_expr", value
) == -1)
2074 value
= ast2obj_expr(o
->v
.With
.optional_vars
);
2075 if (!value
) goto failed
;
2076 if (PyObject_SetAttrString(result
, "optional_vars", value
) ==
2080 value
= ast2obj_list(o
->v
.With
.body
, ast2obj_stmt
);
2081 if (!value
) goto failed
;
2082 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2087 result
= PyType_GenericNew(Raise_type
, NULL
, NULL
);
2088 if (!result
) goto failed
;
2089 value
= ast2obj_expr(o
->v
.Raise
.type
);
2090 if (!value
) goto failed
;
2091 if (PyObject_SetAttrString(result
, "type", value
) == -1)
2094 value
= ast2obj_expr(o
->v
.Raise
.inst
);
2095 if (!value
) goto failed
;
2096 if (PyObject_SetAttrString(result
, "inst", value
) == -1)
2099 value
= ast2obj_expr(o
->v
.Raise
.tback
);
2100 if (!value
) goto failed
;
2101 if (PyObject_SetAttrString(result
, "tback", value
) == -1)
2105 case TryExcept_kind
:
2106 result
= PyType_GenericNew(TryExcept_type
, NULL
, NULL
);
2107 if (!result
) goto failed
;
2108 value
= ast2obj_list(o
->v
.TryExcept
.body
, ast2obj_stmt
);
2109 if (!value
) goto failed
;
2110 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2113 value
= ast2obj_list(o
->v
.TryExcept
.handlers
,
2114 ast2obj_excepthandler
);
2115 if (!value
) goto failed
;
2116 if (PyObject_SetAttrString(result
, "handlers", value
) == -1)
2119 value
= ast2obj_list(o
->v
.TryExcept
.orelse
, ast2obj_stmt
);
2120 if (!value
) goto failed
;
2121 if (PyObject_SetAttrString(result
, "orelse", value
) == -1)
2125 case TryFinally_kind
:
2126 result
= PyType_GenericNew(TryFinally_type
, NULL
, NULL
);
2127 if (!result
) goto failed
;
2128 value
= ast2obj_list(o
->v
.TryFinally
.body
, ast2obj_stmt
);
2129 if (!value
) goto failed
;
2130 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2133 value
= ast2obj_list(o
->v
.TryFinally
.finalbody
, ast2obj_stmt
);
2134 if (!value
) goto failed
;
2135 if (PyObject_SetAttrString(result
, "finalbody", value
) == -1)
2140 result
= PyType_GenericNew(Assert_type
, NULL
, NULL
);
2141 if (!result
) goto failed
;
2142 value
= ast2obj_expr(o
->v
.Assert
.test
);
2143 if (!value
) goto failed
;
2144 if (PyObject_SetAttrString(result
, "test", value
) == -1)
2147 value
= ast2obj_expr(o
->v
.Assert
.msg
);
2148 if (!value
) goto failed
;
2149 if (PyObject_SetAttrString(result
, "msg", value
) == -1)
2154 result
= PyType_GenericNew(Import_type
, NULL
, NULL
);
2155 if (!result
) goto failed
;
2156 value
= ast2obj_list(o
->v
.Import
.names
, ast2obj_alias
);
2157 if (!value
) goto failed
;
2158 if (PyObject_SetAttrString(result
, "names", value
) == -1)
2162 case ImportFrom_kind
:
2163 result
= PyType_GenericNew(ImportFrom_type
, NULL
, NULL
);
2164 if (!result
) goto failed
;
2165 value
= ast2obj_identifier(o
->v
.ImportFrom
.module
);
2166 if (!value
) goto failed
;
2167 if (PyObject_SetAttrString(result
, "module", value
) == -1)
2170 value
= ast2obj_list(o
->v
.ImportFrom
.names
, ast2obj_alias
);
2171 if (!value
) goto failed
;
2172 if (PyObject_SetAttrString(result
, "names", value
) == -1)
2175 value
= ast2obj_int(o
->v
.ImportFrom
.level
);
2176 if (!value
) goto failed
;
2177 if (PyObject_SetAttrString(result
, "level", value
) == -1)
2182 result
= PyType_GenericNew(Exec_type
, NULL
, NULL
);
2183 if (!result
) goto failed
;
2184 value
= ast2obj_expr(o
->v
.Exec
.body
);
2185 if (!value
) goto failed
;
2186 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2189 value
= ast2obj_expr(o
->v
.Exec
.globals
);
2190 if (!value
) goto failed
;
2191 if (PyObject_SetAttrString(result
, "globals", value
) == -1)
2194 value
= ast2obj_expr(o
->v
.Exec
.locals
);
2195 if (!value
) goto failed
;
2196 if (PyObject_SetAttrString(result
, "locals", value
) == -1)
2201 result
= PyType_GenericNew(Global_type
, NULL
, NULL
);
2202 if (!result
) goto failed
;
2203 value
= ast2obj_list(o
->v
.Global
.names
, ast2obj_identifier
);
2204 if (!value
) goto failed
;
2205 if (PyObject_SetAttrString(result
, "names", value
) == -1)
2210 result
= PyType_GenericNew(Expr_type
, NULL
, NULL
);
2211 if (!result
) goto failed
;
2212 value
= ast2obj_expr(o
->v
.Expr
.value
);
2213 if (!value
) goto failed
;
2214 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2219 result
= PyType_GenericNew(Pass_type
, NULL
, NULL
);
2220 if (!result
) goto failed
;
2223 result
= PyType_GenericNew(Break_type
, NULL
, NULL
);
2224 if (!result
) goto failed
;
2227 result
= PyType_GenericNew(Continue_type
, NULL
, NULL
);
2228 if (!result
) goto failed
;
2231 value
= ast2obj_int(o
->lineno
);
2232 if (!value
) goto failed
;
2233 if (PyObject_SetAttrString(result
, "lineno", value
) < 0)
2236 value
= ast2obj_int(o
->col_offset
);
2237 if (!value
) goto failed
;
2238 if (PyObject_SetAttrString(result
, "col_offset", value
) < 0)
2249 ast2obj_expr(void* _o
)
2251 expr_ty o
= (expr_ty
)_o
;
2252 PyObject
*result
= NULL
, *value
= NULL
;
2260 result
= PyType_GenericNew(BoolOp_type
, NULL
, NULL
);
2261 if (!result
) goto failed
;
2262 value
= ast2obj_boolop(o
->v
.BoolOp
.op
);
2263 if (!value
) goto failed
;
2264 if (PyObject_SetAttrString(result
, "op", value
) == -1)
2267 value
= ast2obj_list(o
->v
.BoolOp
.values
, ast2obj_expr
);
2268 if (!value
) goto failed
;
2269 if (PyObject_SetAttrString(result
, "values", value
) == -1)
2274 result
= PyType_GenericNew(BinOp_type
, NULL
, NULL
);
2275 if (!result
) goto failed
;
2276 value
= ast2obj_expr(o
->v
.BinOp
.left
);
2277 if (!value
) goto failed
;
2278 if (PyObject_SetAttrString(result
, "left", value
) == -1)
2281 value
= ast2obj_operator(o
->v
.BinOp
.op
);
2282 if (!value
) goto failed
;
2283 if (PyObject_SetAttrString(result
, "op", value
) == -1)
2286 value
= ast2obj_expr(o
->v
.BinOp
.right
);
2287 if (!value
) goto failed
;
2288 if (PyObject_SetAttrString(result
, "right", value
) == -1)
2293 result
= PyType_GenericNew(UnaryOp_type
, NULL
, NULL
);
2294 if (!result
) goto failed
;
2295 value
= ast2obj_unaryop(o
->v
.UnaryOp
.op
);
2296 if (!value
) goto failed
;
2297 if (PyObject_SetAttrString(result
, "op", value
) == -1)
2300 value
= ast2obj_expr(o
->v
.UnaryOp
.operand
);
2301 if (!value
) goto failed
;
2302 if (PyObject_SetAttrString(result
, "operand", value
) == -1)
2307 result
= PyType_GenericNew(Lambda_type
, NULL
, NULL
);
2308 if (!result
) goto failed
;
2309 value
= ast2obj_arguments(o
->v
.Lambda
.args
);
2310 if (!value
) goto failed
;
2311 if (PyObject_SetAttrString(result
, "args", value
) == -1)
2314 value
= ast2obj_expr(o
->v
.Lambda
.body
);
2315 if (!value
) goto failed
;
2316 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2321 result
= PyType_GenericNew(IfExp_type
, NULL
, NULL
);
2322 if (!result
) goto failed
;
2323 value
= ast2obj_expr(o
->v
.IfExp
.test
);
2324 if (!value
) goto failed
;
2325 if (PyObject_SetAttrString(result
, "test", value
) == -1)
2328 value
= ast2obj_expr(o
->v
.IfExp
.body
);
2329 if (!value
) goto failed
;
2330 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2333 value
= ast2obj_expr(o
->v
.IfExp
.orelse
);
2334 if (!value
) goto failed
;
2335 if (PyObject_SetAttrString(result
, "orelse", value
) == -1)
2340 result
= PyType_GenericNew(Dict_type
, NULL
, NULL
);
2341 if (!result
) goto failed
;
2342 value
= ast2obj_list(o
->v
.Dict
.keys
, ast2obj_expr
);
2343 if (!value
) goto failed
;
2344 if (PyObject_SetAttrString(result
, "keys", value
) == -1)
2347 value
= ast2obj_list(o
->v
.Dict
.values
, ast2obj_expr
);
2348 if (!value
) goto failed
;
2349 if (PyObject_SetAttrString(result
, "values", value
) == -1)
2354 result
= PyType_GenericNew(ListComp_type
, NULL
, NULL
);
2355 if (!result
) goto failed
;
2356 value
= ast2obj_expr(o
->v
.ListComp
.elt
);
2357 if (!value
) goto failed
;
2358 if (PyObject_SetAttrString(result
, "elt", value
) == -1)
2361 value
= ast2obj_list(o
->v
.ListComp
.generators
,
2362 ast2obj_comprehension
);
2363 if (!value
) goto failed
;
2364 if (PyObject_SetAttrString(result
, "generators", value
) == -1)
2368 case GeneratorExp_kind
:
2369 result
= PyType_GenericNew(GeneratorExp_type
, NULL
, NULL
);
2370 if (!result
) goto failed
;
2371 value
= ast2obj_expr(o
->v
.GeneratorExp
.elt
);
2372 if (!value
) goto failed
;
2373 if (PyObject_SetAttrString(result
, "elt", value
) == -1)
2376 value
= ast2obj_list(o
->v
.GeneratorExp
.generators
,
2377 ast2obj_comprehension
);
2378 if (!value
) goto failed
;
2379 if (PyObject_SetAttrString(result
, "generators", value
) == -1)
2384 result
= PyType_GenericNew(Yield_type
, NULL
, NULL
);
2385 if (!result
) goto failed
;
2386 value
= ast2obj_expr(o
->v
.Yield
.value
);
2387 if (!value
) goto failed
;
2388 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2393 result
= PyType_GenericNew(Compare_type
, NULL
, NULL
);
2394 if (!result
) goto failed
;
2395 value
= ast2obj_expr(o
->v
.Compare
.left
);
2396 if (!value
) goto failed
;
2397 if (PyObject_SetAttrString(result
, "left", value
) == -1)
2401 int i
, n
= asdl_seq_LEN(o
->v
.Compare
.ops
);
2402 value
= PyList_New(n
);
2403 if (!value
) goto failed
;
2404 for(i
= 0; i
< n
; i
++)
2405 PyList_SET_ITEM(value
, i
, ast2obj_cmpop((cmpop_ty
)asdl_seq_GET(o
->v
.Compare
.ops
, i
)));
2407 if (!value
) goto failed
;
2408 if (PyObject_SetAttrString(result
, "ops", value
) == -1)
2411 value
= ast2obj_list(o
->v
.Compare
.comparators
, ast2obj_expr
);
2412 if (!value
) goto failed
;
2413 if (PyObject_SetAttrString(result
, "comparators", value
) == -1)
2418 result
= PyType_GenericNew(Call_type
, NULL
, NULL
);
2419 if (!result
) goto failed
;
2420 value
= ast2obj_expr(o
->v
.Call
.func
);
2421 if (!value
) goto failed
;
2422 if (PyObject_SetAttrString(result
, "func", value
) == -1)
2425 value
= ast2obj_list(o
->v
.Call
.args
, ast2obj_expr
);
2426 if (!value
) goto failed
;
2427 if (PyObject_SetAttrString(result
, "args", value
) == -1)
2430 value
= ast2obj_list(o
->v
.Call
.keywords
, ast2obj_keyword
);
2431 if (!value
) goto failed
;
2432 if (PyObject_SetAttrString(result
, "keywords", value
) == -1)
2435 value
= ast2obj_expr(o
->v
.Call
.starargs
);
2436 if (!value
) goto failed
;
2437 if (PyObject_SetAttrString(result
, "starargs", value
) == -1)
2440 value
= ast2obj_expr(o
->v
.Call
.kwargs
);
2441 if (!value
) goto failed
;
2442 if (PyObject_SetAttrString(result
, "kwargs", value
) == -1)
2447 result
= PyType_GenericNew(Repr_type
, NULL
, NULL
);
2448 if (!result
) goto failed
;
2449 value
= ast2obj_expr(o
->v
.Repr
.value
);
2450 if (!value
) goto failed
;
2451 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2456 result
= PyType_GenericNew(Num_type
, NULL
, NULL
);
2457 if (!result
) goto failed
;
2458 value
= ast2obj_object(o
->v
.Num
.n
);
2459 if (!value
) goto failed
;
2460 if (PyObject_SetAttrString(result
, "n", value
) == -1)
2465 result
= PyType_GenericNew(Str_type
, NULL
, NULL
);
2466 if (!result
) goto failed
;
2467 value
= ast2obj_string(o
->v
.Str
.s
);
2468 if (!value
) goto failed
;
2469 if (PyObject_SetAttrString(result
, "s", value
) == -1)
2473 case Attribute_kind
:
2474 result
= PyType_GenericNew(Attribute_type
, NULL
, NULL
);
2475 if (!result
) goto failed
;
2476 value
= ast2obj_expr(o
->v
.Attribute
.value
);
2477 if (!value
) goto failed
;
2478 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2481 value
= ast2obj_identifier(o
->v
.Attribute
.attr
);
2482 if (!value
) goto failed
;
2483 if (PyObject_SetAttrString(result
, "attr", value
) == -1)
2486 value
= ast2obj_expr_context(o
->v
.Attribute
.ctx
);
2487 if (!value
) goto failed
;
2488 if (PyObject_SetAttrString(result
, "ctx", value
) == -1)
2492 case Subscript_kind
:
2493 result
= PyType_GenericNew(Subscript_type
, NULL
, NULL
);
2494 if (!result
) goto failed
;
2495 value
= ast2obj_expr(o
->v
.Subscript
.value
);
2496 if (!value
) goto failed
;
2497 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2500 value
= ast2obj_slice(o
->v
.Subscript
.slice
);
2501 if (!value
) goto failed
;
2502 if (PyObject_SetAttrString(result
, "slice", value
) == -1)
2505 value
= ast2obj_expr_context(o
->v
.Subscript
.ctx
);
2506 if (!value
) goto failed
;
2507 if (PyObject_SetAttrString(result
, "ctx", value
) == -1)
2512 result
= PyType_GenericNew(Name_type
, NULL
, NULL
);
2513 if (!result
) goto failed
;
2514 value
= ast2obj_identifier(o
->v
.Name
.id
);
2515 if (!value
) goto failed
;
2516 if (PyObject_SetAttrString(result
, "id", value
) == -1)
2519 value
= ast2obj_expr_context(o
->v
.Name
.ctx
);
2520 if (!value
) goto failed
;
2521 if (PyObject_SetAttrString(result
, "ctx", value
) == -1)
2526 result
= PyType_GenericNew(List_type
, NULL
, NULL
);
2527 if (!result
) goto failed
;
2528 value
= ast2obj_list(o
->v
.List
.elts
, ast2obj_expr
);
2529 if (!value
) goto failed
;
2530 if (PyObject_SetAttrString(result
, "elts", value
) == -1)
2533 value
= ast2obj_expr_context(o
->v
.List
.ctx
);
2534 if (!value
) goto failed
;
2535 if (PyObject_SetAttrString(result
, "ctx", value
) == -1)
2540 result
= PyType_GenericNew(Tuple_type
, NULL
, NULL
);
2541 if (!result
) goto failed
;
2542 value
= ast2obj_list(o
->v
.Tuple
.elts
, ast2obj_expr
);
2543 if (!value
) goto failed
;
2544 if (PyObject_SetAttrString(result
, "elts", value
) == -1)
2547 value
= ast2obj_expr_context(o
->v
.Tuple
.ctx
);
2548 if (!value
) goto failed
;
2549 if (PyObject_SetAttrString(result
, "ctx", value
) == -1)
2554 value
= ast2obj_int(o
->lineno
);
2555 if (!value
) goto failed
;
2556 if (PyObject_SetAttrString(result
, "lineno", value
) < 0)
2559 value
= ast2obj_int(o
->col_offset
);
2560 if (!value
) goto failed
;
2561 if (PyObject_SetAttrString(result
, "col_offset", value
) < 0)
2571 PyObject
* ast2obj_expr_context(expr_context_ty o
)
2575 Py_INCREF(Load_singleton
);
2576 return Load_singleton
;
2578 Py_INCREF(Store_singleton
);
2579 return Store_singleton
;
2581 Py_INCREF(Del_singleton
);
2582 return Del_singleton
;
2584 Py_INCREF(AugLoad_singleton
);
2585 return AugLoad_singleton
;
2587 Py_INCREF(AugStore_singleton
);
2588 return AugStore_singleton
;
2590 Py_INCREF(Param_singleton
);
2591 return Param_singleton
;
2593 return NULL
; /* cannot happen */
2596 ast2obj_slice(void* _o
)
2598 slice_ty o
= (slice_ty
)_o
;
2599 PyObject
*result
= NULL
, *value
= NULL
;
2607 result
= PyType_GenericNew(Ellipsis_type
, NULL
, NULL
);
2608 if (!result
) goto failed
;
2611 result
= PyType_GenericNew(Slice_type
, NULL
, NULL
);
2612 if (!result
) goto failed
;
2613 value
= ast2obj_expr(o
->v
.Slice
.lower
);
2614 if (!value
) goto failed
;
2615 if (PyObject_SetAttrString(result
, "lower", value
) == -1)
2618 value
= ast2obj_expr(o
->v
.Slice
.upper
);
2619 if (!value
) goto failed
;
2620 if (PyObject_SetAttrString(result
, "upper", value
) == -1)
2623 value
= ast2obj_expr(o
->v
.Slice
.step
);
2624 if (!value
) goto failed
;
2625 if (PyObject_SetAttrString(result
, "step", value
) == -1)
2630 result
= PyType_GenericNew(ExtSlice_type
, NULL
, NULL
);
2631 if (!result
) goto failed
;
2632 value
= ast2obj_list(o
->v
.ExtSlice
.dims
, ast2obj_slice
);
2633 if (!value
) goto failed
;
2634 if (PyObject_SetAttrString(result
, "dims", value
) == -1)
2639 result
= PyType_GenericNew(Index_type
, NULL
, NULL
);
2640 if (!result
) goto failed
;
2641 value
= ast2obj_expr(o
->v
.Index
.value
);
2642 if (!value
) goto failed
;
2643 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2655 PyObject
* ast2obj_boolop(boolop_ty o
)
2659 Py_INCREF(And_singleton
);
2660 return And_singleton
;
2662 Py_INCREF(Or_singleton
);
2663 return Or_singleton
;
2665 return NULL
; /* cannot happen */
2667 PyObject
* ast2obj_operator(operator_ty o
)
2671 Py_INCREF(Add_singleton
);
2672 return Add_singleton
;
2674 Py_INCREF(Sub_singleton
);
2675 return Sub_singleton
;
2677 Py_INCREF(Mult_singleton
);
2678 return Mult_singleton
;
2680 Py_INCREF(Div_singleton
);
2681 return Div_singleton
;
2683 Py_INCREF(Mod_singleton
);
2684 return Mod_singleton
;
2686 Py_INCREF(Pow_singleton
);
2687 return Pow_singleton
;
2689 Py_INCREF(LShift_singleton
);
2690 return LShift_singleton
;
2692 Py_INCREF(RShift_singleton
);
2693 return RShift_singleton
;
2695 Py_INCREF(BitOr_singleton
);
2696 return BitOr_singleton
;
2698 Py_INCREF(BitXor_singleton
);
2699 return BitXor_singleton
;
2701 Py_INCREF(BitAnd_singleton
);
2702 return BitAnd_singleton
;
2704 Py_INCREF(FloorDiv_singleton
);
2705 return FloorDiv_singleton
;
2707 return NULL
; /* cannot happen */
2709 PyObject
* ast2obj_unaryop(unaryop_ty o
)
2713 Py_INCREF(Invert_singleton
);
2714 return Invert_singleton
;
2716 Py_INCREF(Not_singleton
);
2717 return Not_singleton
;
2719 Py_INCREF(UAdd_singleton
);
2720 return UAdd_singleton
;
2722 Py_INCREF(USub_singleton
);
2723 return USub_singleton
;
2725 return NULL
; /* cannot happen */
2727 PyObject
* ast2obj_cmpop(cmpop_ty o
)
2731 Py_INCREF(Eq_singleton
);
2732 return Eq_singleton
;
2734 Py_INCREF(NotEq_singleton
);
2735 return NotEq_singleton
;
2737 Py_INCREF(Lt_singleton
);
2738 return Lt_singleton
;
2740 Py_INCREF(LtE_singleton
);
2741 return LtE_singleton
;
2743 Py_INCREF(Gt_singleton
);
2744 return Gt_singleton
;
2746 Py_INCREF(GtE_singleton
);
2747 return GtE_singleton
;
2749 Py_INCREF(Is_singleton
);
2750 return Is_singleton
;
2752 Py_INCREF(IsNot_singleton
);
2753 return IsNot_singleton
;
2755 Py_INCREF(In_singleton
);
2756 return In_singleton
;
2758 Py_INCREF(NotIn_singleton
);
2759 return NotIn_singleton
;
2761 return NULL
; /* cannot happen */
2764 ast2obj_comprehension(void* _o
)
2766 comprehension_ty o
= (comprehension_ty
)_o
;
2767 PyObject
*result
= NULL
, *value
= NULL
;
2773 result
= PyType_GenericNew(comprehension_type
, NULL
, NULL
);
2774 if (!result
) return NULL
;
2775 value
= ast2obj_expr(o
->target
);
2776 if (!value
) goto failed
;
2777 if (PyObject_SetAttrString(result
, "target", value
) == -1)
2780 value
= ast2obj_expr(o
->iter
);
2781 if (!value
) goto failed
;
2782 if (PyObject_SetAttrString(result
, "iter", value
) == -1)
2785 value
= ast2obj_list(o
->ifs
, ast2obj_expr
);
2786 if (!value
) goto failed
;
2787 if (PyObject_SetAttrString(result
, "ifs", value
) == -1)
2798 ast2obj_excepthandler(void* _o
)
2800 excepthandler_ty o
= (excepthandler_ty
)_o
;
2801 PyObject
*result
= NULL
, *value
= NULL
;
2807 result
= PyType_GenericNew(excepthandler_type
, NULL
, NULL
);
2808 if (!result
) return NULL
;
2809 value
= ast2obj_expr(o
->type
);
2810 if (!value
) goto failed
;
2811 if (PyObject_SetAttrString(result
, "type", value
) == -1)
2814 value
= ast2obj_expr(o
->name
);
2815 if (!value
) goto failed
;
2816 if (PyObject_SetAttrString(result
, "name", value
) == -1)
2819 value
= ast2obj_list(o
->body
, ast2obj_stmt
);
2820 if (!value
) goto failed
;
2821 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2824 value
= ast2obj_int(o
->lineno
);
2825 if (!value
) goto failed
;
2826 if (PyObject_SetAttrString(result
, "lineno", value
) == -1)
2829 value
= ast2obj_int(o
->col_offset
);
2830 if (!value
) goto failed
;
2831 if (PyObject_SetAttrString(result
, "col_offset", value
) == -1)
2842 ast2obj_arguments(void* _o
)
2844 arguments_ty o
= (arguments_ty
)_o
;
2845 PyObject
*result
= NULL
, *value
= NULL
;
2851 result
= PyType_GenericNew(arguments_type
, NULL
, NULL
);
2852 if (!result
) return NULL
;
2853 value
= ast2obj_list(o
->args
, ast2obj_expr
);
2854 if (!value
) goto failed
;
2855 if (PyObject_SetAttrString(result
, "args", value
) == -1)
2858 value
= ast2obj_identifier(o
->vararg
);
2859 if (!value
) goto failed
;
2860 if (PyObject_SetAttrString(result
, "vararg", value
) == -1)
2863 value
= ast2obj_identifier(o
->kwarg
);
2864 if (!value
) goto failed
;
2865 if (PyObject_SetAttrString(result
, "kwarg", value
) == -1)
2868 value
= ast2obj_list(o
->defaults
, ast2obj_expr
);
2869 if (!value
) goto failed
;
2870 if (PyObject_SetAttrString(result
, "defaults", value
) == -1)
2881 ast2obj_keyword(void* _o
)
2883 keyword_ty o
= (keyword_ty
)_o
;
2884 PyObject
*result
= NULL
, *value
= NULL
;
2890 result
= PyType_GenericNew(keyword_type
, NULL
, NULL
);
2891 if (!result
) return NULL
;
2892 value
= ast2obj_identifier(o
->arg
);
2893 if (!value
) goto failed
;
2894 if (PyObject_SetAttrString(result
, "arg", value
) == -1)
2897 value
= ast2obj_expr(o
->value
);
2898 if (!value
) goto failed
;
2899 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2910 ast2obj_alias(void* _o
)
2912 alias_ty o
= (alias_ty
)_o
;
2913 PyObject
*result
= NULL
, *value
= NULL
;
2919 result
= PyType_GenericNew(alias_type
, NULL
, NULL
);
2920 if (!result
) return NULL
;
2921 value
= ast2obj_identifier(o
->name
);
2922 if (!value
) goto failed
;
2923 if (PyObject_SetAttrString(result
, "name", value
) == -1)
2926 value
= ast2obj_identifier(o
->asname
);
2927 if (!value
) goto failed
;
2928 if (PyObject_SetAttrString(result
, "asname", value
) == -1)
2943 if (!init_types()) return;
2944 m
= Py_InitModule3("_ast", NULL
, NULL
);
2946 d
= PyModule_GetDict(m
);
2947 if (PyDict_SetItemString(d
, "AST", (PyObject
*)AST_type
) < 0) return;
2948 if (PyModule_AddIntConstant(m
, "PyCF_ONLY_AST", PyCF_ONLY_AST
) < 0)
2950 if (PyModule_AddStringConstant(m
, "__version__", "53731") < 0)
2952 if (PyDict_SetItemString(d
, "mod", (PyObject
*)mod_type
) < 0) return;
2953 if (PyDict_SetItemString(d
, "Module", (PyObject
*)Module_type
) < 0)
2955 if (PyDict_SetItemString(d
, "Interactive", (PyObject
*)Interactive_type
)
2957 if (PyDict_SetItemString(d
, "Expression", (PyObject
*)Expression_type
) <
2959 if (PyDict_SetItemString(d
, "Suite", (PyObject
*)Suite_type
) < 0) return;
2960 if (PyDict_SetItemString(d
, "stmt", (PyObject
*)stmt_type
) < 0) return;
2961 if (PyDict_SetItemString(d
, "FunctionDef", (PyObject
*)FunctionDef_type
)
2963 if (PyDict_SetItemString(d
, "ClassDef", (PyObject
*)ClassDef_type
) < 0)
2965 if (PyDict_SetItemString(d
, "Return", (PyObject
*)Return_type
) < 0)
2967 if (PyDict_SetItemString(d
, "Delete", (PyObject
*)Delete_type
) < 0)
2969 if (PyDict_SetItemString(d
, "Assign", (PyObject
*)Assign_type
) < 0)
2971 if (PyDict_SetItemString(d
, "AugAssign", (PyObject
*)AugAssign_type
) <
2973 if (PyDict_SetItemString(d
, "Print", (PyObject
*)Print_type
) < 0) return;
2974 if (PyDict_SetItemString(d
, "For", (PyObject
*)For_type
) < 0) return;
2975 if (PyDict_SetItemString(d
, "While", (PyObject
*)While_type
) < 0) return;
2976 if (PyDict_SetItemString(d
, "If", (PyObject
*)If_type
) < 0) return;
2977 if (PyDict_SetItemString(d
, "With", (PyObject
*)With_type
) < 0) return;
2978 if (PyDict_SetItemString(d
, "Raise", (PyObject
*)Raise_type
) < 0) return;
2979 if (PyDict_SetItemString(d
, "TryExcept", (PyObject
*)TryExcept_type
) <
2981 if (PyDict_SetItemString(d
, "TryFinally", (PyObject
*)TryFinally_type
) <
2983 if (PyDict_SetItemString(d
, "Assert", (PyObject
*)Assert_type
) < 0)
2985 if (PyDict_SetItemString(d
, "Import", (PyObject
*)Import_type
) < 0)
2987 if (PyDict_SetItemString(d
, "ImportFrom", (PyObject
*)ImportFrom_type
) <
2989 if (PyDict_SetItemString(d
, "Exec", (PyObject
*)Exec_type
) < 0) return;
2990 if (PyDict_SetItemString(d
, "Global", (PyObject
*)Global_type
) < 0)
2992 if (PyDict_SetItemString(d
, "Expr", (PyObject
*)Expr_type
) < 0) return;
2993 if (PyDict_SetItemString(d
, "Pass", (PyObject
*)Pass_type
) < 0) return;
2994 if (PyDict_SetItemString(d
, "Break", (PyObject
*)Break_type
) < 0) return;
2995 if (PyDict_SetItemString(d
, "Continue", (PyObject
*)Continue_type
) < 0)
2997 if (PyDict_SetItemString(d
, "expr", (PyObject
*)expr_type
) < 0) return;
2998 if (PyDict_SetItemString(d
, "BoolOp", (PyObject
*)BoolOp_type
) < 0)
3000 if (PyDict_SetItemString(d
, "BinOp", (PyObject
*)BinOp_type
) < 0) return;
3001 if (PyDict_SetItemString(d
, "UnaryOp", (PyObject
*)UnaryOp_type
) < 0)
3003 if (PyDict_SetItemString(d
, "Lambda", (PyObject
*)Lambda_type
) < 0)
3005 if (PyDict_SetItemString(d
, "IfExp", (PyObject
*)IfExp_type
) < 0) return;
3006 if (PyDict_SetItemString(d
, "Dict", (PyObject
*)Dict_type
) < 0) return;
3007 if (PyDict_SetItemString(d
, "ListComp", (PyObject
*)ListComp_type
) < 0)
3009 if (PyDict_SetItemString(d
, "GeneratorExp",
3010 (PyObject
*)GeneratorExp_type
) < 0) return;
3011 if (PyDict_SetItemString(d
, "Yield", (PyObject
*)Yield_type
) < 0) return;
3012 if (PyDict_SetItemString(d
, "Compare", (PyObject
*)Compare_type
) < 0)
3014 if (PyDict_SetItemString(d
, "Call", (PyObject
*)Call_type
) < 0) return;
3015 if (PyDict_SetItemString(d
, "Repr", (PyObject
*)Repr_type
) < 0) return;
3016 if (PyDict_SetItemString(d
, "Num", (PyObject
*)Num_type
) < 0) return;
3017 if (PyDict_SetItemString(d
, "Str", (PyObject
*)Str_type
) < 0) return;
3018 if (PyDict_SetItemString(d
, "Attribute", (PyObject
*)Attribute_type
) <
3020 if (PyDict_SetItemString(d
, "Subscript", (PyObject
*)Subscript_type
) <
3022 if (PyDict_SetItemString(d
, "Name", (PyObject
*)Name_type
) < 0) return;
3023 if (PyDict_SetItemString(d
, "List", (PyObject
*)List_type
) < 0) return;
3024 if (PyDict_SetItemString(d
, "Tuple", (PyObject
*)Tuple_type
) < 0) return;
3025 if (PyDict_SetItemString(d
, "expr_context",
3026 (PyObject
*)expr_context_type
) < 0) return;
3027 if (PyDict_SetItemString(d
, "Load", (PyObject
*)Load_type
) < 0) return;
3028 if (PyDict_SetItemString(d
, "Store", (PyObject
*)Store_type
) < 0) return;
3029 if (PyDict_SetItemString(d
, "Del", (PyObject
*)Del_type
) < 0) return;
3030 if (PyDict_SetItemString(d
, "AugLoad", (PyObject
*)AugLoad_type
) < 0)
3032 if (PyDict_SetItemString(d
, "AugStore", (PyObject
*)AugStore_type
) < 0)
3034 if (PyDict_SetItemString(d
, "Param", (PyObject
*)Param_type
) < 0) return;
3035 if (PyDict_SetItemString(d
, "slice", (PyObject
*)slice_type
) < 0) return;
3036 if (PyDict_SetItemString(d
, "Ellipsis", (PyObject
*)Ellipsis_type
) < 0)
3038 if (PyDict_SetItemString(d
, "Slice", (PyObject
*)Slice_type
) < 0) return;
3039 if (PyDict_SetItemString(d
, "ExtSlice", (PyObject
*)ExtSlice_type
) < 0)
3041 if (PyDict_SetItemString(d
, "Index", (PyObject
*)Index_type
) < 0) return;
3042 if (PyDict_SetItemString(d
, "boolop", (PyObject
*)boolop_type
) < 0)
3044 if (PyDict_SetItemString(d
, "And", (PyObject
*)And_type
) < 0) return;
3045 if (PyDict_SetItemString(d
, "Or", (PyObject
*)Or_type
) < 0) return;
3046 if (PyDict_SetItemString(d
, "operator", (PyObject
*)operator_type
) < 0)
3048 if (PyDict_SetItemString(d
, "Add", (PyObject
*)Add_type
) < 0) return;
3049 if (PyDict_SetItemString(d
, "Sub", (PyObject
*)Sub_type
) < 0) return;
3050 if (PyDict_SetItemString(d
, "Mult", (PyObject
*)Mult_type
) < 0) return;
3051 if (PyDict_SetItemString(d
, "Div", (PyObject
*)Div_type
) < 0) return;
3052 if (PyDict_SetItemString(d
, "Mod", (PyObject
*)Mod_type
) < 0) return;
3053 if (PyDict_SetItemString(d
, "Pow", (PyObject
*)Pow_type
) < 0) return;
3054 if (PyDict_SetItemString(d
, "LShift", (PyObject
*)LShift_type
) < 0)
3056 if (PyDict_SetItemString(d
, "RShift", (PyObject
*)RShift_type
) < 0)
3058 if (PyDict_SetItemString(d
, "BitOr", (PyObject
*)BitOr_type
) < 0) return;
3059 if (PyDict_SetItemString(d
, "BitXor", (PyObject
*)BitXor_type
) < 0)
3061 if (PyDict_SetItemString(d
, "BitAnd", (PyObject
*)BitAnd_type
) < 0)
3063 if (PyDict_SetItemString(d
, "FloorDiv", (PyObject
*)FloorDiv_type
) < 0)
3065 if (PyDict_SetItemString(d
, "unaryop", (PyObject
*)unaryop_type
) < 0)
3067 if (PyDict_SetItemString(d
, "Invert", (PyObject
*)Invert_type
) < 0)
3069 if (PyDict_SetItemString(d
, "Not", (PyObject
*)Not_type
) < 0) return;
3070 if (PyDict_SetItemString(d
, "UAdd", (PyObject
*)UAdd_type
) < 0) return;
3071 if (PyDict_SetItemString(d
, "USub", (PyObject
*)USub_type
) < 0) return;
3072 if (PyDict_SetItemString(d
, "cmpop", (PyObject
*)cmpop_type
) < 0) return;
3073 if (PyDict_SetItemString(d
, "Eq", (PyObject
*)Eq_type
) < 0) return;
3074 if (PyDict_SetItemString(d
, "NotEq", (PyObject
*)NotEq_type
) < 0) return;
3075 if (PyDict_SetItemString(d
, "Lt", (PyObject
*)Lt_type
) < 0) return;
3076 if (PyDict_SetItemString(d
, "LtE", (PyObject
*)LtE_type
) < 0) return;
3077 if (PyDict_SetItemString(d
, "Gt", (PyObject
*)Gt_type
) < 0) return;
3078 if (PyDict_SetItemString(d
, "GtE", (PyObject
*)GtE_type
) < 0) return;
3079 if (PyDict_SetItemString(d
, "Is", (PyObject
*)Is_type
) < 0) return;
3080 if (PyDict_SetItemString(d
, "IsNot", (PyObject
*)IsNot_type
) < 0) return;
3081 if (PyDict_SetItemString(d
, "In", (PyObject
*)In_type
) < 0) return;
3082 if (PyDict_SetItemString(d
, "NotIn", (PyObject
*)NotIn_type
) < 0) return;
3083 if (PyDict_SetItemString(d
, "comprehension",
3084 (PyObject
*)comprehension_type
) < 0) return;
3085 if (PyDict_SetItemString(d
, "excepthandler",
3086 (PyObject
*)excepthandler_type
) < 0) return;
3087 if (PyDict_SetItemString(d
, "arguments", (PyObject
*)arguments_type
) <
3089 if (PyDict_SetItemString(d
, "keyword", (PyObject
*)keyword_type
) < 0)
3091 if (PyDict_SetItemString(d
, "alias", (PyObject
*)alias_type
) < 0) return;
3095 PyObject
* PyAST_mod2obj(mod_ty t
)
3098 return ast2obj_mod(t
);