summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2023-10-02 15:22:07 (GMT)
committerGitHub <noreply@github.com>2023-10-02 15:22:07 (GMT)
commitf6cb2e48152fc7b44d55583ad8b80b653085bae2 (patch)
tree69b634818ebd0a76d8ccde5c6a9db3b02eb09625 /Lib/test
parentc7cbd82e62d22b6b1c6d4e95dbbd1db16c321533 (diff)
downloadcpython-f6cb2e48152fc7b44d55583ad8b80b653085bae2.zip
cpython-f6cb2e48152fc7b44d55583ad8b80b653085bae2.tar.gz
cpython-f6cb2e48152fc7b44d55583ad8b80b653085bae2.tar.bz2
[3.12] gh-109596: Ensure repeated rules in the grammar are not allowed and fix incorrect soft keywords (GH-109606). (#109752)
(cherry picked from commit b28ffaa193efc66f46ab90d383279174a11a11d7)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_peg_generator/test_pegen.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_peg_generator/test_pegen.py b/Lib/test/test_peg_generator/test_pegen.py
index d92da7b..ec61199 100644
--- a/Lib/test/test_peg_generator/test_pegen.py
+++ b/Lib/test/test_peg_generator/test_pegen.py
@@ -42,6 +42,15 @@ class TestPegen(unittest.TestCase):
)
self.assertEqual(repr(rules["term"]), expected_repr)
+ def test_repeated_rules(self) -> None:
+ grammar_source = """
+ start: the_rule NEWLINE
+ the_rule: 'b' NEWLINE
+ the_rule: 'a' NEWLINE
+ """
+ with self.assertRaisesRegex(GrammarError, "Repeated rule 'the_rule'"):
+ parse_string(grammar_source, GrammarParser)
+
def test_long_rule_str(self) -> None:
grammar_source = """
start: zero | one | one zero | one one | one zero zero | one zero one | one one zero | one one one