コード例 #1
0
 def testRuleNamesWithAscentAndDescent(self):
     self.rules = [
         Rule("aaaaa", NonTerminal("ascent and descent")),
         Rule("ppppp", NonTerminal("should")),
         Rule("ddddd", NonTerminal("look")),
         Rule("dddpp", NonTerminal("right"))
     ]
コード例 #2
0
 def testRestrictionWithLongerException(self):
     self.rules = [
         Rule(
             "restriction",
             Restriction(Terminal("base"),
                         Terminal("long exception branch")))
     ]
コード例 #3
0
 def testRestrictionWithShorterException(self):
     self.rules = [
         Rule(
             "restriction",
             Restriction(Terminal("long base branch"),
                         Terminal("exception")))
     ]
コード例 #4
0
 def testRepetitionWithLongBackwardBranch(self):
     self.rules = [
         Rule(
             "repetition",
             Repetition(Terminal("forward"),
                        Terminal("backward branch is longer")))
     ]
コード例 #5
0
 def testSequence(self):
     self.rules = [
         Rule(
             "sequence",
             Sequence([
                 NonTerminal("with"),
                 NonTerminal("one"),
                 NonTerminal("branch")
             ]))
     ]
コード例 #6
0
 def testAlternative(self):
     self.rules = [
         Rule(
             "alternative",
             Alternative([
                 NonTerminal("with"),
                 NonTerminal("several"),
                 NonTerminal("branches")
             ]))
     ]
コード例 #7
0
 def testNull(self):
     self.rules = [
         Rule(
             "sequence with null",
             Sequence([
                 Terminal("space here ->"), Null,
                 Terminal("should be like here ->"),
                 Terminal("foo")
             ]))
     ]
コード例 #8
0
 def testImbricatedRepetitions(self):
     self.rules = [
         Rule(
             "repetition",
             Repetition(
                 Repetition(NonTerminal("forward 1"),
                            NonTerminal("backward 1")),
                 Repetition(NonTerminal("forward 2"),
                            NonTerminal("backward 2"))))
     ]
コード例 #9
0
 def testBackwardAlternative(self):
     self.rules = [
         Rule(
             "repetition",
             Repetition(
                 NonTerminal("forward"),
                 Alternative([
                     NonTerminal("foo"),
                     NonTerminal("bar"),
                     NonTerminal("baz")
                 ])))
     ]
コード例 #10
0
 def testAlternativeWithOneBranch(self):
     self.rules = [
         Rule("alternative", Alternative([NonTerminal("with one branch")]))
     ]
コード例 #11
0
 def testLongRuleName(self):
     self.rules = [
         Rule("this long rule name should not be truncated",
              NonTerminal("foo")),
     ]
コード例 #12
0
 def testTerminal(self):
     self.rules = [Rule("terminal", Terminal("in a rounded rectangle"))]
コード例 #13
0
 def testNonTerminal(self):
     self.rules = [Rule("non terminal", NonTerminal("in a rectangle"))]