summaryrefslogtreecommitdiffstats
path: root/Tools
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 /Tools
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 'Tools')
-rw-r--r--Tools/peg_generator/pegen/c_generator.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py
index 52bdb84..6af0d3f 100644
--- a/Tools/peg_generator/pegen/c_generator.py
+++ b/Tools/peg_generator/pegen/c_generator.py
@@ -502,6 +502,9 @@ class CParserGenerator(ParserGenerator, GrammarVisitor):
)
self.print("p->mark = _mark;")
self.print(f"void *_raw = {node.name}_raw(p);")
+ self.print("if (p->error_indicator)")
+ with self.indent():
+ self.print("return NULL;")
self.print("if (_raw == NULL || p->mark <= _resmark)")
with self.indent():
self.print("break;")