1 /* File automatically generated by Parser/asdl_c.py */
4 #include "Python-ast.h"
6 static PyTypeObject
* AST_type
;
7 static PyTypeObject
*mod_type
;
8 static PyObject
* ast2obj_mod(void*);
9 static PyTypeObject
*Module_type
;
10 static char *Module_fields
[]={
13 static PyTypeObject
*Interactive_type
;
14 static char *Interactive_fields
[]={
17 static PyTypeObject
*Expression_type
;
18 static char *Expression_fields
[]={
21 static PyTypeObject
*Suite_type
;
22 static char *Suite_fields
[]={
25 static PyTypeObject
*stmt_type
;
26 static char *stmt_attributes
[] = {
30 static PyObject
* ast2obj_stmt(void*);
31 static PyTypeObject
*FunctionDef_type
;
32 static char *FunctionDef_fields
[]={
38 static PyTypeObject
*ClassDef_type
;
39 static char *ClassDef_fields
[]={
44 static PyTypeObject
*Return_type
;
45 static char *Return_fields
[]={
48 static PyTypeObject
*Delete_type
;
49 static char *Delete_fields
[]={
52 static PyTypeObject
*Assign_type
;
53 static char *Assign_fields
[]={
57 static PyTypeObject
*AugAssign_type
;
58 static char *AugAssign_fields
[]={
63 static PyTypeObject
*Print_type
;
64 static char *Print_fields
[]={
69 static PyTypeObject
*For_type
;
70 static char *For_fields
[]={
76 static PyTypeObject
*While_type
;
77 static char *While_fields
[]={
82 static PyTypeObject
*If_type
;
83 static char *If_fields
[]={
88 static PyTypeObject
*With_type
;
89 static char *With_fields
[]={
94 static PyTypeObject
*Raise_type
;
95 static char *Raise_fields
[]={
100 static PyTypeObject
*TryExcept_type
;
101 static char *TryExcept_fields
[]={
106 static PyTypeObject
*TryFinally_type
;
107 static char *TryFinally_fields
[]={
111 static PyTypeObject
*Assert_type
;
112 static char *Assert_fields
[]={
116 static PyTypeObject
*Import_type
;
117 static char *Import_fields
[]={
120 static PyTypeObject
*ImportFrom_type
;
121 static char *ImportFrom_fields
[]={
126 static PyTypeObject
*Exec_type
;
127 static char *Exec_fields
[]={
132 static PyTypeObject
*Global_type
;
133 static char *Global_fields
[]={
136 static PyTypeObject
*Expr_type
;
137 static char *Expr_fields
[]={
140 static PyTypeObject
*Pass_type
;
141 static PyTypeObject
*Break_type
;
142 static PyTypeObject
*Continue_type
;
143 static PyTypeObject
*expr_type
;
144 static char *expr_attributes
[] = {
148 static PyObject
* ast2obj_expr(void*);
149 static PyTypeObject
*BoolOp_type
;
150 static char *BoolOp_fields
[]={
154 static PyTypeObject
*BinOp_type
;
155 static char *BinOp_fields
[]={
160 static PyTypeObject
*UnaryOp_type
;
161 static char *UnaryOp_fields
[]={
165 static PyTypeObject
*Lambda_type
;
166 static char *Lambda_fields
[]={
170 static PyTypeObject
*IfExp_type
;
171 static char *IfExp_fields
[]={
176 static PyTypeObject
*Dict_type
;
177 static char *Dict_fields
[]={
181 static PyTypeObject
*ListComp_type
;
182 static char *ListComp_fields
[]={
186 static PyTypeObject
*GeneratorExp_type
;
187 static char *GeneratorExp_fields
[]={
191 static PyTypeObject
*Yield_type
;
192 static char *Yield_fields
[]={
195 static PyTypeObject
*Compare_type
;
196 static char *Compare_fields
[]={
201 static PyTypeObject
*Call_type
;
202 static char *Call_fields
[]={
209 static PyTypeObject
*Repr_type
;
210 static char *Repr_fields
[]={
213 static PyTypeObject
*Num_type
;
214 static char *Num_fields
[]={
217 static PyTypeObject
*Str_type
;
218 static char *Str_fields
[]={
221 static PyTypeObject
*Attribute_type
;
222 static char *Attribute_fields
[]={
227 static PyTypeObject
*Subscript_type
;
228 static char *Subscript_fields
[]={
233 static PyTypeObject
*Name_type
;
234 static char *Name_fields
[]={
238 static PyTypeObject
*List_type
;
239 static char *List_fields
[]={
243 static PyTypeObject
*Tuple_type
;
244 static char *Tuple_fields
[]={
248 static PyTypeObject
*expr_context_type
;
249 static PyObject
*Load_singleton
, *Store_singleton
, *Del_singleton
,
250 *AugLoad_singleton
, *AugStore_singleton
, *Param_singleton
;
251 static PyObject
* ast2obj_expr_context(expr_context_ty
);
252 static PyTypeObject
*Load_type
;
253 static PyTypeObject
*Store_type
;
254 static PyTypeObject
*Del_type
;
255 static PyTypeObject
*AugLoad_type
;
256 static PyTypeObject
*AugStore_type
;
257 static PyTypeObject
*Param_type
;
258 static PyTypeObject
*slice_type
;
259 static PyObject
* ast2obj_slice(void*);
260 static PyTypeObject
*Ellipsis_type
;
261 static PyTypeObject
*Slice_type
;
262 static char *Slice_fields
[]={
267 static PyTypeObject
*ExtSlice_type
;
268 static char *ExtSlice_fields
[]={
271 static PyTypeObject
*Index_type
;
272 static char *Index_fields
[]={
275 static PyTypeObject
*boolop_type
;
276 static PyObject
*And_singleton
, *Or_singleton
;
277 static PyObject
* ast2obj_boolop(boolop_ty
);
278 static PyTypeObject
*And_type
;
279 static PyTypeObject
*Or_type
;
280 static PyTypeObject
*operator_type
;
281 static PyObject
*Add_singleton
, *Sub_singleton
, *Mult_singleton
,
282 *Div_singleton
, *Mod_singleton
, *Pow_singleton
, *LShift_singleton
,
283 *RShift_singleton
, *BitOr_singleton
, *BitXor_singleton
, *BitAnd_singleton
,
285 static PyObject
* ast2obj_operator(operator_ty
);
286 static PyTypeObject
*Add_type
;
287 static PyTypeObject
*Sub_type
;
288 static PyTypeObject
*Mult_type
;
289 static PyTypeObject
*Div_type
;
290 static PyTypeObject
*Mod_type
;
291 static PyTypeObject
*Pow_type
;
292 static PyTypeObject
*LShift_type
;
293 static PyTypeObject
*RShift_type
;
294 static PyTypeObject
*BitOr_type
;
295 static PyTypeObject
*BitXor_type
;
296 static PyTypeObject
*BitAnd_type
;
297 static PyTypeObject
*FloorDiv_type
;
298 static PyTypeObject
*unaryop_type
;
299 static PyObject
*Invert_singleton
, *Not_singleton
, *UAdd_singleton
,
301 static PyObject
* ast2obj_unaryop(unaryop_ty
);
302 static PyTypeObject
*Invert_type
;
303 static PyTypeObject
*Not_type
;
304 static PyTypeObject
*UAdd_type
;
305 static PyTypeObject
*USub_type
;
306 static PyTypeObject
*cmpop_type
;
307 static PyObject
*Eq_singleton
, *NotEq_singleton
, *Lt_singleton
, *LtE_singleton
,
308 *Gt_singleton
, *GtE_singleton
, *Is_singleton
, *IsNot_singleton
, *In_singleton
,
310 static PyObject
* ast2obj_cmpop(cmpop_ty
);
311 static PyTypeObject
*Eq_type
;
312 static PyTypeObject
*NotEq_type
;
313 static PyTypeObject
*Lt_type
;
314 static PyTypeObject
*LtE_type
;
315 static PyTypeObject
*Gt_type
;
316 static PyTypeObject
*GtE_type
;
317 static PyTypeObject
*Is_type
;
318 static PyTypeObject
*IsNot_type
;
319 static PyTypeObject
*In_type
;
320 static PyTypeObject
*NotIn_type
;
321 static PyTypeObject
*comprehension_type
;
322 static PyObject
* ast2obj_comprehension(void*);
323 static char *comprehension_fields
[]={
328 static PyTypeObject
*excepthandler_type
;
329 static PyObject
* ast2obj_excepthandler(void*);
330 static char *excepthandler_fields
[]={
335 static PyTypeObject
*arguments_type
;
336 static PyObject
* ast2obj_arguments(void*);
337 static char *arguments_fields
[]={
343 static PyTypeObject
*keyword_type
;
344 static PyObject
* ast2obj_keyword(void*);
345 static char *keyword_fields
[]={
349 static PyTypeObject
*alias_type
;
350 static PyObject
* ast2obj_alias(void*);
351 static char *alias_fields
[]={
357 static PyTypeObject
* make_type(char *type
, PyTypeObject
* base
, char**fields
, int num_fields
)
359 PyObject
*fnames
, *result
;
362 fnames
= PyTuple_New(num_fields
);
363 if (!fnames
) return NULL
;
368 for(i
=0; i
< num_fields
; i
++) {
369 PyObject
*field
= PyString_FromString(fields
[i
]);
374 PyTuple_SET_ITEM(fnames
, i
, field
);
376 result
= PyObject_CallFunction((PyObject
*)&PyType_Type
, "s(O){sOss}",
377 type
, base
, "_fields", fnames
, "__module__", "_ast");
379 return (PyTypeObject
*)result
;
382 static int add_attributes(PyTypeObject
* type
, char**attrs
, int num_fields
)
385 PyObject
*s
, *l
= PyList_New(num_fields
);
387 for(i
=0; i
< num_fields
; i
++) {
388 s
= PyString_FromString(attrs
[i
]);
393 PyList_SET_ITEM(l
, i
, s
);
395 return PyObject_SetAttrString((PyObject
*)type
, "_attributes", l
) >=0;
398 static PyObject
* ast2obj_list(asdl_seq
*seq
, PyObject
* (*func
)(void*))
400 int i
, n
= asdl_seq_LEN(seq
);
401 PyObject
*result
= PyList_New(n
);
405 for (i
= 0; i
< n
; i
++) {
406 value
= func(asdl_seq_GET(seq
, i
));
411 PyList_SET_ITEM(result
, i
, value
);
416 static PyObject
* ast2obj_object(void *o
)
420 Py_INCREF((PyObject
*)o
);
423 #define ast2obj_identifier ast2obj_object
424 #define ast2obj_string ast2obj_object
425 static PyObject
* ast2obj_bool(bool b
)
427 return PyBool_FromLong(b
);
430 static PyObject
* ast2obj_int(bool b
)
432 return PyInt_FromLong(b
);
435 static int initialized
;
436 static int init_types(void)
438 if (initialized
) return 1;
439 AST_type
= make_type("AST", &PyBaseObject_Type
, NULL
, 0);
440 mod_type
= make_type("mod", AST_type
, NULL
, 0);
441 if (!mod_type
) return 0;
442 if (!add_attributes(mod_type
, NULL
, 0)) return 0;
443 Module_type
= make_type("Module", mod_type
, Module_fields
, 1);
444 if (!Module_type
) return 0;
445 Interactive_type
= make_type("Interactive", mod_type
,
446 Interactive_fields
, 1);
447 if (!Interactive_type
) return 0;
448 Expression_type
= make_type("Expression", mod_type
, Expression_fields
,
450 if (!Expression_type
) return 0;
451 Suite_type
= make_type("Suite", mod_type
, Suite_fields
, 1);
452 if (!Suite_type
) return 0;
453 stmt_type
= make_type("stmt", AST_type
, NULL
, 0);
454 if (!stmt_type
) return 0;
455 if (!add_attributes(stmt_type
, stmt_attributes
, 2)) return 0;
456 FunctionDef_type
= make_type("FunctionDef", stmt_type
,
457 FunctionDef_fields
, 4);
458 if (!FunctionDef_type
) return 0;
459 ClassDef_type
= make_type("ClassDef", stmt_type
, ClassDef_fields
, 3);
460 if (!ClassDef_type
) return 0;
461 Return_type
= make_type("Return", stmt_type
, Return_fields
, 1);
462 if (!Return_type
) return 0;
463 Delete_type
= make_type("Delete", stmt_type
, Delete_fields
, 1);
464 if (!Delete_type
) return 0;
465 Assign_type
= make_type("Assign", stmt_type
, Assign_fields
, 2);
466 if (!Assign_type
) return 0;
467 AugAssign_type
= make_type("AugAssign", stmt_type
, AugAssign_fields
, 3);
468 if (!AugAssign_type
) return 0;
469 Print_type
= make_type("Print", stmt_type
, Print_fields
, 3);
470 if (!Print_type
) return 0;
471 For_type
= make_type("For", stmt_type
, For_fields
, 4);
472 if (!For_type
) return 0;
473 While_type
= make_type("While", stmt_type
, While_fields
, 3);
474 if (!While_type
) return 0;
475 If_type
= make_type("If", stmt_type
, If_fields
, 3);
476 if (!If_type
) return 0;
477 With_type
= make_type("With", stmt_type
, With_fields
, 3);
478 if (!With_type
) return 0;
479 Raise_type
= make_type("Raise", stmt_type
, Raise_fields
, 3);
480 if (!Raise_type
) return 0;
481 TryExcept_type
= make_type("TryExcept", stmt_type
, TryExcept_fields
, 3);
482 if (!TryExcept_type
) return 0;
483 TryFinally_type
= make_type("TryFinally", stmt_type
, TryFinally_fields
,
485 if (!TryFinally_type
) return 0;
486 Assert_type
= make_type("Assert", stmt_type
, Assert_fields
, 2);
487 if (!Assert_type
) return 0;
488 Import_type
= make_type("Import", stmt_type
, Import_fields
, 1);
489 if (!Import_type
) return 0;
490 ImportFrom_type
= make_type("ImportFrom", stmt_type
, ImportFrom_fields
,
492 if (!ImportFrom_type
) return 0;
493 Exec_type
= make_type("Exec", stmt_type
, Exec_fields
, 3);
494 if (!Exec_type
) return 0;
495 Global_type
= make_type("Global", stmt_type
, Global_fields
, 1);
496 if (!Global_type
) return 0;
497 Expr_type
= make_type("Expr", stmt_type
, Expr_fields
, 1);
498 if (!Expr_type
) return 0;
499 Pass_type
= make_type("Pass", stmt_type
, NULL
, 0);
500 if (!Pass_type
) return 0;
501 Break_type
= make_type("Break", stmt_type
, NULL
, 0);
502 if (!Break_type
) return 0;
503 Continue_type
= make_type("Continue", stmt_type
, NULL
, 0);
504 if (!Continue_type
) return 0;
505 expr_type
= make_type("expr", AST_type
, NULL
, 0);
506 if (!expr_type
) return 0;
507 if (!add_attributes(expr_type
, expr_attributes
, 2)) return 0;
508 BoolOp_type
= make_type("BoolOp", expr_type
, BoolOp_fields
, 2);
509 if (!BoolOp_type
) return 0;
510 BinOp_type
= make_type("BinOp", expr_type
, BinOp_fields
, 3);
511 if (!BinOp_type
) return 0;
512 UnaryOp_type
= make_type("UnaryOp", expr_type
, UnaryOp_fields
, 2);
513 if (!UnaryOp_type
) return 0;
514 Lambda_type
= make_type("Lambda", expr_type
, Lambda_fields
, 2);
515 if (!Lambda_type
) return 0;
516 IfExp_type
= make_type("IfExp", expr_type
, IfExp_fields
, 3);
517 if (!IfExp_type
) return 0;
518 Dict_type
= make_type("Dict", expr_type
, Dict_fields
, 2);
519 if (!Dict_type
) return 0;
520 ListComp_type
= make_type("ListComp", expr_type
, ListComp_fields
, 2);
521 if (!ListComp_type
) return 0;
522 GeneratorExp_type
= make_type("GeneratorExp", expr_type
,
523 GeneratorExp_fields
, 2);
524 if (!GeneratorExp_type
) return 0;
525 Yield_type
= make_type("Yield", expr_type
, Yield_fields
, 1);
526 if (!Yield_type
) return 0;
527 Compare_type
= make_type("Compare", expr_type
, Compare_fields
, 3);
528 if (!Compare_type
) return 0;
529 Call_type
= make_type("Call", expr_type
, Call_fields
, 5);
530 if (!Call_type
) return 0;
531 Repr_type
= make_type("Repr", expr_type
, Repr_fields
, 1);
532 if (!Repr_type
) return 0;
533 Num_type
= make_type("Num", expr_type
, Num_fields
, 1);
534 if (!Num_type
) return 0;
535 Str_type
= make_type("Str", expr_type
, Str_fields
, 1);
536 if (!Str_type
) return 0;
537 Attribute_type
= make_type("Attribute", expr_type
, Attribute_fields
, 3);
538 if (!Attribute_type
) return 0;
539 Subscript_type
= make_type("Subscript", expr_type
, Subscript_fields
, 3);
540 if (!Subscript_type
) return 0;
541 Name_type
= make_type("Name", expr_type
, Name_fields
, 2);
542 if (!Name_type
) return 0;
543 List_type
= make_type("List", expr_type
, List_fields
, 2);
544 if (!List_type
) return 0;
545 Tuple_type
= make_type("Tuple", expr_type
, Tuple_fields
, 2);
546 if (!Tuple_type
) return 0;
547 expr_context_type
= make_type("expr_context", AST_type
, NULL
, 0);
548 if (!expr_context_type
) return 0;
549 if (!add_attributes(expr_context_type
, NULL
, 0)) return 0;
550 Load_type
= make_type("Load", expr_context_type
, NULL
, 0);
551 if (!Load_type
) return 0;
552 Load_singleton
= PyType_GenericNew(Load_type
, NULL
, NULL
);
553 if (!Load_singleton
) return 0;
554 Store_type
= make_type("Store", expr_context_type
, NULL
, 0);
555 if (!Store_type
) return 0;
556 Store_singleton
= PyType_GenericNew(Store_type
, NULL
, NULL
);
557 if (!Store_singleton
) return 0;
558 Del_type
= make_type("Del", expr_context_type
, NULL
, 0);
559 if (!Del_type
) return 0;
560 Del_singleton
= PyType_GenericNew(Del_type
, NULL
, NULL
);
561 if (!Del_singleton
) return 0;
562 AugLoad_type
= make_type("AugLoad", expr_context_type
, NULL
, 0);
563 if (!AugLoad_type
) return 0;
564 AugLoad_singleton
= PyType_GenericNew(AugLoad_type
, NULL
, NULL
);
565 if (!AugLoad_singleton
) return 0;
566 AugStore_type
= make_type("AugStore", expr_context_type
, NULL
, 0);
567 if (!AugStore_type
) return 0;
568 AugStore_singleton
= PyType_GenericNew(AugStore_type
, NULL
, NULL
);
569 if (!AugStore_singleton
) return 0;
570 Param_type
= make_type("Param", expr_context_type
, NULL
, 0);
571 if (!Param_type
) return 0;
572 Param_singleton
= PyType_GenericNew(Param_type
, NULL
, NULL
);
573 if (!Param_singleton
) return 0;
574 slice_type
= make_type("slice", AST_type
, NULL
, 0);
575 if (!slice_type
) return 0;
576 if (!add_attributes(slice_type
, NULL
, 0)) return 0;
577 Ellipsis_type
= make_type("Ellipsis", slice_type
, NULL
, 0);
578 if (!Ellipsis_type
) return 0;
579 Slice_type
= make_type("Slice", slice_type
, Slice_fields
, 3);
580 if (!Slice_type
) return 0;
581 ExtSlice_type
= make_type("ExtSlice", slice_type
, ExtSlice_fields
, 1);
582 if (!ExtSlice_type
) return 0;
583 Index_type
= make_type("Index", slice_type
, Index_fields
, 1);
584 if (!Index_type
) return 0;
585 boolop_type
= make_type("boolop", AST_type
, NULL
, 0);
586 if (!boolop_type
) return 0;
587 if (!add_attributes(boolop_type
, NULL
, 0)) return 0;
588 And_type
= make_type("And", boolop_type
, NULL
, 0);
589 if (!And_type
) return 0;
590 And_singleton
= PyType_GenericNew(And_type
, NULL
, NULL
);
591 if (!And_singleton
) return 0;
592 Or_type
= make_type("Or", boolop_type
, NULL
, 0);
593 if (!Or_type
) return 0;
594 Or_singleton
= PyType_GenericNew(Or_type
, NULL
, NULL
);
595 if (!Or_singleton
) return 0;
596 operator_type
= make_type("operator", AST_type
, NULL
, 0);
597 if (!operator_type
) return 0;
598 if (!add_attributes(operator_type
, NULL
, 0)) return 0;
599 Add_type
= make_type("Add", operator_type
, NULL
, 0);
600 if (!Add_type
) return 0;
601 Add_singleton
= PyType_GenericNew(Add_type
, NULL
, NULL
);
602 if (!Add_singleton
) return 0;
603 Sub_type
= make_type("Sub", operator_type
, NULL
, 0);
604 if (!Sub_type
) return 0;
605 Sub_singleton
= PyType_GenericNew(Sub_type
, NULL
, NULL
);
606 if (!Sub_singleton
) return 0;
607 Mult_type
= make_type("Mult", operator_type
, NULL
, 0);
608 if (!Mult_type
) return 0;
609 Mult_singleton
= PyType_GenericNew(Mult_type
, NULL
, NULL
);
610 if (!Mult_singleton
) return 0;
611 Div_type
= make_type("Div", operator_type
, NULL
, 0);
612 if (!Div_type
) return 0;
613 Div_singleton
= PyType_GenericNew(Div_type
, NULL
, NULL
);
614 if (!Div_singleton
) return 0;
615 Mod_type
= make_type("Mod", operator_type
, NULL
, 0);
616 if (!Mod_type
) return 0;
617 Mod_singleton
= PyType_GenericNew(Mod_type
, NULL
, NULL
);
618 if (!Mod_singleton
) return 0;
619 Pow_type
= make_type("Pow", operator_type
, NULL
, 0);
620 if (!Pow_type
) return 0;
621 Pow_singleton
= PyType_GenericNew(Pow_type
, NULL
, NULL
);
622 if (!Pow_singleton
) return 0;
623 LShift_type
= make_type("LShift", operator_type
, NULL
, 0);
624 if (!LShift_type
) return 0;
625 LShift_singleton
= PyType_GenericNew(LShift_type
, NULL
, NULL
);
626 if (!LShift_singleton
) return 0;
627 RShift_type
= make_type("RShift", operator_type
, NULL
, 0);
628 if (!RShift_type
) return 0;
629 RShift_singleton
= PyType_GenericNew(RShift_type
, NULL
, NULL
);
630 if (!RShift_singleton
) return 0;
631 BitOr_type
= make_type("BitOr", operator_type
, NULL
, 0);
632 if (!BitOr_type
) return 0;
633 BitOr_singleton
= PyType_GenericNew(BitOr_type
, NULL
, NULL
);
634 if (!BitOr_singleton
) return 0;
635 BitXor_type
= make_type("BitXor", operator_type
, NULL
, 0);
636 if (!BitXor_type
) return 0;
637 BitXor_singleton
= PyType_GenericNew(BitXor_type
, NULL
, NULL
);
638 if (!BitXor_singleton
) return 0;
639 BitAnd_type
= make_type("BitAnd", operator_type
, NULL
, 0);
640 if (!BitAnd_type
) return 0;
641 BitAnd_singleton
= PyType_GenericNew(BitAnd_type
, NULL
, NULL
);
642 if (!BitAnd_singleton
) return 0;
643 FloorDiv_type
= make_type("FloorDiv", operator_type
, NULL
, 0);
644 if (!FloorDiv_type
) return 0;
645 FloorDiv_singleton
= PyType_GenericNew(FloorDiv_type
, NULL
, NULL
);
646 if (!FloorDiv_singleton
) return 0;
647 unaryop_type
= make_type("unaryop", AST_type
, NULL
, 0);
648 if (!unaryop_type
) return 0;
649 if (!add_attributes(unaryop_type
, NULL
, 0)) return 0;
650 Invert_type
= make_type("Invert", unaryop_type
, NULL
, 0);
651 if (!Invert_type
) return 0;
652 Invert_singleton
= PyType_GenericNew(Invert_type
, NULL
, NULL
);
653 if (!Invert_singleton
) return 0;
654 Not_type
= make_type("Not", unaryop_type
, NULL
, 0);
655 if (!Not_type
) return 0;
656 Not_singleton
= PyType_GenericNew(Not_type
, NULL
, NULL
);
657 if (!Not_singleton
) return 0;
658 UAdd_type
= make_type("UAdd", unaryop_type
, NULL
, 0);
659 if (!UAdd_type
) return 0;
660 UAdd_singleton
= PyType_GenericNew(UAdd_type
, NULL
, NULL
);
661 if (!UAdd_singleton
) return 0;
662 USub_type
= make_type("USub", unaryop_type
, NULL
, 0);
663 if (!USub_type
) return 0;
664 USub_singleton
= PyType_GenericNew(USub_type
, NULL
, NULL
);
665 if (!USub_singleton
) return 0;
666 cmpop_type
= make_type("cmpop", AST_type
, NULL
, 0);
667 if (!cmpop_type
) return 0;
668 if (!add_attributes(cmpop_type
, NULL
, 0)) return 0;
669 Eq_type
= make_type("Eq", cmpop_type
, NULL
, 0);
670 if (!Eq_type
) return 0;
671 Eq_singleton
= PyType_GenericNew(Eq_type
, NULL
, NULL
);
672 if (!Eq_singleton
) return 0;
673 NotEq_type
= make_type("NotEq", cmpop_type
, NULL
, 0);
674 if (!NotEq_type
) return 0;
675 NotEq_singleton
= PyType_GenericNew(NotEq_type
, NULL
, NULL
);
676 if (!NotEq_singleton
) return 0;
677 Lt_type
= make_type("Lt", cmpop_type
, NULL
, 0);
678 if (!Lt_type
) return 0;
679 Lt_singleton
= PyType_GenericNew(Lt_type
, NULL
, NULL
);
680 if (!Lt_singleton
) return 0;
681 LtE_type
= make_type("LtE", cmpop_type
, NULL
, 0);
682 if (!LtE_type
) return 0;
683 LtE_singleton
= PyType_GenericNew(LtE_type
, NULL
, NULL
);
684 if (!LtE_singleton
) return 0;
685 Gt_type
= make_type("Gt", cmpop_type
, NULL
, 0);
686 if (!Gt_type
) return 0;
687 Gt_singleton
= PyType_GenericNew(Gt_type
, NULL
, NULL
);
688 if (!Gt_singleton
) return 0;
689 GtE_type
= make_type("GtE", cmpop_type
, NULL
, 0);
690 if (!GtE_type
) return 0;
691 GtE_singleton
= PyType_GenericNew(GtE_type
, NULL
, NULL
);
692 if (!GtE_singleton
) return 0;
693 Is_type
= make_type("Is", cmpop_type
, NULL
, 0);
694 if (!Is_type
) return 0;
695 Is_singleton
= PyType_GenericNew(Is_type
, NULL
, NULL
);
696 if (!Is_singleton
) return 0;
697 IsNot_type
= make_type("IsNot", cmpop_type
, NULL
, 0);
698 if (!IsNot_type
) return 0;
699 IsNot_singleton
= PyType_GenericNew(IsNot_type
, NULL
, NULL
);
700 if (!IsNot_singleton
) return 0;
701 In_type
= make_type("In", cmpop_type
, NULL
, 0);
702 if (!In_type
) return 0;
703 In_singleton
= PyType_GenericNew(In_type
, NULL
, NULL
);
704 if (!In_singleton
) return 0;
705 NotIn_type
= make_type("NotIn", cmpop_type
, NULL
, 0);
706 if (!NotIn_type
) return 0;
707 NotIn_singleton
= PyType_GenericNew(NotIn_type
, NULL
, NULL
);
708 if (!NotIn_singleton
) return 0;
709 comprehension_type
= make_type("comprehension", AST_type
,
710 comprehension_fields
, 3);
711 if (!comprehension_type
) return 0;
712 excepthandler_type
= make_type("excepthandler", AST_type
,
713 excepthandler_fields
, 3);
714 if (!excepthandler_type
) return 0;
715 arguments_type
= make_type("arguments", AST_type
, arguments_fields
, 4);
716 if (!arguments_type
) return 0;
717 keyword_type
= make_type("keyword", AST_type
, keyword_fields
, 2);
718 if (!keyword_type
) return 0;
719 alias_type
= make_type("alias", AST_type
, alias_fields
, 2);
720 if (!alias_type
) return 0;
726 Module(asdl_seq
* body
, PyArena
*arena
)
729 p
= (mod_ty
)PyArena_Malloc(arena
, sizeof(*p
));
734 p
->kind
= Module_kind
;
735 p
->v
.Module
.body
= body
;
740 Interactive(asdl_seq
* body
, PyArena
*arena
)
743 p
= (mod_ty
)PyArena_Malloc(arena
, sizeof(*p
));
748 p
->kind
= Interactive_kind
;
749 p
->v
.Interactive
.body
= body
;
754 Expression(expr_ty body
, PyArena
*arena
)
758 PyErr_SetString(PyExc_ValueError
,
759 "field body is required for Expression");
762 p
= (mod_ty
)PyArena_Malloc(arena
, sizeof(*p
));
767 p
->kind
= Expression_kind
;
768 p
->v
.Expression
.body
= body
;
773 Suite(asdl_seq
* body
, PyArena
*arena
)
776 p
= (mod_ty
)PyArena_Malloc(arena
, sizeof(*p
));
781 p
->kind
= Suite_kind
;
782 p
->v
.Suite
.body
= body
;
787 FunctionDef(identifier name
, arguments_ty args
, asdl_seq
* body
, asdl_seq
*
788 decorators
, int lineno
, int col_offset
, PyArena
*arena
)
792 PyErr_SetString(PyExc_ValueError
,
793 "field name is required for FunctionDef");
797 PyErr_SetString(PyExc_ValueError
,
798 "field args is required for FunctionDef");
801 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
806 p
->kind
= FunctionDef_kind
;
807 p
->v
.FunctionDef
.name
= name
;
808 p
->v
.FunctionDef
.args
= args
;
809 p
->v
.FunctionDef
.body
= body
;
810 p
->v
.FunctionDef
.decorators
= decorators
;
812 p
->col_offset
= col_offset
;
817 ClassDef(identifier name
, asdl_seq
* bases
, asdl_seq
* body
, int lineno
, int
818 col_offset
, PyArena
*arena
)
822 PyErr_SetString(PyExc_ValueError
,
823 "field name is required for ClassDef");
826 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
831 p
->kind
= ClassDef_kind
;
832 p
->v
.ClassDef
.name
= name
;
833 p
->v
.ClassDef
.bases
= bases
;
834 p
->v
.ClassDef
.body
= body
;
836 p
->col_offset
= col_offset
;
841 Return(expr_ty value
, int lineno
, int col_offset
, PyArena
*arena
)
844 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
849 p
->kind
= Return_kind
;
850 p
->v
.Return
.value
= value
;
852 p
->col_offset
= col_offset
;
857 Delete(asdl_seq
* targets
, int lineno
, int col_offset
, PyArena
*arena
)
860 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
865 p
->kind
= Delete_kind
;
866 p
->v
.Delete
.targets
= targets
;
868 p
->col_offset
= col_offset
;
873 Assign(asdl_seq
* targets
, expr_ty value
, int lineno
, int col_offset
, PyArena
878 PyErr_SetString(PyExc_ValueError
,
879 "field value is required for Assign");
882 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
887 p
->kind
= Assign_kind
;
888 p
->v
.Assign
.targets
= targets
;
889 p
->v
.Assign
.value
= value
;
891 p
->col_offset
= col_offset
;
896 AugAssign(expr_ty target
, operator_ty op
, expr_ty value
, int lineno
, int
897 col_offset
, PyArena
*arena
)
901 PyErr_SetString(PyExc_ValueError
,
902 "field target is required for AugAssign");
906 PyErr_SetString(PyExc_ValueError
,
907 "field op is required for AugAssign");
911 PyErr_SetString(PyExc_ValueError
,
912 "field value is required for AugAssign");
915 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
920 p
->kind
= AugAssign_kind
;
921 p
->v
.AugAssign
.target
= target
;
922 p
->v
.AugAssign
.op
= op
;
923 p
->v
.AugAssign
.value
= value
;
925 p
->col_offset
= col_offset
;
930 Print(expr_ty dest
, asdl_seq
* values
, bool nl
, int lineno
, int col_offset
,
934 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
939 p
->kind
= Print_kind
;
940 p
->v
.Print
.dest
= dest
;
941 p
->v
.Print
.values
= values
;
944 p
->col_offset
= col_offset
;
949 For(expr_ty target
, expr_ty iter
, asdl_seq
* body
, asdl_seq
* orelse
, int
950 lineno
, int col_offset
, PyArena
*arena
)
954 PyErr_SetString(PyExc_ValueError
,
955 "field target is required for For");
959 PyErr_SetString(PyExc_ValueError
,
960 "field iter is required for For");
963 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
969 p
->v
.For
.target
= target
;
970 p
->v
.For
.iter
= iter
;
971 p
->v
.For
.body
= body
;
972 p
->v
.For
.orelse
= orelse
;
974 p
->col_offset
= col_offset
;
979 While(expr_ty test
, asdl_seq
* body
, asdl_seq
* orelse
, int lineno
, int
980 col_offset
, PyArena
*arena
)
984 PyErr_SetString(PyExc_ValueError
,
985 "field test is required for While");
988 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
993 p
->kind
= While_kind
;
994 p
->v
.While
.test
= test
;
995 p
->v
.While
.body
= body
;
996 p
->v
.While
.orelse
= orelse
;
998 p
->col_offset
= col_offset
;
1003 If(expr_ty test
, asdl_seq
* body
, asdl_seq
* orelse
, int lineno
, int
1004 col_offset
, PyArena
*arena
)
1008 PyErr_SetString(PyExc_ValueError
,
1009 "field test is required for If");
1012 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1018 p
->v
.If
.test
= test
;
1019 p
->v
.If
.body
= body
;
1020 p
->v
.If
.orelse
= orelse
;
1022 p
->col_offset
= col_offset
;
1027 With(expr_ty context_expr
, expr_ty optional_vars
, asdl_seq
* body
, int lineno
,
1028 int col_offset
, PyArena
*arena
)
1031 if (!context_expr
) {
1032 PyErr_SetString(PyExc_ValueError
,
1033 "field context_expr is required for With");
1036 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1041 p
->kind
= With_kind
;
1042 p
->v
.With
.context_expr
= context_expr
;
1043 p
->v
.With
.optional_vars
= optional_vars
;
1044 p
->v
.With
.body
= body
;
1046 p
->col_offset
= col_offset
;
1051 Raise(expr_ty type
, expr_ty inst
, expr_ty tback
, int lineno
, int col_offset
,
1055 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1060 p
->kind
= Raise_kind
;
1061 p
->v
.Raise
.type
= type
;
1062 p
->v
.Raise
.inst
= inst
;
1063 p
->v
.Raise
.tback
= tback
;
1065 p
->col_offset
= col_offset
;
1070 TryExcept(asdl_seq
* body
, asdl_seq
* handlers
, asdl_seq
* orelse
, int lineno
,
1071 int col_offset
, PyArena
*arena
)
1074 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1079 p
->kind
= TryExcept_kind
;
1080 p
->v
.TryExcept
.body
= body
;
1081 p
->v
.TryExcept
.handlers
= handlers
;
1082 p
->v
.TryExcept
.orelse
= orelse
;
1084 p
->col_offset
= col_offset
;
1089 TryFinally(asdl_seq
* body
, asdl_seq
* finalbody
, int lineno
, int col_offset
,
1093 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1098 p
->kind
= TryFinally_kind
;
1099 p
->v
.TryFinally
.body
= body
;
1100 p
->v
.TryFinally
.finalbody
= finalbody
;
1102 p
->col_offset
= col_offset
;
1107 Assert(expr_ty test
, expr_ty msg
, int lineno
, int col_offset
, PyArena
*arena
)
1111 PyErr_SetString(PyExc_ValueError
,
1112 "field test is required for Assert");
1115 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1120 p
->kind
= Assert_kind
;
1121 p
->v
.Assert
.test
= test
;
1122 p
->v
.Assert
.msg
= msg
;
1124 p
->col_offset
= col_offset
;
1129 Import(asdl_seq
* names
, int lineno
, int col_offset
, PyArena
*arena
)
1132 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1137 p
->kind
= Import_kind
;
1138 p
->v
.Import
.names
= names
;
1140 p
->col_offset
= col_offset
;
1145 ImportFrom(identifier module
, asdl_seq
* names
, int level
, int lineno
, int
1146 col_offset
, PyArena
*arena
)
1150 PyErr_SetString(PyExc_ValueError
,
1151 "field module is required for ImportFrom");
1154 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1159 p
->kind
= ImportFrom_kind
;
1160 p
->v
.ImportFrom
.module
= module
;
1161 p
->v
.ImportFrom
.names
= names
;
1162 p
->v
.ImportFrom
.level
= level
;
1164 p
->col_offset
= col_offset
;
1169 Exec(expr_ty body
, expr_ty globals
, expr_ty locals
, int lineno
, int col_offset
,
1174 PyErr_SetString(PyExc_ValueError
,
1175 "field body is required for Exec");
1178 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1183 p
->kind
= Exec_kind
;
1184 p
->v
.Exec
.body
= body
;
1185 p
->v
.Exec
.globals
= globals
;
1186 p
->v
.Exec
.locals
= locals
;
1188 p
->col_offset
= col_offset
;
1193 Global(asdl_seq
* names
, int lineno
, int col_offset
, PyArena
*arena
)
1196 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1201 p
->kind
= Global_kind
;
1202 p
->v
.Global
.names
= names
;
1204 p
->col_offset
= col_offset
;
1209 Expr(expr_ty value
, int lineno
, int col_offset
, PyArena
*arena
)
1213 PyErr_SetString(PyExc_ValueError
,
1214 "field value is required for Expr");
1217 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1222 p
->kind
= Expr_kind
;
1223 p
->v
.Expr
.value
= value
;
1225 p
->col_offset
= col_offset
;
1230 Pass(int lineno
, int col_offset
, PyArena
*arena
)
1233 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1238 p
->kind
= Pass_kind
;
1240 p
->col_offset
= col_offset
;
1245 Break(int lineno
, int col_offset
, PyArena
*arena
)
1248 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1253 p
->kind
= Break_kind
;
1255 p
->col_offset
= col_offset
;
1260 Continue(int lineno
, int col_offset
, PyArena
*arena
)
1263 p
= (stmt_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1268 p
->kind
= Continue_kind
;
1270 p
->col_offset
= col_offset
;
1275 BoolOp(boolop_ty op
, asdl_seq
* values
, int lineno
, int col_offset
, PyArena
1280 PyErr_SetString(PyExc_ValueError
,
1281 "field op is required for BoolOp");
1284 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1289 p
->kind
= BoolOp_kind
;
1290 p
->v
.BoolOp
.op
= op
;
1291 p
->v
.BoolOp
.values
= values
;
1293 p
->col_offset
= col_offset
;
1298 BinOp(expr_ty left
, operator_ty op
, expr_ty right
, int lineno
, int col_offset
,
1303 PyErr_SetString(PyExc_ValueError
,
1304 "field left is required for BinOp");
1308 PyErr_SetString(PyExc_ValueError
,
1309 "field op is required for BinOp");
1313 PyErr_SetString(PyExc_ValueError
,
1314 "field right is required for BinOp");
1317 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1322 p
->kind
= BinOp_kind
;
1323 p
->v
.BinOp
.left
= left
;
1325 p
->v
.BinOp
.right
= right
;
1327 p
->col_offset
= col_offset
;
1332 UnaryOp(unaryop_ty op
, expr_ty operand
, int lineno
, int col_offset
, PyArena
1337 PyErr_SetString(PyExc_ValueError
,
1338 "field op is required for UnaryOp");
1342 PyErr_SetString(PyExc_ValueError
,
1343 "field operand is required for UnaryOp");
1346 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1351 p
->kind
= UnaryOp_kind
;
1352 p
->v
.UnaryOp
.op
= op
;
1353 p
->v
.UnaryOp
.operand
= operand
;
1355 p
->col_offset
= col_offset
;
1360 Lambda(arguments_ty args
, expr_ty body
, int lineno
, int col_offset
, PyArena
1365 PyErr_SetString(PyExc_ValueError
,
1366 "field args is required for Lambda");
1370 PyErr_SetString(PyExc_ValueError
,
1371 "field body is required for Lambda");
1374 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1379 p
->kind
= Lambda_kind
;
1380 p
->v
.Lambda
.args
= args
;
1381 p
->v
.Lambda
.body
= body
;
1383 p
->col_offset
= col_offset
;
1388 IfExp(expr_ty test
, expr_ty body
, expr_ty orelse
, int lineno
, int col_offset
,
1393 PyErr_SetString(PyExc_ValueError
,
1394 "field test is required for IfExp");
1398 PyErr_SetString(PyExc_ValueError
,
1399 "field body is required for IfExp");
1403 PyErr_SetString(PyExc_ValueError
,
1404 "field orelse is required for IfExp");
1407 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1412 p
->kind
= IfExp_kind
;
1413 p
->v
.IfExp
.test
= test
;
1414 p
->v
.IfExp
.body
= body
;
1415 p
->v
.IfExp
.orelse
= orelse
;
1417 p
->col_offset
= col_offset
;
1422 Dict(asdl_seq
* keys
, asdl_seq
* values
, int lineno
, int col_offset
, PyArena
1426 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1431 p
->kind
= Dict_kind
;
1432 p
->v
.Dict
.keys
= keys
;
1433 p
->v
.Dict
.values
= values
;
1435 p
->col_offset
= col_offset
;
1440 ListComp(expr_ty elt
, asdl_seq
* generators
, int lineno
, int col_offset
,
1445 PyErr_SetString(PyExc_ValueError
,
1446 "field elt is required for ListComp");
1449 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1454 p
->kind
= ListComp_kind
;
1455 p
->v
.ListComp
.elt
= elt
;
1456 p
->v
.ListComp
.generators
= generators
;
1458 p
->col_offset
= col_offset
;
1463 GeneratorExp(expr_ty elt
, asdl_seq
* generators
, int lineno
, int col_offset
,
1468 PyErr_SetString(PyExc_ValueError
,
1469 "field elt is required for GeneratorExp");
1472 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1477 p
->kind
= GeneratorExp_kind
;
1478 p
->v
.GeneratorExp
.elt
= elt
;
1479 p
->v
.GeneratorExp
.generators
= generators
;
1481 p
->col_offset
= col_offset
;
1486 Yield(expr_ty value
, int lineno
, int col_offset
, PyArena
*arena
)
1489 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1494 p
->kind
= Yield_kind
;
1495 p
->v
.Yield
.value
= value
;
1497 p
->col_offset
= col_offset
;
1502 Compare(expr_ty left
, asdl_seq
* ops
, asdl_seq
* comparators
, int lineno
, int
1503 col_offset
, PyArena
*arena
)
1507 PyErr_SetString(PyExc_ValueError
,
1508 "field left is required for Compare");
1511 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1516 p
->kind
= Compare_kind
;
1517 p
->v
.Compare
.left
= left
;
1518 p
->v
.Compare
.ops
= ops
;
1519 p
->v
.Compare
.comparators
= comparators
;
1521 p
->col_offset
= col_offset
;
1526 Call(expr_ty func
, asdl_seq
* args
, asdl_seq
* keywords
, expr_ty starargs
,
1527 expr_ty kwargs
, int lineno
, int col_offset
, PyArena
*arena
)
1531 PyErr_SetString(PyExc_ValueError
,
1532 "field func is required for Call");
1535 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1540 p
->kind
= Call_kind
;
1541 p
->v
.Call
.func
= func
;
1542 p
->v
.Call
.args
= args
;
1543 p
->v
.Call
.keywords
= keywords
;
1544 p
->v
.Call
.starargs
= starargs
;
1545 p
->v
.Call
.kwargs
= kwargs
;
1547 p
->col_offset
= col_offset
;
1552 Repr(expr_ty value
, int lineno
, int col_offset
, PyArena
*arena
)
1556 PyErr_SetString(PyExc_ValueError
,
1557 "field value is required for Repr");
1560 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1565 p
->kind
= Repr_kind
;
1566 p
->v
.Repr
.value
= value
;
1568 p
->col_offset
= col_offset
;
1573 Num(object n
, int lineno
, int col_offset
, PyArena
*arena
)
1577 PyErr_SetString(PyExc_ValueError
,
1578 "field n is required for Num");
1581 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1589 p
->col_offset
= col_offset
;
1594 Str(string s
, int lineno
, int col_offset
, PyArena
*arena
)
1598 PyErr_SetString(PyExc_ValueError
,
1599 "field s is required for Str");
1602 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1610 p
->col_offset
= col_offset
;
1615 Attribute(expr_ty value
, identifier attr
, expr_context_ty ctx
, int lineno
, int
1616 col_offset
, PyArena
*arena
)
1620 PyErr_SetString(PyExc_ValueError
,
1621 "field value is required for Attribute");
1625 PyErr_SetString(PyExc_ValueError
,
1626 "field attr is required for Attribute");
1630 PyErr_SetString(PyExc_ValueError
,
1631 "field ctx is required for Attribute");
1634 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1639 p
->kind
= Attribute_kind
;
1640 p
->v
.Attribute
.value
= value
;
1641 p
->v
.Attribute
.attr
= attr
;
1642 p
->v
.Attribute
.ctx
= ctx
;
1644 p
->col_offset
= col_offset
;
1649 Subscript(expr_ty value
, slice_ty slice
, expr_context_ty ctx
, int lineno
, int
1650 col_offset
, PyArena
*arena
)
1654 PyErr_SetString(PyExc_ValueError
,
1655 "field value is required for Subscript");
1659 PyErr_SetString(PyExc_ValueError
,
1660 "field slice is required for Subscript");
1664 PyErr_SetString(PyExc_ValueError
,
1665 "field ctx is required for Subscript");
1668 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1673 p
->kind
= Subscript_kind
;
1674 p
->v
.Subscript
.value
= value
;
1675 p
->v
.Subscript
.slice
= slice
;
1676 p
->v
.Subscript
.ctx
= ctx
;
1678 p
->col_offset
= col_offset
;
1683 Name(identifier id
, expr_context_ty ctx
, int lineno
, int col_offset
, PyArena
1688 PyErr_SetString(PyExc_ValueError
,
1689 "field id is required for Name");
1693 PyErr_SetString(PyExc_ValueError
,
1694 "field ctx is required for Name");
1697 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1702 p
->kind
= Name_kind
;
1704 p
->v
.Name
.ctx
= ctx
;
1706 p
->col_offset
= col_offset
;
1711 List(asdl_seq
* elts
, expr_context_ty ctx
, int lineno
, int col_offset
, PyArena
1716 PyErr_SetString(PyExc_ValueError
,
1717 "field ctx is required for List");
1720 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1725 p
->kind
= List_kind
;
1726 p
->v
.List
.elts
= elts
;
1727 p
->v
.List
.ctx
= ctx
;
1729 p
->col_offset
= col_offset
;
1734 Tuple(asdl_seq
* elts
, expr_context_ty ctx
, int lineno
, int col_offset
, PyArena
1739 PyErr_SetString(PyExc_ValueError
,
1740 "field ctx is required for Tuple");
1743 p
= (expr_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1748 p
->kind
= Tuple_kind
;
1749 p
->v
.Tuple
.elts
= elts
;
1750 p
->v
.Tuple
.ctx
= ctx
;
1752 p
->col_offset
= col_offset
;
1757 Ellipsis(PyArena
*arena
)
1760 p
= (slice_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1765 p
->kind
= Ellipsis_kind
;
1770 Slice(expr_ty lower
, expr_ty upper
, expr_ty step
, PyArena
*arena
)
1773 p
= (slice_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1778 p
->kind
= Slice_kind
;
1779 p
->v
.Slice
.lower
= lower
;
1780 p
->v
.Slice
.upper
= upper
;
1781 p
->v
.Slice
.step
= step
;
1786 ExtSlice(asdl_seq
* dims
, PyArena
*arena
)
1789 p
= (slice_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1794 p
->kind
= ExtSlice_kind
;
1795 p
->v
.ExtSlice
.dims
= dims
;
1800 Index(expr_ty value
, PyArena
*arena
)
1804 PyErr_SetString(PyExc_ValueError
,
1805 "field value is required for Index");
1808 p
= (slice_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1813 p
->kind
= Index_kind
;
1814 p
->v
.Index
.value
= value
;
1819 comprehension(expr_ty target
, expr_ty iter
, asdl_seq
* ifs
, PyArena
*arena
)
1823 PyErr_SetString(PyExc_ValueError
,
1824 "field target is required for comprehension");
1828 PyErr_SetString(PyExc_ValueError
,
1829 "field iter is required for comprehension");
1832 p
= (comprehension_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1844 excepthandler(expr_ty type
, expr_ty name
, asdl_seq
* body
, PyArena
*arena
)
1847 p
= (excepthandler_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1859 arguments(asdl_seq
* args
, identifier vararg
, identifier kwarg
, asdl_seq
*
1860 defaults
, PyArena
*arena
)
1863 p
= (arguments_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1871 p
->defaults
= defaults
;
1876 keyword(identifier arg
, expr_ty value
, PyArena
*arena
)
1880 PyErr_SetString(PyExc_ValueError
,
1881 "field arg is required for keyword");
1885 PyErr_SetString(PyExc_ValueError
,
1886 "field value is required for keyword");
1889 p
= (keyword_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1900 alias(identifier name
, identifier asname
, PyArena
*arena
)
1904 PyErr_SetString(PyExc_ValueError
,
1905 "field name is required for alias");
1908 p
= (alias_ty
)PyArena_Malloc(arena
, sizeof(*p
));
1920 ast2obj_mod(void* _o
)
1922 mod_ty o
= (mod_ty
)_o
;
1923 PyObject
*result
= NULL
, *value
= NULL
;
1931 result
= PyType_GenericNew(Module_type
, NULL
, NULL
);
1932 if (!result
) goto failed
;
1933 value
= ast2obj_list(o
->v
.Module
.body
, ast2obj_stmt
);
1934 if (!value
) goto failed
;
1935 if (PyObject_SetAttrString(result
, "body", value
) == -1)
1939 case Interactive_kind
:
1940 result
= PyType_GenericNew(Interactive_type
, NULL
, NULL
);
1941 if (!result
) goto failed
;
1942 value
= ast2obj_list(o
->v
.Interactive
.body
, ast2obj_stmt
);
1943 if (!value
) goto failed
;
1944 if (PyObject_SetAttrString(result
, "body", value
) == -1)
1948 case Expression_kind
:
1949 result
= PyType_GenericNew(Expression_type
, NULL
, NULL
);
1950 if (!result
) goto failed
;
1951 value
= ast2obj_expr(o
->v
.Expression
.body
);
1952 if (!value
) goto failed
;
1953 if (PyObject_SetAttrString(result
, "body", value
) == -1)
1958 result
= PyType_GenericNew(Suite_type
, NULL
, NULL
);
1959 if (!result
) goto failed
;
1960 value
= ast2obj_list(o
->v
.Suite
.body
, ast2obj_stmt
);
1961 if (!value
) goto failed
;
1962 if (PyObject_SetAttrString(result
, "body", value
) == -1)
1975 ast2obj_stmt(void* _o
)
1977 stmt_ty o
= (stmt_ty
)_o
;
1978 PyObject
*result
= NULL
, *value
= NULL
;
1985 case FunctionDef_kind
:
1986 result
= PyType_GenericNew(FunctionDef_type
, NULL
, NULL
);
1987 if (!result
) goto failed
;
1988 value
= ast2obj_identifier(o
->v
.FunctionDef
.name
);
1989 if (!value
) goto failed
;
1990 if (PyObject_SetAttrString(result
, "name", value
) == -1)
1993 value
= ast2obj_arguments(o
->v
.FunctionDef
.args
);
1994 if (!value
) goto failed
;
1995 if (PyObject_SetAttrString(result
, "args", value
) == -1)
1998 value
= ast2obj_list(o
->v
.FunctionDef
.body
, ast2obj_stmt
);
1999 if (!value
) goto failed
;
2000 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2003 value
= ast2obj_list(o
->v
.FunctionDef
.decorators
, ast2obj_expr
);
2004 if (!value
) goto failed
;
2005 if (PyObject_SetAttrString(result
, "decorators", value
) == -1)
2010 result
= PyType_GenericNew(ClassDef_type
, NULL
, NULL
);
2011 if (!result
) goto failed
;
2012 value
= ast2obj_identifier(o
->v
.ClassDef
.name
);
2013 if (!value
) goto failed
;
2014 if (PyObject_SetAttrString(result
, "name", value
) == -1)
2017 value
= ast2obj_list(o
->v
.ClassDef
.bases
, ast2obj_expr
);
2018 if (!value
) goto failed
;
2019 if (PyObject_SetAttrString(result
, "bases", value
) == -1)
2022 value
= ast2obj_list(o
->v
.ClassDef
.body
, ast2obj_stmt
);
2023 if (!value
) goto failed
;
2024 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2029 result
= PyType_GenericNew(Return_type
, NULL
, NULL
);
2030 if (!result
) goto failed
;
2031 value
= ast2obj_expr(o
->v
.Return
.value
);
2032 if (!value
) goto failed
;
2033 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2038 result
= PyType_GenericNew(Delete_type
, NULL
, NULL
);
2039 if (!result
) goto failed
;
2040 value
= ast2obj_list(o
->v
.Delete
.targets
, ast2obj_expr
);
2041 if (!value
) goto failed
;
2042 if (PyObject_SetAttrString(result
, "targets", value
) == -1)
2047 result
= PyType_GenericNew(Assign_type
, NULL
, NULL
);
2048 if (!result
) goto failed
;
2049 value
= ast2obj_list(o
->v
.Assign
.targets
, ast2obj_expr
);
2050 if (!value
) goto failed
;
2051 if (PyObject_SetAttrString(result
, "targets", value
) == -1)
2054 value
= ast2obj_expr(o
->v
.Assign
.value
);
2055 if (!value
) goto failed
;
2056 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2060 case AugAssign_kind
:
2061 result
= PyType_GenericNew(AugAssign_type
, NULL
, NULL
);
2062 if (!result
) goto failed
;
2063 value
= ast2obj_expr(o
->v
.AugAssign
.target
);
2064 if (!value
) goto failed
;
2065 if (PyObject_SetAttrString(result
, "target", value
) == -1)
2068 value
= ast2obj_operator(o
->v
.AugAssign
.op
);
2069 if (!value
) goto failed
;
2070 if (PyObject_SetAttrString(result
, "op", value
) == -1)
2073 value
= ast2obj_expr(o
->v
.AugAssign
.value
);
2074 if (!value
) goto failed
;
2075 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2080 result
= PyType_GenericNew(Print_type
, NULL
, NULL
);
2081 if (!result
) goto failed
;
2082 value
= ast2obj_expr(o
->v
.Print
.dest
);
2083 if (!value
) goto failed
;
2084 if (PyObject_SetAttrString(result
, "dest", value
) == -1)
2087 value
= ast2obj_list(o
->v
.Print
.values
, ast2obj_expr
);
2088 if (!value
) goto failed
;
2089 if (PyObject_SetAttrString(result
, "values", value
) == -1)
2092 value
= ast2obj_bool(o
->v
.Print
.nl
);
2093 if (!value
) goto failed
;
2094 if (PyObject_SetAttrString(result
, "nl", value
) == -1)
2099 result
= PyType_GenericNew(For_type
, NULL
, NULL
);
2100 if (!result
) goto failed
;
2101 value
= ast2obj_expr(o
->v
.For
.target
);
2102 if (!value
) goto failed
;
2103 if (PyObject_SetAttrString(result
, "target", value
) == -1)
2106 value
= ast2obj_expr(o
->v
.For
.iter
);
2107 if (!value
) goto failed
;
2108 if (PyObject_SetAttrString(result
, "iter", value
) == -1)
2111 value
= ast2obj_list(o
->v
.For
.body
, ast2obj_stmt
);
2112 if (!value
) goto failed
;
2113 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2116 value
= ast2obj_list(o
->v
.For
.orelse
, ast2obj_stmt
);
2117 if (!value
) goto failed
;
2118 if (PyObject_SetAttrString(result
, "orelse", value
) == -1)
2123 result
= PyType_GenericNew(While_type
, NULL
, NULL
);
2124 if (!result
) goto failed
;
2125 value
= ast2obj_expr(o
->v
.While
.test
);
2126 if (!value
) goto failed
;
2127 if (PyObject_SetAttrString(result
, "test", value
) == -1)
2130 value
= ast2obj_list(o
->v
.While
.body
, ast2obj_stmt
);
2131 if (!value
) goto failed
;
2132 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2135 value
= ast2obj_list(o
->v
.While
.orelse
, ast2obj_stmt
);
2136 if (!value
) goto failed
;
2137 if (PyObject_SetAttrString(result
, "orelse", value
) == -1)
2142 result
= PyType_GenericNew(If_type
, NULL
, NULL
);
2143 if (!result
) goto failed
;
2144 value
= ast2obj_expr(o
->v
.If
.test
);
2145 if (!value
) goto failed
;
2146 if (PyObject_SetAttrString(result
, "test", value
) == -1)
2149 value
= ast2obj_list(o
->v
.If
.body
, ast2obj_stmt
);
2150 if (!value
) goto failed
;
2151 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2154 value
= ast2obj_list(o
->v
.If
.orelse
, ast2obj_stmt
);
2155 if (!value
) goto failed
;
2156 if (PyObject_SetAttrString(result
, "orelse", value
) == -1)
2161 result
= PyType_GenericNew(With_type
, NULL
, NULL
);
2162 if (!result
) goto failed
;
2163 value
= ast2obj_expr(o
->v
.With
.context_expr
);
2164 if (!value
) goto failed
;
2165 if (PyObject_SetAttrString(result
, "context_expr", value
) == -1)
2168 value
= ast2obj_expr(o
->v
.With
.optional_vars
);
2169 if (!value
) goto failed
;
2170 if (PyObject_SetAttrString(result
, "optional_vars", value
) ==
2174 value
= ast2obj_list(o
->v
.With
.body
, ast2obj_stmt
);
2175 if (!value
) goto failed
;
2176 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2181 result
= PyType_GenericNew(Raise_type
, NULL
, NULL
);
2182 if (!result
) goto failed
;
2183 value
= ast2obj_expr(o
->v
.Raise
.type
);
2184 if (!value
) goto failed
;
2185 if (PyObject_SetAttrString(result
, "type", value
) == -1)
2188 value
= ast2obj_expr(o
->v
.Raise
.inst
);
2189 if (!value
) goto failed
;
2190 if (PyObject_SetAttrString(result
, "inst", value
) == -1)
2193 value
= ast2obj_expr(o
->v
.Raise
.tback
);
2194 if (!value
) goto failed
;
2195 if (PyObject_SetAttrString(result
, "tback", value
) == -1)
2199 case TryExcept_kind
:
2200 result
= PyType_GenericNew(TryExcept_type
, NULL
, NULL
);
2201 if (!result
) goto failed
;
2202 value
= ast2obj_list(o
->v
.TryExcept
.body
, ast2obj_stmt
);
2203 if (!value
) goto failed
;
2204 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2207 value
= ast2obj_list(o
->v
.TryExcept
.handlers
,
2208 ast2obj_excepthandler
);
2209 if (!value
) goto failed
;
2210 if (PyObject_SetAttrString(result
, "handlers", value
) == -1)
2213 value
= ast2obj_list(o
->v
.TryExcept
.orelse
, ast2obj_stmt
);
2214 if (!value
) goto failed
;
2215 if (PyObject_SetAttrString(result
, "orelse", value
) == -1)
2219 case TryFinally_kind
:
2220 result
= PyType_GenericNew(TryFinally_type
, NULL
, NULL
);
2221 if (!result
) goto failed
;
2222 value
= ast2obj_list(o
->v
.TryFinally
.body
, ast2obj_stmt
);
2223 if (!value
) goto failed
;
2224 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2227 value
= ast2obj_list(o
->v
.TryFinally
.finalbody
, ast2obj_stmt
);
2228 if (!value
) goto failed
;
2229 if (PyObject_SetAttrString(result
, "finalbody", value
) == -1)
2234 result
= PyType_GenericNew(Assert_type
, NULL
, NULL
);
2235 if (!result
) goto failed
;
2236 value
= ast2obj_expr(o
->v
.Assert
.test
);
2237 if (!value
) goto failed
;
2238 if (PyObject_SetAttrString(result
, "test", value
) == -1)
2241 value
= ast2obj_expr(o
->v
.Assert
.msg
);
2242 if (!value
) goto failed
;
2243 if (PyObject_SetAttrString(result
, "msg", value
) == -1)
2248 result
= PyType_GenericNew(Import_type
, NULL
, NULL
);
2249 if (!result
) goto failed
;
2250 value
= ast2obj_list(o
->v
.Import
.names
, ast2obj_alias
);
2251 if (!value
) goto failed
;
2252 if (PyObject_SetAttrString(result
, "names", value
) == -1)
2256 case ImportFrom_kind
:
2257 result
= PyType_GenericNew(ImportFrom_type
, NULL
, NULL
);
2258 if (!result
) goto failed
;
2259 value
= ast2obj_identifier(o
->v
.ImportFrom
.module
);
2260 if (!value
) goto failed
;
2261 if (PyObject_SetAttrString(result
, "module", value
) == -1)
2264 value
= ast2obj_list(o
->v
.ImportFrom
.names
, ast2obj_alias
);
2265 if (!value
) goto failed
;
2266 if (PyObject_SetAttrString(result
, "names", value
) == -1)
2269 value
= ast2obj_int(o
->v
.ImportFrom
.level
);
2270 if (!value
) goto failed
;
2271 if (PyObject_SetAttrString(result
, "level", value
) == -1)
2276 result
= PyType_GenericNew(Exec_type
, NULL
, NULL
);
2277 if (!result
) goto failed
;
2278 value
= ast2obj_expr(o
->v
.Exec
.body
);
2279 if (!value
) goto failed
;
2280 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2283 value
= ast2obj_expr(o
->v
.Exec
.globals
);
2284 if (!value
) goto failed
;
2285 if (PyObject_SetAttrString(result
, "globals", value
) == -1)
2288 value
= ast2obj_expr(o
->v
.Exec
.locals
);
2289 if (!value
) goto failed
;
2290 if (PyObject_SetAttrString(result
, "locals", value
) == -1)
2295 result
= PyType_GenericNew(Global_type
, NULL
, NULL
);
2296 if (!result
) goto failed
;
2297 value
= ast2obj_list(o
->v
.Global
.names
, ast2obj_identifier
);
2298 if (!value
) goto failed
;
2299 if (PyObject_SetAttrString(result
, "names", value
) == -1)
2304 result
= PyType_GenericNew(Expr_type
, NULL
, NULL
);
2305 if (!result
) goto failed
;
2306 value
= ast2obj_expr(o
->v
.Expr
.value
);
2307 if (!value
) goto failed
;
2308 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2313 result
= PyType_GenericNew(Pass_type
, NULL
, NULL
);
2314 if (!result
) goto failed
;
2317 result
= PyType_GenericNew(Break_type
, NULL
, NULL
);
2318 if (!result
) goto failed
;
2321 result
= PyType_GenericNew(Continue_type
, NULL
, NULL
);
2322 if (!result
) goto failed
;
2325 value
= ast2obj_int(o
->lineno
);
2326 if (!value
) goto failed
;
2327 if (PyObject_SetAttrString(result
, "lineno", value
) < 0)
2330 value
= ast2obj_int(o
->col_offset
);
2331 if (!value
) goto failed
;
2332 if (PyObject_SetAttrString(result
, "col_offset", value
) < 0)
2343 ast2obj_expr(void* _o
)
2345 expr_ty o
= (expr_ty
)_o
;
2346 PyObject
*result
= NULL
, *value
= NULL
;
2354 result
= PyType_GenericNew(BoolOp_type
, NULL
, NULL
);
2355 if (!result
) goto failed
;
2356 value
= ast2obj_boolop(o
->v
.BoolOp
.op
);
2357 if (!value
) goto failed
;
2358 if (PyObject_SetAttrString(result
, "op", value
) == -1)
2361 value
= ast2obj_list(o
->v
.BoolOp
.values
, ast2obj_expr
);
2362 if (!value
) goto failed
;
2363 if (PyObject_SetAttrString(result
, "values", value
) == -1)
2368 result
= PyType_GenericNew(BinOp_type
, NULL
, NULL
);
2369 if (!result
) goto failed
;
2370 value
= ast2obj_expr(o
->v
.BinOp
.left
);
2371 if (!value
) goto failed
;
2372 if (PyObject_SetAttrString(result
, "left", value
) == -1)
2375 value
= ast2obj_operator(o
->v
.BinOp
.op
);
2376 if (!value
) goto failed
;
2377 if (PyObject_SetAttrString(result
, "op", value
) == -1)
2380 value
= ast2obj_expr(o
->v
.BinOp
.right
);
2381 if (!value
) goto failed
;
2382 if (PyObject_SetAttrString(result
, "right", value
) == -1)
2387 result
= PyType_GenericNew(UnaryOp_type
, NULL
, NULL
);
2388 if (!result
) goto failed
;
2389 value
= ast2obj_unaryop(o
->v
.UnaryOp
.op
);
2390 if (!value
) goto failed
;
2391 if (PyObject_SetAttrString(result
, "op", value
) == -1)
2394 value
= ast2obj_expr(o
->v
.UnaryOp
.operand
);
2395 if (!value
) goto failed
;
2396 if (PyObject_SetAttrString(result
, "operand", value
) == -1)
2401 result
= PyType_GenericNew(Lambda_type
, NULL
, NULL
);
2402 if (!result
) goto failed
;
2403 value
= ast2obj_arguments(o
->v
.Lambda
.args
);
2404 if (!value
) goto failed
;
2405 if (PyObject_SetAttrString(result
, "args", value
) == -1)
2408 value
= ast2obj_expr(o
->v
.Lambda
.body
);
2409 if (!value
) goto failed
;
2410 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2415 result
= PyType_GenericNew(IfExp_type
, NULL
, NULL
);
2416 if (!result
) goto failed
;
2417 value
= ast2obj_expr(o
->v
.IfExp
.test
);
2418 if (!value
) goto failed
;
2419 if (PyObject_SetAttrString(result
, "test", value
) == -1)
2422 value
= ast2obj_expr(o
->v
.IfExp
.body
);
2423 if (!value
) goto failed
;
2424 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2427 value
= ast2obj_expr(o
->v
.IfExp
.orelse
);
2428 if (!value
) goto failed
;
2429 if (PyObject_SetAttrString(result
, "orelse", value
) == -1)
2434 result
= PyType_GenericNew(Dict_type
, NULL
, NULL
);
2435 if (!result
) goto failed
;
2436 value
= ast2obj_list(o
->v
.Dict
.keys
, ast2obj_expr
);
2437 if (!value
) goto failed
;
2438 if (PyObject_SetAttrString(result
, "keys", value
) == -1)
2441 value
= ast2obj_list(o
->v
.Dict
.values
, ast2obj_expr
);
2442 if (!value
) goto failed
;
2443 if (PyObject_SetAttrString(result
, "values", value
) == -1)
2448 result
= PyType_GenericNew(ListComp_type
, NULL
, NULL
);
2449 if (!result
) goto failed
;
2450 value
= ast2obj_expr(o
->v
.ListComp
.elt
);
2451 if (!value
) goto failed
;
2452 if (PyObject_SetAttrString(result
, "elt", value
) == -1)
2455 value
= ast2obj_list(o
->v
.ListComp
.generators
,
2456 ast2obj_comprehension
);
2457 if (!value
) goto failed
;
2458 if (PyObject_SetAttrString(result
, "generators", value
) == -1)
2462 case GeneratorExp_kind
:
2463 result
= PyType_GenericNew(GeneratorExp_type
, NULL
, NULL
);
2464 if (!result
) goto failed
;
2465 value
= ast2obj_expr(o
->v
.GeneratorExp
.elt
);
2466 if (!value
) goto failed
;
2467 if (PyObject_SetAttrString(result
, "elt", value
) == -1)
2470 value
= ast2obj_list(o
->v
.GeneratorExp
.generators
,
2471 ast2obj_comprehension
);
2472 if (!value
) goto failed
;
2473 if (PyObject_SetAttrString(result
, "generators", value
) == -1)
2478 result
= PyType_GenericNew(Yield_type
, NULL
, NULL
);
2479 if (!result
) goto failed
;
2480 value
= ast2obj_expr(o
->v
.Yield
.value
);
2481 if (!value
) goto failed
;
2482 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2487 result
= PyType_GenericNew(Compare_type
, NULL
, NULL
);
2488 if (!result
) goto failed
;
2489 value
= ast2obj_expr(o
->v
.Compare
.left
);
2490 if (!value
) goto failed
;
2491 if (PyObject_SetAttrString(result
, "left", value
) == -1)
2495 int i
, n
= asdl_seq_LEN(o
->v
.Compare
.ops
);
2496 value
= PyList_New(n
);
2497 if (!value
) goto failed
;
2498 for(i
= 0; i
< n
; i
++)
2499 PyList_SET_ITEM(value
, i
, ast2obj_cmpop((cmpop_ty
)asdl_seq_GET(o
->v
.Compare
.ops
, i
)));
2501 if (!value
) goto failed
;
2502 if (PyObject_SetAttrString(result
, "ops", value
) == -1)
2505 value
= ast2obj_list(o
->v
.Compare
.comparators
, ast2obj_expr
);
2506 if (!value
) goto failed
;
2507 if (PyObject_SetAttrString(result
, "comparators", value
) == -1)
2512 result
= PyType_GenericNew(Call_type
, NULL
, NULL
);
2513 if (!result
) goto failed
;
2514 value
= ast2obj_expr(o
->v
.Call
.func
);
2515 if (!value
) goto failed
;
2516 if (PyObject_SetAttrString(result
, "func", value
) == -1)
2519 value
= ast2obj_list(o
->v
.Call
.args
, ast2obj_expr
);
2520 if (!value
) goto failed
;
2521 if (PyObject_SetAttrString(result
, "args", value
) == -1)
2524 value
= ast2obj_list(o
->v
.Call
.keywords
, ast2obj_keyword
);
2525 if (!value
) goto failed
;
2526 if (PyObject_SetAttrString(result
, "keywords", value
) == -1)
2529 value
= ast2obj_expr(o
->v
.Call
.starargs
);
2530 if (!value
) goto failed
;
2531 if (PyObject_SetAttrString(result
, "starargs", value
) == -1)
2534 value
= ast2obj_expr(o
->v
.Call
.kwargs
);
2535 if (!value
) goto failed
;
2536 if (PyObject_SetAttrString(result
, "kwargs", value
) == -1)
2541 result
= PyType_GenericNew(Repr_type
, NULL
, NULL
);
2542 if (!result
) goto failed
;
2543 value
= ast2obj_expr(o
->v
.Repr
.value
);
2544 if (!value
) goto failed
;
2545 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2550 result
= PyType_GenericNew(Num_type
, NULL
, NULL
);
2551 if (!result
) goto failed
;
2552 value
= ast2obj_object(o
->v
.Num
.n
);
2553 if (!value
) goto failed
;
2554 if (PyObject_SetAttrString(result
, "n", value
) == -1)
2559 result
= PyType_GenericNew(Str_type
, NULL
, NULL
);
2560 if (!result
) goto failed
;
2561 value
= ast2obj_string(o
->v
.Str
.s
);
2562 if (!value
) goto failed
;
2563 if (PyObject_SetAttrString(result
, "s", value
) == -1)
2567 case Attribute_kind
:
2568 result
= PyType_GenericNew(Attribute_type
, NULL
, NULL
);
2569 if (!result
) goto failed
;
2570 value
= ast2obj_expr(o
->v
.Attribute
.value
);
2571 if (!value
) goto failed
;
2572 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2575 value
= ast2obj_identifier(o
->v
.Attribute
.attr
);
2576 if (!value
) goto failed
;
2577 if (PyObject_SetAttrString(result
, "attr", value
) == -1)
2580 value
= ast2obj_expr_context(o
->v
.Attribute
.ctx
);
2581 if (!value
) goto failed
;
2582 if (PyObject_SetAttrString(result
, "ctx", value
) == -1)
2586 case Subscript_kind
:
2587 result
= PyType_GenericNew(Subscript_type
, NULL
, NULL
);
2588 if (!result
) goto failed
;
2589 value
= ast2obj_expr(o
->v
.Subscript
.value
);
2590 if (!value
) goto failed
;
2591 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2594 value
= ast2obj_slice(o
->v
.Subscript
.slice
);
2595 if (!value
) goto failed
;
2596 if (PyObject_SetAttrString(result
, "slice", value
) == -1)
2599 value
= ast2obj_expr_context(o
->v
.Subscript
.ctx
);
2600 if (!value
) goto failed
;
2601 if (PyObject_SetAttrString(result
, "ctx", value
) == -1)
2606 result
= PyType_GenericNew(Name_type
, NULL
, NULL
);
2607 if (!result
) goto failed
;
2608 value
= ast2obj_identifier(o
->v
.Name
.id
);
2609 if (!value
) goto failed
;
2610 if (PyObject_SetAttrString(result
, "id", value
) == -1)
2613 value
= ast2obj_expr_context(o
->v
.Name
.ctx
);
2614 if (!value
) goto failed
;
2615 if (PyObject_SetAttrString(result
, "ctx", value
) == -1)
2620 result
= PyType_GenericNew(List_type
, NULL
, NULL
);
2621 if (!result
) goto failed
;
2622 value
= ast2obj_list(o
->v
.List
.elts
, ast2obj_expr
);
2623 if (!value
) goto failed
;
2624 if (PyObject_SetAttrString(result
, "elts", value
) == -1)
2627 value
= ast2obj_expr_context(o
->v
.List
.ctx
);
2628 if (!value
) goto failed
;
2629 if (PyObject_SetAttrString(result
, "ctx", value
) == -1)
2634 result
= PyType_GenericNew(Tuple_type
, NULL
, NULL
);
2635 if (!result
) goto failed
;
2636 value
= ast2obj_list(o
->v
.Tuple
.elts
, ast2obj_expr
);
2637 if (!value
) goto failed
;
2638 if (PyObject_SetAttrString(result
, "elts", value
) == -1)
2641 value
= ast2obj_expr_context(o
->v
.Tuple
.ctx
);
2642 if (!value
) goto failed
;
2643 if (PyObject_SetAttrString(result
, "ctx", value
) == -1)
2648 value
= ast2obj_int(o
->lineno
);
2649 if (!value
) goto failed
;
2650 if (PyObject_SetAttrString(result
, "lineno", value
) < 0)
2653 value
= ast2obj_int(o
->col_offset
);
2654 if (!value
) goto failed
;
2655 if (PyObject_SetAttrString(result
, "col_offset", value
) < 0)
2665 PyObject
* ast2obj_expr_context(expr_context_ty o
)
2669 Py_INCREF(Load_singleton
);
2670 return Load_singleton
;
2672 Py_INCREF(Store_singleton
);
2673 return Store_singleton
;
2675 Py_INCREF(Del_singleton
);
2676 return Del_singleton
;
2678 Py_INCREF(AugLoad_singleton
);
2679 return AugLoad_singleton
;
2681 Py_INCREF(AugStore_singleton
);
2682 return AugStore_singleton
;
2684 Py_INCREF(Param_singleton
);
2685 return Param_singleton
;
2687 return NULL
; /* cannot happen */
2690 ast2obj_slice(void* _o
)
2692 slice_ty o
= (slice_ty
)_o
;
2693 PyObject
*result
= NULL
, *value
= NULL
;
2701 result
= PyType_GenericNew(Ellipsis_type
, NULL
, NULL
);
2702 if (!result
) goto failed
;
2705 result
= PyType_GenericNew(Slice_type
, NULL
, NULL
);
2706 if (!result
) goto failed
;
2707 value
= ast2obj_expr(o
->v
.Slice
.lower
);
2708 if (!value
) goto failed
;
2709 if (PyObject_SetAttrString(result
, "lower", value
) == -1)
2712 value
= ast2obj_expr(o
->v
.Slice
.upper
);
2713 if (!value
) goto failed
;
2714 if (PyObject_SetAttrString(result
, "upper", value
) == -1)
2717 value
= ast2obj_expr(o
->v
.Slice
.step
);
2718 if (!value
) goto failed
;
2719 if (PyObject_SetAttrString(result
, "step", value
) == -1)
2724 result
= PyType_GenericNew(ExtSlice_type
, NULL
, NULL
);
2725 if (!result
) goto failed
;
2726 value
= ast2obj_list(o
->v
.ExtSlice
.dims
, ast2obj_slice
);
2727 if (!value
) goto failed
;
2728 if (PyObject_SetAttrString(result
, "dims", value
) == -1)
2733 result
= PyType_GenericNew(Index_type
, NULL
, NULL
);
2734 if (!result
) goto failed
;
2735 value
= ast2obj_expr(o
->v
.Index
.value
);
2736 if (!value
) goto failed
;
2737 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2749 PyObject
* ast2obj_boolop(boolop_ty o
)
2753 Py_INCREF(And_singleton
);
2754 return And_singleton
;
2756 Py_INCREF(Or_singleton
);
2757 return Or_singleton
;
2759 return NULL
; /* cannot happen */
2761 PyObject
* ast2obj_operator(operator_ty o
)
2765 Py_INCREF(Add_singleton
);
2766 return Add_singleton
;
2768 Py_INCREF(Sub_singleton
);
2769 return Sub_singleton
;
2771 Py_INCREF(Mult_singleton
);
2772 return Mult_singleton
;
2774 Py_INCREF(Div_singleton
);
2775 return Div_singleton
;
2777 Py_INCREF(Mod_singleton
);
2778 return Mod_singleton
;
2780 Py_INCREF(Pow_singleton
);
2781 return Pow_singleton
;
2783 Py_INCREF(LShift_singleton
);
2784 return LShift_singleton
;
2786 Py_INCREF(RShift_singleton
);
2787 return RShift_singleton
;
2789 Py_INCREF(BitOr_singleton
);
2790 return BitOr_singleton
;
2792 Py_INCREF(BitXor_singleton
);
2793 return BitXor_singleton
;
2795 Py_INCREF(BitAnd_singleton
);
2796 return BitAnd_singleton
;
2798 Py_INCREF(FloorDiv_singleton
);
2799 return FloorDiv_singleton
;
2801 return NULL
; /* cannot happen */
2803 PyObject
* ast2obj_unaryop(unaryop_ty o
)
2807 Py_INCREF(Invert_singleton
);
2808 return Invert_singleton
;
2810 Py_INCREF(Not_singleton
);
2811 return Not_singleton
;
2813 Py_INCREF(UAdd_singleton
);
2814 return UAdd_singleton
;
2816 Py_INCREF(USub_singleton
);
2817 return USub_singleton
;
2819 return NULL
; /* cannot happen */
2821 PyObject
* ast2obj_cmpop(cmpop_ty o
)
2825 Py_INCREF(Eq_singleton
);
2826 return Eq_singleton
;
2828 Py_INCREF(NotEq_singleton
);
2829 return NotEq_singleton
;
2831 Py_INCREF(Lt_singleton
);
2832 return Lt_singleton
;
2834 Py_INCREF(LtE_singleton
);
2835 return LtE_singleton
;
2837 Py_INCREF(Gt_singleton
);
2838 return Gt_singleton
;
2840 Py_INCREF(GtE_singleton
);
2841 return GtE_singleton
;
2843 Py_INCREF(Is_singleton
);
2844 return Is_singleton
;
2846 Py_INCREF(IsNot_singleton
);
2847 return IsNot_singleton
;
2849 Py_INCREF(In_singleton
);
2850 return In_singleton
;
2852 Py_INCREF(NotIn_singleton
);
2853 return NotIn_singleton
;
2855 return NULL
; /* cannot happen */
2858 ast2obj_comprehension(void* _o
)
2860 comprehension_ty o
= (comprehension_ty
)_o
;
2861 PyObject
*result
= NULL
, *value
= NULL
;
2867 result
= PyType_GenericNew(comprehension_type
, NULL
, NULL
);
2868 if (!result
) return NULL
;
2869 value
= ast2obj_expr(o
->target
);
2870 if (!value
) goto failed
;
2871 if (PyObject_SetAttrString(result
, "target", value
) == -1)
2874 value
= ast2obj_expr(o
->iter
);
2875 if (!value
) goto failed
;
2876 if (PyObject_SetAttrString(result
, "iter", value
) == -1)
2879 value
= ast2obj_list(o
->ifs
, ast2obj_expr
);
2880 if (!value
) goto failed
;
2881 if (PyObject_SetAttrString(result
, "ifs", value
) == -1)
2892 ast2obj_excepthandler(void* _o
)
2894 excepthandler_ty o
= (excepthandler_ty
)_o
;
2895 PyObject
*result
= NULL
, *value
= NULL
;
2901 result
= PyType_GenericNew(excepthandler_type
, NULL
, NULL
);
2902 if (!result
) return NULL
;
2903 value
= ast2obj_expr(o
->type
);
2904 if (!value
) goto failed
;
2905 if (PyObject_SetAttrString(result
, "type", value
) == -1)
2908 value
= ast2obj_expr(o
->name
);
2909 if (!value
) goto failed
;
2910 if (PyObject_SetAttrString(result
, "name", value
) == -1)
2913 value
= ast2obj_list(o
->body
, ast2obj_stmt
);
2914 if (!value
) goto failed
;
2915 if (PyObject_SetAttrString(result
, "body", value
) == -1)
2926 ast2obj_arguments(void* _o
)
2928 arguments_ty o
= (arguments_ty
)_o
;
2929 PyObject
*result
= NULL
, *value
= NULL
;
2935 result
= PyType_GenericNew(arguments_type
, NULL
, NULL
);
2936 if (!result
) return NULL
;
2937 value
= ast2obj_list(o
->args
, ast2obj_expr
);
2938 if (!value
) goto failed
;
2939 if (PyObject_SetAttrString(result
, "args", value
) == -1)
2942 value
= ast2obj_identifier(o
->vararg
);
2943 if (!value
) goto failed
;
2944 if (PyObject_SetAttrString(result
, "vararg", value
) == -1)
2947 value
= ast2obj_identifier(o
->kwarg
);
2948 if (!value
) goto failed
;
2949 if (PyObject_SetAttrString(result
, "kwarg", value
) == -1)
2952 value
= ast2obj_list(o
->defaults
, ast2obj_expr
);
2953 if (!value
) goto failed
;
2954 if (PyObject_SetAttrString(result
, "defaults", value
) == -1)
2965 ast2obj_keyword(void* _o
)
2967 keyword_ty o
= (keyword_ty
)_o
;
2968 PyObject
*result
= NULL
, *value
= NULL
;
2974 result
= PyType_GenericNew(keyword_type
, NULL
, NULL
);
2975 if (!result
) return NULL
;
2976 value
= ast2obj_identifier(o
->arg
);
2977 if (!value
) goto failed
;
2978 if (PyObject_SetAttrString(result
, "arg", value
) == -1)
2981 value
= ast2obj_expr(o
->value
);
2982 if (!value
) goto failed
;
2983 if (PyObject_SetAttrString(result
, "value", value
) == -1)
2994 ast2obj_alias(void* _o
)
2996 alias_ty o
= (alias_ty
)_o
;
2997 PyObject
*result
= NULL
, *value
= NULL
;
3003 result
= PyType_GenericNew(alias_type
, NULL
, NULL
);
3004 if (!result
) return NULL
;
3005 value
= ast2obj_identifier(o
->name
);
3006 if (!value
) goto failed
;
3007 if (PyObject_SetAttrString(result
, "name", value
) == -1)
3010 value
= ast2obj_identifier(o
->asname
);
3011 if (!value
) goto failed
;
3012 if (PyObject_SetAttrString(result
, "asname", value
) == -1)
3027 if (!init_types()) return;
3028 m
= Py_InitModule3("_ast", NULL
, NULL
);
3030 d
= PyModule_GetDict(m
);
3031 if (PyDict_SetItemString(d
, "AST", (PyObject
*)AST_type
) < 0) return;
3032 if (PyModule_AddIntConstant(m
, "PyCF_ONLY_AST", PyCF_ONLY_AST
) < 0)
3034 if (PyModule_AddStringConstant(m
, "__version__", "42753") < 0)
3036 if(PyDict_SetItemString(d
, "mod", (PyObject
*)mod_type
) < 0) return;
3037 if(PyDict_SetItemString(d
, "Module", (PyObject
*)Module_type
) < 0)
3039 if(PyDict_SetItemString(d
, "Interactive", (PyObject
*)Interactive_type
)
3041 if(PyDict_SetItemString(d
, "Expression", (PyObject
*)Expression_type
) <
3043 if(PyDict_SetItemString(d
, "Suite", (PyObject
*)Suite_type
) < 0) return;
3044 if(PyDict_SetItemString(d
, "stmt", (PyObject
*)stmt_type
) < 0) return;
3045 if(PyDict_SetItemString(d
, "FunctionDef", (PyObject
*)FunctionDef_type
)
3047 if(PyDict_SetItemString(d
, "ClassDef", (PyObject
*)ClassDef_type
) < 0)
3049 if(PyDict_SetItemString(d
, "Return", (PyObject
*)Return_type
) < 0)
3051 if(PyDict_SetItemString(d
, "Delete", (PyObject
*)Delete_type
) < 0)
3053 if(PyDict_SetItemString(d
, "Assign", (PyObject
*)Assign_type
) < 0)
3055 if(PyDict_SetItemString(d
, "AugAssign", (PyObject
*)AugAssign_type
) < 0)
3057 if(PyDict_SetItemString(d
, "Print", (PyObject
*)Print_type
) < 0) return;
3058 if(PyDict_SetItemString(d
, "For", (PyObject
*)For_type
) < 0) return;
3059 if(PyDict_SetItemString(d
, "While", (PyObject
*)While_type
) < 0) return;
3060 if(PyDict_SetItemString(d
, "If", (PyObject
*)If_type
) < 0) return;
3061 if(PyDict_SetItemString(d
, "With", (PyObject
*)With_type
) < 0) return;
3062 if(PyDict_SetItemString(d
, "Raise", (PyObject
*)Raise_type
) < 0) return;
3063 if(PyDict_SetItemString(d
, "TryExcept", (PyObject
*)TryExcept_type
) < 0)
3065 if(PyDict_SetItemString(d
, "TryFinally", (PyObject
*)TryFinally_type
) <
3067 if(PyDict_SetItemString(d
, "Assert", (PyObject
*)Assert_type
) < 0)
3069 if(PyDict_SetItemString(d
, "Import", (PyObject
*)Import_type
) < 0)
3071 if(PyDict_SetItemString(d
, "ImportFrom", (PyObject
*)ImportFrom_type
) <
3073 if(PyDict_SetItemString(d
, "Exec", (PyObject
*)Exec_type
) < 0) return;
3074 if(PyDict_SetItemString(d
, "Global", (PyObject
*)Global_type
) < 0)
3076 if(PyDict_SetItemString(d
, "Expr", (PyObject
*)Expr_type
) < 0) return;
3077 if(PyDict_SetItemString(d
, "Pass", (PyObject
*)Pass_type
) < 0) return;
3078 if(PyDict_SetItemString(d
, "Break", (PyObject
*)Break_type
) < 0) return;
3079 if(PyDict_SetItemString(d
, "Continue", (PyObject
*)Continue_type
) < 0)
3081 if(PyDict_SetItemString(d
, "expr", (PyObject
*)expr_type
) < 0) return;
3082 if(PyDict_SetItemString(d
, "BoolOp", (PyObject
*)BoolOp_type
) < 0)
3084 if(PyDict_SetItemString(d
, "BinOp", (PyObject
*)BinOp_type
) < 0) return;
3085 if(PyDict_SetItemString(d
, "UnaryOp", (PyObject
*)UnaryOp_type
) < 0)
3087 if(PyDict_SetItemString(d
, "Lambda", (PyObject
*)Lambda_type
) < 0)
3089 if(PyDict_SetItemString(d
, "IfExp", (PyObject
*)IfExp_type
) < 0) return;
3090 if(PyDict_SetItemString(d
, "Dict", (PyObject
*)Dict_type
) < 0) return;
3091 if(PyDict_SetItemString(d
, "ListComp", (PyObject
*)ListComp_type
) < 0)
3093 if(PyDict_SetItemString(d
, "GeneratorExp",
3094 (PyObject
*)GeneratorExp_type
) < 0) return;
3095 if(PyDict_SetItemString(d
, "Yield", (PyObject
*)Yield_type
) < 0) return;
3096 if(PyDict_SetItemString(d
, "Compare", (PyObject
*)Compare_type
) < 0)
3098 if(PyDict_SetItemString(d
, "Call", (PyObject
*)Call_type
) < 0) return;
3099 if(PyDict_SetItemString(d
, "Repr", (PyObject
*)Repr_type
) < 0) return;
3100 if(PyDict_SetItemString(d
, "Num", (PyObject
*)Num_type
) < 0) return;
3101 if(PyDict_SetItemString(d
, "Str", (PyObject
*)Str_type
) < 0) return;
3102 if(PyDict_SetItemString(d
, "Attribute", (PyObject
*)Attribute_type
) < 0)
3104 if(PyDict_SetItemString(d
, "Subscript", (PyObject
*)Subscript_type
) < 0)
3106 if(PyDict_SetItemString(d
, "Name", (PyObject
*)Name_type
) < 0) return;
3107 if(PyDict_SetItemString(d
, "List", (PyObject
*)List_type
) < 0) return;
3108 if(PyDict_SetItemString(d
, "Tuple", (PyObject
*)Tuple_type
) < 0) return;
3109 if(PyDict_SetItemString(d
, "expr_context",
3110 (PyObject
*)expr_context_type
) < 0) return;
3111 if(PyDict_SetItemString(d
, "Load", (PyObject
*)Load_type
) < 0) return;
3112 if(PyDict_SetItemString(d
, "Store", (PyObject
*)Store_type
) < 0) return;
3113 if(PyDict_SetItemString(d
, "Del", (PyObject
*)Del_type
) < 0) return;
3114 if(PyDict_SetItemString(d
, "AugLoad", (PyObject
*)AugLoad_type
) < 0)
3116 if(PyDict_SetItemString(d
, "AugStore", (PyObject
*)AugStore_type
) < 0)
3118 if(PyDict_SetItemString(d
, "Param", (PyObject
*)Param_type
) < 0) return;
3119 if(PyDict_SetItemString(d
, "slice", (PyObject
*)slice_type
) < 0) return;
3120 if(PyDict_SetItemString(d
, "Ellipsis", (PyObject
*)Ellipsis_type
) < 0)
3122 if(PyDict_SetItemString(d
, "Slice", (PyObject
*)Slice_type
) < 0) return;
3123 if(PyDict_SetItemString(d
, "ExtSlice", (PyObject
*)ExtSlice_type
) < 0)
3125 if(PyDict_SetItemString(d
, "Index", (PyObject
*)Index_type
) < 0) return;
3126 if(PyDict_SetItemString(d
, "boolop", (PyObject
*)boolop_type
) < 0)
3128 if(PyDict_SetItemString(d
, "And", (PyObject
*)And_type
) < 0) return;
3129 if(PyDict_SetItemString(d
, "Or", (PyObject
*)Or_type
) < 0) return;
3130 if(PyDict_SetItemString(d
, "operator", (PyObject
*)operator_type
) < 0)
3132 if(PyDict_SetItemString(d
, "Add", (PyObject
*)Add_type
) < 0) return;
3133 if(PyDict_SetItemString(d
, "Sub", (PyObject
*)Sub_type
) < 0) return;
3134 if(PyDict_SetItemString(d
, "Mult", (PyObject
*)Mult_type
) < 0) return;
3135 if(PyDict_SetItemString(d
, "Div", (PyObject
*)Div_type
) < 0) return;
3136 if(PyDict_SetItemString(d
, "Mod", (PyObject
*)Mod_type
) < 0) return;
3137 if(PyDict_SetItemString(d
, "Pow", (PyObject
*)Pow_type
) < 0) return;
3138 if(PyDict_SetItemString(d
, "LShift", (PyObject
*)LShift_type
) < 0)
3140 if(PyDict_SetItemString(d
, "RShift", (PyObject
*)RShift_type
) < 0)
3142 if(PyDict_SetItemString(d
, "BitOr", (PyObject
*)BitOr_type
) < 0) return;
3143 if(PyDict_SetItemString(d
, "BitXor", (PyObject
*)BitXor_type
) < 0)
3145 if(PyDict_SetItemString(d
, "BitAnd", (PyObject
*)BitAnd_type
) < 0)
3147 if(PyDict_SetItemString(d
, "FloorDiv", (PyObject
*)FloorDiv_type
) < 0)
3149 if(PyDict_SetItemString(d
, "unaryop", (PyObject
*)unaryop_type
) < 0)
3151 if(PyDict_SetItemString(d
, "Invert", (PyObject
*)Invert_type
) < 0)
3153 if(PyDict_SetItemString(d
, "Not", (PyObject
*)Not_type
) < 0) return;
3154 if(PyDict_SetItemString(d
, "UAdd", (PyObject
*)UAdd_type
) < 0) return;
3155 if(PyDict_SetItemString(d
, "USub", (PyObject
*)USub_type
) < 0) return;
3156 if(PyDict_SetItemString(d
, "cmpop", (PyObject
*)cmpop_type
) < 0) return;
3157 if(PyDict_SetItemString(d
, "Eq", (PyObject
*)Eq_type
) < 0) return;
3158 if(PyDict_SetItemString(d
, "NotEq", (PyObject
*)NotEq_type
) < 0) return;
3159 if(PyDict_SetItemString(d
, "Lt", (PyObject
*)Lt_type
) < 0) return;
3160 if(PyDict_SetItemString(d
, "LtE", (PyObject
*)LtE_type
) < 0) return;
3161 if(PyDict_SetItemString(d
, "Gt", (PyObject
*)Gt_type
) < 0) return;
3162 if(PyDict_SetItemString(d
, "GtE", (PyObject
*)GtE_type
) < 0) return;
3163 if(PyDict_SetItemString(d
, "Is", (PyObject
*)Is_type
) < 0) return;
3164 if(PyDict_SetItemString(d
, "IsNot", (PyObject
*)IsNot_type
) < 0) return;
3165 if(PyDict_SetItemString(d
, "In", (PyObject
*)In_type
) < 0) return;
3166 if(PyDict_SetItemString(d
, "NotIn", (PyObject
*)NotIn_type
) < 0) return;
3167 if(PyDict_SetItemString(d
, "comprehension",
3168 (PyObject
*)comprehension_type
) < 0) return;
3169 if(PyDict_SetItemString(d
, "excepthandler",
3170 (PyObject
*)excepthandler_type
) < 0) return;
3171 if(PyDict_SetItemString(d
, "arguments", (PyObject
*)arguments_type
) < 0)
3173 if(PyDict_SetItemString(d
, "keyword", (PyObject
*)keyword_type
) < 0)
3175 if(PyDict_SetItemString(d
, "alias", (PyObject
*)alias_type
) < 0) return;
3179 PyObject
* PyAST_mod2obj(mod_ty t
)
3182 return ast2obj_mod(t
);