Fix lookahead of soft keywords in the PEG parser (GH-20436)

Automerge-Triggered-By: @gvanrossum
This commit is contained in:
Pablo Galindo 2020-05-27 00:15:52 +01:00 committed by GitHub
parent 21fda91f8d
commit 404b23b85b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 2 deletions

View file

@ -432,3 +432,15 @@ def test_soft_keywords_parse(self) -> None:
self.check_input_strings_for_grammar(valid_cases, invalid_cases)
"""
self.run_test(grammar_source, test_source)
def test_soft_keywords_lookahead(self) -> None:
grammar_source = """
start: &"if" "if" expr '+' expr NEWLINE
expr: NAME
"""
test_source = """
valid_cases = ["if if + if"]
invalid_cases = ["if if"]
self.check_input_strings_for_grammar(valid_cases, invalid_cases)
"""
self.run_test(grammar_source, test_source)