summaryrefslogtreecommitdiffstats
path: root/Parser/pegen.h
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-05-21 18:20:43 (GMT)
committerGitHub <noreply@github.com>2021-05-21 18:20:43 (GMT)
commitae1732d4611ee859c754e7a867b2a4cbb47d0637 (patch)
treefe148ae91412c7f8a0f88b9cada6d2ee86f936d7 /Parser/pegen.h
parent150bc1f4aa67226fb05fb29032375c203252a538 (diff)
downloadcpython-ae1732d4611ee859c754e7a867b2a4cbb47d0637.zip
cpython-ae1732d4611ee859c754e7a867b2a4cbb47d0637.tar.gz
cpython-ae1732d4611ee859c754e7a867b2a4cbb47d0637.tar.bz2
bpo-44180: Fix edge cases in invalid assigment rules in the parser (GH-26283)
The invalid assignment rules are very delicate since the parser can easily raise an invalid assignment when a keyword argument is provided. As they are very deep into the grammar tree, is very difficult to specify in which contexts these rules can be used and in which don't. For that, we need to use a different version of the rule that doesn't do error checking in those situations where we don't want the rule to raise (keyword arguments and generator expressions). We also need to check if we are in left-recursive rule, as those can try to eagerly advance the parser even if the parse will fail at the end of the expression. Failing to do this allows the parser to start parsing a call as a tuple and incorrectly identify a keyword argument as an invalid assignment, before it realizes that it was not a tuple after all. (cherry picked from commit c878a9796841c1f4726e6dd5ac49a478af4c8504) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Parser/pegen.h')
-rw-r--r--Parser/pegen.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/Parser/pegen.h b/Parser/pegen.h
index d591c56..1540da0 100644
--- a/Parser/pegen.h
+++ b/Parser/pegen.h
@@ -74,6 +74,7 @@ typedef struct {
Token *known_err_token;
int level;
int call_invalid_rules;
+ int in_raw_rule;
} Parser;
typedef struct {