5 #include "Python-ast.h"
9 symtable_symtable(PyObject
*self
, PyObject
*args
)
19 if (!PyArg_ParseTuple(args
, "sss:symtable", &str
, &filename
,
22 if (strcmp(startstr
, "exec") == 0)
23 start
= Py_file_input
;
24 else if (strcmp(startstr
, "eval") == 0)
25 start
= Py_eval_input
;
26 else if (strcmp(startstr
, "single") == 0)
27 start
= Py_single_input
;
29 PyErr_SetString(PyExc_ValueError
,
30 "symtable() arg 3 must be 'exec' or 'eval' or 'single'");
33 st
= Py_SymtableString(str
, filename
, start
);
38 PyMem_Free((void *)st
->st_future
);
43 static PyMethodDef symtable_methods
[] = {
44 {"symtable", symtable_symtable
, METH_VARARGS
,
45 PyDoc_STR("Return symbol and scope dictionaries"
46 " used internally by compiler.")},
47 {NULL
, NULL
} /* sentinel */
55 m
= Py_InitModule("_symtable", symtable_methods
);
58 PyModule_AddIntConstant(m
, "USE", USE
);
59 PyModule_AddIntConstant(m
, "DEF_GLOBAL", DEF_GLOBAL
);
60 PyModule_AddIntConstant(m
, "DEF_LOCAL", DEF_LOCAL
);
61 PyModule_AddIntConstant(m
, "DEF_PARAM", DEF_PARAM
);
62 PyModule_AddIntConstant(m
, "DEF_FREE", DEF_FREE
);
63 PyModule_AddIntConstant(m
, "DEF_FREE_CLASS", DEF_FREE_CLASS
);
64 PyModule_AddIntConstant(m
, "DEF_IMPORT", DEF_IMPORT
);
65 PyModule_AddIntConstant(m
, "DEF_BOUND", DEF_BOUND
);
67 PyModule_AddIntConstant(m
, "TYPE_FUNCTION", FunctionBlock
);
68 PyModule_AddIntConstant(m
, "TYPE_CLASS", ClassBlock
);
69 PyModule_AddIntConstant(m
, "TYPE_MODULE", ModuleBlock
);
71 PyModule_AddIntConstant(m
, "OPT_IMPORT_STAR", OPT_IMPORT_STAR
);
72 PyModule_AddIntConstant(m
, "OPT_EXEC", OPT_EXEC
);
73 PyModule_AddIntConstant(m
, "OPT_BARE_EXEC", OPT_BARE_EXEC
);
75 PyModule_AddIntConstant(m
, "LOCAL", LOCAL
);
76 PyModule_AddIntConstant(m
, "GLOBAL_EXPLICIT", GLOBAL_EXPLICIT
);
77 PyModule_AddIntConstant(m
, "GLOBAL_IMPLICIT", GLOBAL_IMPLICIT
);
78 PyModule_AddIntConstant(m
, "FREE", FREE
);
79 PyModule_AddIntConstant(m
, "CELL", CELL
);
81 PyModule_AddIntConstant(m
, "SCOPE_OFF", SCOPE_OFF
);
82 PyModule_AddIntConstant(m
, "SCOPE_MASK", SCOPE_MASK
);