1 #ifndef Py_INTERNAL_PARSER_H
2 #define Py_INTERNAL_PARSER_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6
7 #ifndef Py_BUILD_CORE
8 # error "this header requires Py_BUILD_CORE define"
9 #endif
10
11
12 #include "pycore_ast.h" // struct _expr
13 #include "pycore_global_strings.h" // _Py_DECLARE_STR()
14 #include "pycore_pyarena.h" // PyArena
15
16
17 #ifdef Py_DEBUG
18 #define _PYPEGEN_NSTATISTICS 2000
19 #endif
20
21 struct _parser_runtime_state {
22 #ifdef Py_DEBUG
23 long memo_statistics[_PYPEGEN_NSTATISTICS];
24 #else
25 int _not_used;
26 #endif
27 struct _expr dummy_name;
28 };
29
30 _Py_DECLARE_STR(empty, "")
31 #define _parser_runtime_state_INIT \
32 { \
33 .dummy_name = { \
34 .kind = Name_kind, \
35 .v.Name.id = &_Py_STR(empty), \
36 .v.Name.ctx = Load, \
37 .lineno = 1, \
38 .col_offset = 0, \
39 .end_lineno = 1, \
40 .end_col_offset = 0, \
41 }, \
42 }
43
44 extern struct _mod* _PyParser_ASTFromString(
45 const char *str,
46 PyObject* filename,
47 int mode,
48 PyCompilerFlags *flags,
49 PyArena *arena);
50
51 extern struct _mod* _PyParser_ASTFromFile(
52 FILE *fp,
53 PyObject *filename_ob,
54 const char *enc,
55 int mode,
56 const char *ps1,
57 const char *ps2,
58 PyCompilerFlags *flags,
59 int *errcode,
60 PyArena *arena);
61
62
63 #ifdef __cplusplus
64 }
65 #endif
66 #endif /* !Py_INTERNAL_PARSER_H */