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>
This commit is contained in:
Lysandros Nikolaou 2020-10-31 20:31:41 +02:00 committed by GitHub
parent d21cb2d5ee
commit 02cdfc93f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 0 deletions

View file

@ -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;")