summaryrefslogtreecommitdiff
path: root/Parser/pegen/pegen.h
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2020-04-30 20:59:30 -0700
committerGuido van Rossum <guido@python.org>2020-04-30 20:59:30 -0700
commit0be7a2bb0c0c4f7a1317338726176eb267a1c709 (patch)
treea379628b6ff449cddc9d4953ecb869d7fa434639 /Parser/pegen/pegen.h
parentc73ab8934487d0dc88ce4a8ed230bae100ff3776 (diff)
parent3e0a6f37dfdd595be737baae00ec0e036a912615 (diff)
downloadcpython-git-refactor-lambda-parameters.tar.gz
Merge remote-tracking branch 'origin/master' into refactor-lambda-parametersrefactor-lambda-parameters
Diffstat (limited to 'Parser/pegen/pegen.h')
-rw-r--r--Parser/pegen/pegen.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/Parser/pegen/pegen.h b/Parser/pegen/pegen.h
index 3af4bb29aa..1620f92609 100644
--- a/Parser/pegen/pegen.h
+++ b/Parser/pegen/pegen.h
@@ -69,6 +69,7 @@ typedef struct {
int starting_col_offset;
int error_indicator;
int flags;
+ int feature_version;
growable_comment_array type_ignore_comments;
} Parser;
@@ -180,9 +181,26 @@ NEW_TYPE_COMMENT(Parser *p, Token *tc)
return NULL;
}
+Py_LOCAL_INLINE(void *)
+INVALID_VERSION_CHECK(Parser *p, int version, char *msg, void *node)
+{
+ if (node == NULL) {
+ p->error_indicator = 1; // Inline CHECK_CALL
+ return NULL;
+ }
+ if (p->feature_version < version) {
+ p->error_indicator = 1;
+ return _PyPegen_raise_error(p, PyExc_SyntaxError, "%s only supported in Python 3.%i and greater",
+ msg, version);
+ }
+ return node;
+}
+
+#define CHECK_VERSION(version, msg, node) INVALID_VERSION_CHECK(p, version, msg, node)
+
arg_ty _PyPegen_add_type_comment_to_arg(Parser *, arg_ty, Token *);
PyObject *_PyPegen_new_identifier(Parser *, char *);
-Parser *_PyPegen_Parser_New(struct tok_state *, int, int, int *, PyArena *);
+Parser *_PyPegen_Parser_New(struct tok_state *, int, int, int, int *, PyArena *);
void _PyPegen_Parser_Free(Parser *);
mod_ty _PyPegen_run_parser_from_file_pointer(FILE *, int, PyObject *, const char *,
const char *, const char *, PyCompilerFlags *, int *, PyArena *);