File indexing completed on 2025-11-19 09:50:49
0001 #ifndef Py_INTERNAL_PARSER_H
0002 #define Py_INTERNAL_PARSER_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006
0007 #ifndef Py_BUILD_CORE
0008 # error "this header requires Py_BUILD_CORE define"
0009 #endif
0010
0011
0012 #include "pycore_ast.h" // struct _expr
0013 #include "pycore_global_strings.h" // _Py_DECLARE_STR()
0014 #include "pycore_pyarena.h" // PyArena
0015
0016
0017 #ifdef Py_DEBUG
0018 #define _PYPEGEN_NSTATISTICS 2000
0019 #endif
0020
0021 struct _parser_runtime_state {
0022 #ifdef Py_DEBUG
0023 long memo_statistics[_PYPEGEN_NSTATISTICS];
0024 #ifdef Py_GIL_DISABLED
0025 PyMutex mutex;
0026 #endif
0027 #else
0028 int _not_used;
0029 #endif
0030 struct _expr dummy_name;
0031 };
0032
0033 _Py_DECLARE_STR(empty, "")
0034 #if defined(Py_DEBUG) && defined(Py_GIL_DISABLED)
0035 #define _parser_runtime_state_INIT \
0036 { \
0037 .mutex = {0}, \
0038 .dummy_name = { \
0039 .kind = Name_kind, \
0040 .v.Name.id = &_Py_STR(empty), \
0041 .v.Name.ctx = Load, \
0042 .lineno = 1, \
0043 .col_offset = 0, \
0044 .end_lineno = 1, \
0045 .end_col_offset = 0, \
0046 }, \
0047 }
0048 #else
0049 #define _parser_runtime_state_INIT \
0050 { \
0051 .dummy_name = { \
0052 .kind = Name_kind, \
0053 .v.Name.id = &_Py_STR(empty), \
0054 .v.Name.ctx = Load, \
0055 .lineno = 1, \
0056 .col_offset = 0, \
0057 .end_lineno = 1, \
0058 .end_col_offset = 0, \
0059 }, \
0060 }
0061 #endif
0062
0063 extern struct _mod* _PyParser_ASTFromString(
0064 const char *str,
0065 PyObject* filename,
0066 int mode,
0067 PyCompilerFlags *flags,
0068 PyArena *arena);
0069
0070 extern struct _mod* _PyParser_ASTFromFile(
0071 FILE *fp,
0072 PyObject *filename_ob,
0073 const char *enc,
0074 int mode,
0075 const char *ps1,
0076 const char *ps2,
0077 PyCompilerFlags *flags,
0078 int *errcode,
0079 PyArena *arena);
0080 extern struct _mod* _PyParser_InteractiveASTFromFile(
0081 FILE *fp,
0082 PyObject *filename_ob,
0083 const char *enc,
0084 int mode,
0085 const char *ps1,
0086 const char *ps2,
0087 PyCompilerFlags *flags,
0088 int *errcode,
0089 PyObject **interactive_src,
0090 PyArena *arena);
0091
0092 #ifdef __cplusplus
0093 }
0094 #endif
0095 #endif