diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2020-10-31 19:06:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-31 19:06:03 (GMT) |
commit | cfcb952e30e01d7cce430829af8edc7afc94e0b1 (patch) | |
tree | 8a171bdafe7537ffc636aee5ee76afe9e5562a9b /Tools | |
parent | dbaa07db671c4e5842629c8be912f2b0370be794 (diff) | |
download | cpython-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 'Tools')
-rw-r--r-- | Tools/peg_generator/pegen/c_generator.py | 3 |
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 d0abc12..b4d6a0b 100644 --- a/Tools/peg_generator/pegen/c_generator.py +++ b/Tools/peg_generator/pegen/c_generator.py @@ -496,6 +496,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;") |