summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_peg_generator
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-05-26 23:15:52 (GMT)
committerGitHub <noreply@github.com>2020-05-26 23:15:52 (GMT)
commit404b23b85b17c84e022779f31fc89cb0ed0d37e8 (patch)
treefea9aca0072a7f5f06a5af49b36b434185d7e76c /Lib/test/test_peg_generator
parent21fda91f8da96406e6a912f7c312424209c19bef (diff)
downloadcpython-404b23b85b17c84e022779f31fc89cb0ed0d37e8.zip
cpython-404b23b85b17c84e022779f31fc89cb0ed0d37e8.tar.gz
cpython-404b23b85b17c84e022779f31fc89cb0ed0d37e8.tar.bz2
Fix lookahead of soft keywords in the PEG parser (GH-20436)
Automerge-Triggered-By: @gvanrossum
Diffstat (limited to 'Lib/test/test_peg_generator')
-rw-r--r--Lib/test/test_peg_generator/test_c_parser.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_peg_generator/test_c_parser.py b/Lib/test/test_peg_generator/test_c_parser.py
index 72383d5..a5d8850 100644
--- a/Lib/test/test_peg_generator/test_c_parser.py
+++ b/Lib/test/test_peg_generator/test_c_parser.py
@@ -432,3 +432,15 @@ class TestCParser(TempdirManager, unittest.TestCase):
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)