summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2020-10-31 19:06:03 (GMT)
committerGitHub <noreply@github.com>2020-10-31 19:06:03 (GMT)
commitcfcb952e30e01d7cce430829af8edc7afc94e0b1 (patch)
tree8a171bdafe7537ffc636aee5ee76afe9e5562a9b /Parser
parentdbaa07db671c4e5842629c8be912f2b0370be794 (diff)
downloadcpython-cfcb952e30e01d7cce430829af8edc7afc94e0b1.zip
cpython-cfcb952e30e01d7cce430829af8edc7afc94e0b1.tar.gz
cpython-cfcb952e30e01d7cce430829af8edc7afc94e0b1.tar.bz2
[3.9] bpo-42218: Correctly handle errors in left-recursive rules (GH-23065) (GH-23066)
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> (cherry picked from commit 02cdfc93f82fecdb7eae97a868d4ee222b9875d9) Automerge-Triggered-By: GH:lysnikolaou
Diffstat (limited to 'Parser')
-rw-r--r--Parser/pegen/parse.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/Parser/pegen/parse.c b/Parser/pegen/parse.c
index bae9463..97cefa9 100644
--- a/Parser/pegen/parse.c
+++ b/Parser/pegen/parse.c
@@ -3460,6 +3460,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;
@@ -9044,6 +9046,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;
@@ -9158,6 +9162,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;
@@ -9272,6 +9278,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;
@@ -9386,6 +9394,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;
@@ -9539,6 +9549,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;
@@ -9698,6 +9710,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;
@@ -10302,6 +10316,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;
@@ -13962,6 +13978,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;