Exemplo n.º 1
0
 def testCommonSequenceAfterRepetition(self):
     a = builder.makeSequence([
         Repetition(Null, Sequence([NonTerminal("b"),
                                    Terminal("a")])),
         NonTerminal("b"),
         Terminal("a")
     ])
     b = Repetition(Sequence([NonTerminal("b"), Terminal("a")]), Null)
     self.assertEqual(a, b)
Exemplo n.º 2
0
 def testNullInSequence(self):
     a = builder.makeSequence(
         [NonTerminal("foo"), Null,
          Terminal("bar"), Null,
          Terminal("baz")])
     b = Sequence([NonTerminal("foo"), Terminal("bar"), Terminal("baz")])
     self.assertEqual(a, b)
Exemplo n.º 3
0
 def testSequence(self):
     self.rules = [
         Rule(
             "sequence",
             Sequence([
                 NonTerminal("with"),
                 NonTerminal("one"),
                 NonTerminal("branch")
             ]))
     ]
Exemplo n.º 4
0
 def testNull(self):
     self.rules = [
         Rule(
             "sequence with null",
             Sequence([
                 Terminal("space here ->"), Null,
                 Terminal("should be like here ->"),
                 Terminal("foo")
             ]))
     ]
Exemplo n.º 5
0
 def testNoCommonNullAfterRepetition(self):
     a = builder.makeSequence(
         [Repetition(NonTerminal("b"), Null),
          Terminal("d")])
     b = Sequence([Repetition(NonTerminal("b"), Null), Terminal("d")])
     self.assertEqual(a, b)