summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2020-10-31 18:31:41 (GMT)
committerGitHub <noreply@github.com>2020-10-31 18:31:41 (GMT)
commit02cdfc93f82fecdb7eae97a868d4ee222b9875d9 (patch)
tree85ec4c7f233e9bff63b0e6af21049ec00d7e0af9 /Parser
parentd21cb2d5ee56b8975d92e2ee094aba81f0801be5 (diff)
downloadcpython-02cdfc93f82fecdb7eae97a868d4ee222b9875d9.zip
cpython-02cdfc93f82fecdb7eae97a868d4ee222b9875d9.tar.gz
cpython-02cdfc93f82fecdb7eae97a868d4ee222b9875d9.tar.bz2
bpo-42218: Correctly handle errors in left-recursive rules (GH-23065)
Left-recursive rules need to check for errors explicitly, since even if the rule returns NULL, the parsing might continue and lead to long-distance failures. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Parser')
-rw-r--r--Parser/parser.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/Parser/parser.c b/Parser/parser.c
index a882a81..48ebfe6 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -3461,6 +3461,8 @@ dotted_name_rule(Parser *p)
}
p->mark = _mark;
void *_raw = dotted_name_raw(p);
+ if (p->error_indicator)
+ return NULL;
if (_raw == NULL || p->mark <= _resmark)
break;
_resmark = p->mark;
@@ -9045,6 +9047,8 @@ bitwise_or_rule(Parser *p)
}
p->mark = _mark;
void *_raw = bitwise_or_raw(p);
+ if (p->error_indicator)
+ return NULL;
if (_raw == NULL || p->mark <= _resmark)
break;
_resmark = p->mark;
@@ -9159,6 +9163,8 @@ bitwise_xor_rule(Parser *p)
}
p->mark = _mark;
void *_raw = bitwise_xor_raw(p);
+ if (p->error_indicator)
+ return NULL;
if (_raw == NULL || p->mark <= _resmark)
break;
_resmark = p->mark;
@@ -9273,6 +9279,8 @@ bitwise_and_rule(Parser *p)
}
p->mark = _mark;
void *_raw = bitwise_and_raw(p);
+ if (p->error_indicator)
+ return NULL;
if (_raw == NULL || p->mark <= _resmark)
break;
_resmark = p->mark;
@@ -9387,6 +9395,8 @@ shift_expr_rule(Parser *p)
}
p->mark = _mark;
void *_raw = shift_expr_raw(p);
+ if (p->error_indicator)
+ return NULL;
if (_raw == NULL || p->mark <= _resmark)
break;
_resmark = p->mark;
@@ -9540,6 +9550,8 @@ sum_rule(Parser *p)
}
p->mark = _mark;
void *_raw = sum_raw(p);
+ if (p->error_indicator)
+ return NULL;
if (_raw == NULL || p->mark <= _resmark)
break;
_resmark = p->mark;
@@ -9699,6 +9711,8 @@ term_rule(Parser *p)
}
p->mark = _mark;
void *_raw = term_raw(p);
+ if (p->error_indicator)
+ return NULL;
if (_raw == NULL || p->mark <= _resmark)
break;
_resmark = p->mark;
@@ -10303,6 +10317,8 @@ primary_rule(Parser *p)
}
p->mark = _mark;
void *_raw = primary_raw(p);
+ if (p->error_indicator)
+ return NULL;
if (_raw == NULL || p->mark <= _resmark)
break;
_resmark = p->mark;
@@ -13943,6 +13959,8 @@ t_primary_rule(Parser *p)
}
p->mark = _mark;
void *_raw = t_primary_raw(p);
+ if (p->error_indicator)
+ return NULL;
if (_raw == NULL || p->mark <= _resmark)
break;
_resmark = p->mark;