3202 lines · 110.8 KB · C
RawDownload
/* File automatically generated by Parser/asdl_c.py */ #include "Python.h"#include "Python-ast.h" static PyTypeObject* AST_type;static PyTypeObject *mod_type;static PyObject* ast2obj_mod(void*);static PyTypeObject *Module_type;static char *Module_fields[]={        "body",};static PyTypeObject *Interactive_type;static char *Interactive_fields[]={        "body",};static PyTypeObject *Expression_type;static char *Expression_fields[]={        "body",};static PyTypeObject *Suite_type;static char *Suite_fields[]={        "body",};static PyTypeObject *stmt_type;static char *stmt_attributes[] = {        "lineno",        "col_offset",};static PyObject* ast2obj_stmt(void*);static PyTypeObject *FunctionDef_type;static char *FunctionDef_fields[]={        "name",        "args",        "body",        "decorators",};static PyTypeObject *ClassDef_type;static char *ClassDef_fields[]={        "name",        "bases",        "body",};static PyTypeObject *Return_type;static char *Return_fields[]={        "value",};static PyTypeObject *Delete_type;static char *Delete_fields[]={        "targets",};static PyTypeObject *Assign_type;static char *Assign_fields[]={        "targets",        "value",};static PyTypeObject *AugAssign_type;static char *AugAssign_fields[]={        "target",        "op",        "value",};static PyTypeObject *Print_type;static char *Print_fields[]={        "dest",        "values",        "nl",};static PyTypeObject *For_type;static char *For_fields[]={        "target",        "iter",        "body",        "orelse",};static PyTypeObject *While_type;static char *While_fields[]={        "test",        "body",        "orelse",};static PyTypeObject *If_type;static char *If_fields[]={        "test",        "body",        "orelse",};static PyTypeObject *With_type;static char *With_fields[]={        "context_expr",        "optional_vars",        "body",};static PyTypeObject *Raise_type;static char *Raise_fields[]={        "type",        "inst",        "tback",};static PyTypeObject *TryExcept_type;static char *TryExcept_fields[]={        "body",        "handlers",        "orelse",};static PyTypeObject *TryFinally_type;static char *TryFinally_fields[]={        "body",        "finalbody",};static PyTypeObject *Assert_type;static char *Assert_fields[]={        "test",        "msg",};static PyTypeObject *Import_type;static char *Import_fields[]={        "names",};static PyTypeObject *ImportFrom_type;static char *ImportFrom_fields[]={        "module",        "names",        "level",};static PyTypeObject *Exec_type;static char *Exec_fields[]={        "body",        "globals",        "locals",};static PyTypeObject *Global_type;static char *Global_fields[]={        "names",};static PyTypeObject *Expr_type;static char *Expr_fields[]={        "value",};static PyTypeObject *Pass_type;static PyTypeObject *Break_type;static PyTypeObject *Continue_type;static PyTypeObject *expr_type;static char *expr_attributes[] = {        "lineno",        "col_offset",};static PyObject* ast2obj_expr(void*);static PyTypeObject *BoolOp_type;static char *BoolOp_fields[]={        "op",        "values",};static PyTypeObject *BinOp_type;static char *BinOp_fields[]={        "left",        "op",        "right",};static PyTypeObject *UnaryOp_type;static char *UnaryOp_fields[]={        "op",        "operand",};static PyTypeObject *Lambda_type;static char *Lambda_fields[]={        "args",        "body",};static PyTypeObject *IfExp_type;static char *IfExp_fields[]={        "test",        "body",        "orelse",};static PyTypeObject *Dict_type;static char *Dict_fields[]={        "keys",        "values",};static PyTypeObject *ListComp_type;static char *ListComp_fields[]={        "elt",        "generators",};static PyTypeObject *GeneratorExp_type;static char *GeneratorExp_fields[]={        "elt",        "generators",};static PyTypeObject *Yield_type;static char *Yield_fields[]={        "value",};static PyTypeObject *Compare_type;static char *Compare_fields[]={        "left",        "ops",        "comparators",};static PyTypeObject *Call_type;static char *Call_fields[]={        "func",        "args",        "keywords",        "starargs",        "kwargs",};static PyTypeObject *Repr_type;static char *Repr_fields[]={        "value",};static PyTypeObject *Num_type;static char *Num_fields[]={        "n",};static PyTypeObject *Str_type;static char *Str_fields[]={        "s",};static PyTypeObject *Attribute_type;static char *Attribute_fields[]={        "value",        "attr",        "ctx",};static PyTypeObject *Subscript_type;static char *Subscript_fields[]={        "value",        "slice",        "ctx",};static PyTypeObject *Name_type;static char *Name_fields[]={        "id",        "ctx",};static PyTypeObject *List_type;static char *List_fields[]={        "elts",        "ctx",};static PyTypeObject *Tuple_type;static char *Tuple_fields[]={        "elts",        "ctx",};static PyTypeObject *expr_context_type;static PyObject *Load_singleton, *Store_singleton, *Del_singleton,*AugLoad_singleton, *AugStore_singleton, *Param_singleton;static PyObject* ast2obj_expr_context(expr_context_ty);static PyTypeObject *Load_type;static PyTypeObject *Store_type;static PyTypeObject *Del_type;static PyTypeObject *AugLoad_type;static PyTypeObject *AugStore_type;static PyTypeObject *Param_type;static PyTypeObject *slice_type;static PyObject* ast2obj_slice(void*);static PyTypeObject *Ellipsis_type;static PyTypeObject *Slice_type;static char *Slice_fields[]={        "lower",        "upper",        "step",};static PyTypeObject *ExtSlice_type;static char *ExtSlice_fields[]={        "dims",};static PyTypeObject *Index_type;static char *Index_fields[]={        "value",};static PyTypeObject *boolop_type;static PyObject *And_singleton, *Or_singleton;static PyObject* ast2obj_boolop(boolop_ty);static PyTypeObject *And_type;static PyTypeObject *Or_type;static PyTypeObject *operator_type;static PyObject *Add_singleton, *Sub_singleton, *Mult_singleton,*Div_singleton, *Mod_singleton, *Pow_singleton, *LShift_singleton,*RShift_singleton, *BitOr_singleton, *BitXor_singleton, *BitAnd_singleton,*FloorDiv_singleton;static PyObject* ast2obj_operator(operator_ty);static PyTypeObject *Add_type;static PyTypeObject *Sub_type;static PyTypeObject *Mult_type;static PyTypeObject *Div_type;static PyTypeObject *Mod_type;static PyTypeObject *Pow_type;static PyTypeObject *LShift_type;static PyTypeObject *RShift_type;static PyTypeObject *BitOr_type;static PyTypeObject *BitXor_type;static PyTypeObject *BitAnd_type;static PyTypeObject *FloorDiv_type;static PyTypeObject *unaryop_type;static PyObject *Invert_singleton, *Not_singleton, *UAdd_singleton,*USub_singleton;static PyObject* ast2obj_unaryop(unaryop_ty);static PyTypeObject *Invert_type;static PyTypeObject *Not_type;static PyTypeObject *UAdd_type;static PyTypeObject *USub_type;static PyTypeObject *cmpop_type;static PyObject *Eq_singleton, *NotEq_singleton, *Lt_singleton, *LtE_singleton,*Gt_singleton, *GtE_singleton, *Is_singleton, *IsNot_singleton, *In_singleton,*NotIn_singleton;static PyObject* ast2obj_cmpop(cmpop_ty);static PyTypeObject *Eq_type;static PyTypeObject *NotEq_type;static PyTypeObject *Lt_type;static PyTypeObject *LtE_type;static PyTypeObject *Gt_type;static PyTypeObject *GtE_type;static PyTypeObject *Is_type;static PyTypeObject *IsNot_type;static PyTypeObject *In_type;static PyTypeObject *NotIn_type;static PyTypeObject *comprehension_type;static PyObject* ast2obj_comprehension(void*);static char *comprehension_fields[]={        "target",        "iter",        "ifs",};static PyTypeObject *excepthandler_type;static PyObject* ast2obj_excepthandler(void*);static char *excepthandler_fields[]={        "type",        "name",        "body",        "lineno",        "col_offset",};static PyTypeObject *arguments_type;static PyObject* ast2obj_arguments(void*);static char *arguments_fields[]={        "args",        "vararg",        "kwarg",        "defaults",};static PyTypeObject *keyword_type;static PyObject* ast2obj_keyword(void*);static char *keyword_fields[]={        "arg",        "value",};static PyTypeObject *alias_type;static PyObject* ast2obj_alias(void*);static char *alias_fields[]={        "name",        "asname",};  static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int num_fields){    PyObject *fnames, *result;    int i;    if (num_fields) {        fnames = PyTuple_New(num_fields);        if (!fnames) return NULL;    } else {        fnames = Py_None;        Py_INCREF(Py_None);    }    for(i=0; i < num_fields; i++) {        PyObject *field = PyString_FromString(fields[i]);        if (!field) {            Py_DECREF(fnames);            return NULL;        }        PyTuple_SET_ITEM(fnames, i, field);    }    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){sOss}",                    type, base, "_fields", fnames, "__module__", "_ast");    Py_DECREF(fnames);    return (PyTypeObject*)result;} static int add_attributes(PyTypeObject* type, char**attrs, int num_fields){    int i, result;    PyObject *s, *l = PyList_New(num_fields);    if (!l) return 0;    for(i = 0; i < num_fields; i++) {        s = PyString_FromString(attrs[i]);        if (!s) {            Py_DECREF(l);            return 0;        }        PyList_SET_ITEM(l, i, s);    }    result = PyObject_SetAttrString((PyObject*)type, "_attributes", l) >= 0;    Py_DECREF(l);    return result;} static PyObject* ast2obj_list(asdl_seq *seq, PyObject* (*func)(void*)){    int i, n = asdl_seq_LEN(seq);    PyObject *result = PyList_New(n);    PyObject *value;    if (!result)        return NULL;    for (i = 0; i < n; i++) {        value = func(asdl_seq_GET(seq, i));        if (!value) {            Py_DECREF(result);            return NULL;        }        PyList_SET_ITEM(result, i, value);    }    return result;} static PyObject* ast2obj_object(void *o){    if (!o)        o = Py_None;    Py_INCREF((PyObject*)o);    return (PyObject*)o;}#define ast2obj_identifier ast2obj_object#define ast2obj_string ast2obj_objectstatic PyObject* ast2obj_bool(bool b){    return PyBool_FromLong(b);} static PyObject* ast2obj_int(bool b){    return PyInt_FromLong(b);} static int init_types(void){        static int initialized;        if (initialized) return 1;        AST_type = make_type("AST", &PyBaseObject_Type, NULL, 0);        mod_type = make_type("mod", AST_type, NULL, 0);        if (!mod_type) return 0;        if (!add_attributes(mod_type, NULL, 0)) return 0;        Module_type = make_type("Module", mod_type, Module_fields, 1);        if (!Module_type) return 0;        Interactive_type = make_type("Interactive", mod_type,                                     Interactive_fields, 1);        if (!Interactive_type) return 0;        Expression_type = make_type("Expression", mod_type, Expression_fields,                                    1);        if (!Expression_type) return 0;        Suite_type = make_type("Suite", mod_type, Suite_fields, 1);        if (!Suite_type) return 0;        stmt_type = make_type("stmt", AST_type, NULL, 0);        if (!stmt_type) return 0;        if (!add_attributes(stmt_type, stmt_attributes, 2)) return 0;        FunctionDef_type = make_type("FunctionDef", stmt_type,                                     FunctionDef_fields, 4);        if (!FunctionDef_type) return 0;        ClassDef_type = make_type("ClassDef", stmt_type, ClassDef_fields, 3);        if (!ClassDef_type) return 0;        Return_type = make_type("Return", stmt_type, Return_fields, 1);        if (!Return_type) return 0;        Delete_type = make_type("Delete", stmt_type, Delete_fields, 1);        if (!Delete_type) return 0;        Assign_type = make_type("Assign", stmt_type, Assign_fields, 2);        if (!Assign_type) return 0;        AugAssign_type = make_type("AugAssign", stmt_type, AugAssign_fields, 3);        if (!AugAssign_type) return 0;        Print_type = make_type("Print", stmt_type, Print_fields, 3);        if (!Print_type) return 0;        For_type = make_type("For", stmt_type, For_fields, 4);        if (!For_type) return 0;        While_type = make_type("While", stmt_type, While_fields, 3);        if (!While_type) return 0;        If_type = make_type("If", stmt_type, If_fields, 3);        if (!If_type) return 0;        With_type = make_type("With", stmt_type, With_fields, 3);        if (!With_type) return 0;        Raise_type = make_type("Raise", stmt_type, Raise_fields, 3);        if (!Raise_type) return 0;        TryExcept_type = make_type("TryExcept", stmt_type, TryExcept_fields, 3);        if (!TryExcept_type) return 0;        TryFinally_type = make_type("TryFinally", stmt_type, TryFinally_fields,                                    2);        if (!TryFinally_type) return 0;        Assert_type = make_type("Assert", stmt_type, Assert_fields, 2);        if (!Assert_type) return 0;        Import_type = make_type("Import", stmt_type, Import_fields, 1);        if (!Import_type) return 0;        ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields,                                    3);        if (!ImportFrom_type) return 0;        Exec_type = make_type("Exec", stmt_type, Exec_fields, 3);        if (!Exec_type) return 0;        Global_type = make_type("Global", stmt_type, Global_fields, 1);        if (!Global_type) return 0;

Lines 1–500 of 3202.