File tree Expand file tree Collapse file tree 5 files changed +5758
-5716
lines changed
Lib/test/test_peg_generator
Tools/peg_generator/pegen Expand file tree Collapse file tree 5 files changed +5758
-5716
lines changed Original file line number Diff line number Diff line change @@ -540,6 +540,33 @@ def test_missing_start(self) -> None:
540
540
with self .assertRaises (GrammarError ):
541
541
parser_class = make_parser (grammar )
542
542
543
+ def test_invalid_rule_name (self ) -> None :
544
+ grammar = """
545
+ start: a b
546
+ _a: 'a'
547
+ b: 'b'
548
+ """
549
+ with self .assertRaises (GrammarError ):
550
+ parser_class = make_parser (grammar )
551
+
552
+ def test_invalid_variable_name (self ) -> None :
553
+ grammar = """
554
+ start: a b
555
+ a: _x='a'
556
+ b: 'b'
557
+ """
558
+ with self .assertRaises (GrammarError ):
559
+ parser_class = make_parser (grammar )
560
+
561
+ def test_invalid_variable_name_in_temporal_rule (self ) -> None :
562
+ grammar = """
563
+ start: a b
564
+ a: (_x='a' | 'b') | 'c'
565
+ b: 'b'
566
+ """
567
+ with self .assertRaises (GrammarError ):
568
+ parser_class = make_parser (grammar )
569
+
543
570
544
571
class TestGrammarVisitor :
545
572
class Visitor (GrammarVisitor ):
You can’t perform that action at this time.
0 commit comments