Пример #1
0
 def test_clock_counter(self):
     ragel_parser.global_clock_counter = 0
     ragel_parser.parser("<0>")
     self.assertEqual(ragel_parser.global_clock_counter, 1)
     ragel_parser.global_clock_counter = 0
     ragel_parser.parser("<0>.<1>")
     self.assertEqual(ragel_parser.global_clock_counter, 2)
     ragel_parser.global_clock_counter = 0
     ragel_parser.parser("<0>.<1>.<2>")
     self.assertEqual(ragel_parser.global_clock_counter, 3)
Пример #2
0
 def test_union(self):
     ragel_parser.global_clock_counter = 0
     self.assertEqual("(0.((1.2) @CT0 >~ST0 | (3) @CT1 >~ST1) @U $~STEP $lerr(R);", ragel_parser.parser("0.(<1.2> | <3>"))
Пример #3
0
 def test_nested_tre(self):
     ragel_parser.global_clock_counter = 0
     self.assertEqual("((0.(1.2) @CT1 >~ST1) @CT0 >~ST0) @U $~STEP $lerr(R);", ragel_parser.parser("<0.<1.2>>"))
Пример #4
0
 def test_tre_concatenation(self):
     ragel_parser.global_clock_counter = 0
     self.assertEqual("((0) @CT0 >~ST0.(1) @CT1 >~ST1.(2) @CT2 >~ST2) @U $~STEP $lerr(R);", ragel_parser.parser("<0>.<1>.<2>"))
Пример #5
0
 def test_one_regular_tre(self):
     ragel_parser.global_clock_counter = 0
     self.assertEqual("((0.1) @CT0 >~ST0) @U $~STEP $lerr(R);", ragel_parser.parser("<0.1>"))
Пример #6
0
 def test_non_tre_concat_with_tre(self):
     ragel_parser.global_clock_counter = 0
     self.assertEqual("(1.(0+)) @U $~STEP $lerr(R);", ragel_parser.parser("1.(0+)"))
Пример #7
0
 def test_one_element_plus_outside(self):
     ragel_parser.global_clock_counter = 0
     self.assertEqual("(((0) @CT0 >~ST0)+) @U $~STEP $lerr(R);", ragel_parser.parser("(<0>)+"))