bpo-40334: PEP 617 implementation: New PEG parser for CPython (GH-19503)

Co-authored-by: Guido van Rossum <guido@python.org>
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
diff --git a/Include/compile.h b/Include/compile.h
index a2db65d..dbba85b 100644
--- a/Include/compile.h
+++ b/Include/compile.h
@@ -108,4 +108,7 @@
 #define Py_eval_input 258
 #define Py_func_type_input 345
 
+/* This doesn't need to match anything */
+#define Py_fstring_input 800
+
 #endif /* !Py_COMPILE_H */
diff --git a/Include/cpython/initconfig.h b/Include/cpython/initconfig.h
index c5fa2b3..6539596 100644
--- a/Include/cpython/initconfig.h
+++ b/Include/cpython/initconfig.h
@@ -147,6 +147,10 @@
        Set to 1 by -X faulthandler and PYTHONFAULTHANDLER. -1 means unset. */
     int faulthandler;
 
+    /* Enable PEG parser?
+       1 by default, set to 0 by -X oldparser and PYTHONOLDPARSER */
+    int use_peg;
+
     /* Enable tracemalloc?
        Set by -X tracemalloc=N and PYTHONTRACEMALLOC. -1 means unset */
     int tracemalloc;
diff --git a/Include/pegen_interface.h b/Include/pegen_interface.h
new file mode 100644
index 0000000..bf5b296
--- /dev/null
+++ b/Include/pegen_interface.h
@@ -0,0 +1,32 @@
+#ifndef Py_LIMITED_API
+#ifndef Py_PEGENINTERFACE
+#define Py_PEGENINTERFACE
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "Python.h"
+#include "Python-ast.h"
+
+PyAPI_FUNC(mod_ty) PyPegen_ASTFromFile(const char *filename, int mode, PyArena *arena);
+PyAPI_FUNC(mod_ty) PyPegen_ASTFromString(const char *str, int mode, PyCompilerFlags *flags,
+                                         PyArena *arena);
+PyAPI_FUNC(mod_ty) PyPegen_ASTFromStringObject(const char *str, PyObject* filename, int mode,
+                                               PyCompilerFlags *flags, PyArena *arena);
+PyAPI_FUNC(mod_ty) PyPegen_ASTFromFileObject(FILE *fp, PyObject *filename_ob,
+                                             int mode, const char *enc, const char *ps1,
+                                             const char *ps2, int *errcode, PyArena *arena);
+PyAPI_FUNC(PyCodeObject *) PyPegen_CodeObjectFromFile(const char *filename, int mode);
+PyAPI_FUNC(PyCodeObject *) PyPegen_CodeObjectFromString(const char *str, int mode,
+                                                        PyCompilerFlags *flags);
+PyAPI_FUNC(PyCodeObject *) PyPegen_CodeObjectFromFileObject(FILE *, PyObject *filename_ob,
+                                                            int mode, const char *enc,
+                                                            const char *ps1,
+                                                            const char *ps2,
+                                                            int *errcode);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_PEGENINTERFACE*/
+#endif /* !Py_LIMITED_API */