summaryrefslogtreecommitdiff
path: root/Include
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-04-22 23:29:27 +0100
committerGitHub <noreply@github.com>2020-04-22 23:29:27 +0100
commitc5fc15685202cda73f7c3f5c6f299b0945f58508 (patch)
tree7624ae45b95f2812e801c5879bdbdcb796f570a6 /Include
parenta81849b0315277bb3937271174aaaa5059c0b445 (diff)
downloadcpython-git-c5fc15685202cda73f7c3f5c6f299b0945f58508.tar.gz
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>
Diffstat (limited to 'Include')
-rw-r--r--Include/compile.h3
-rw-r--r--Include/cpython/initconfig.h4
-rw-r--r--Include/pegen_interface.h32
3 files changed, 39 insertions, 0 deletions
diff --git a/Include/compile.h b/Include/compile.h
index a2db65d47f..dbba85bb5f 100644
--- a/Include/compile.h
+++ b/Include/compile.h
@@ -108,4 +108,7 @@ PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena, _PyASTOptimizeSta
#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 c5fa2b3857..653959656f 100644
--- a/Include/cpython/initconfig.h
+++ b/Include/cpython/initconfig.h
@@ -147,6 +147,10 @@ typedef struct {
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 0000000000..bf5b29634a
--- /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 */