Example #1
0
 def test_out_of_order_alternation_with_anchor_after(self):
     r = Regex.get_parse_tree(r"(a|ab)\b")
     print("\n".join(fmttree(r)))
     errs = []
     check_prefix_ordering(r, errs)
     print(errs)
     self.assertEqual(len(errs), 0)
Example #2
0
 def test_out_of_order_crazy_complicated(self):
     r = Regex.get_parse_tree(r"""(!=|#|&&|&|\(|\)|\*|\+|,|-|-\.)""")
     # |->|\.|\.\.|::|:=|:>|:|;;|;|<|<-|=|>|>]|>}|\?|\?\?|\[|\[<|\[>|\[\||]|_|`|{|{<|\||\|]|}|~)''')
     print("\n".join(fmttree(r)))
     errs = []
     check_prefix_ordering(r, errs)
     self.assertEqual(len(errs), 1)
Example #3
0
 def test_out_of_order_alternation_location(self):
     r = Regex.get_parse_tree(r"(foo|bar|@|@@)")
     print("\n".join(fmttree(r)))
     errs = []
     check_prefix_ordering(r, errs)
     self.assertEqual(len(errs), 1)
     # location of the second one.
     self.assertEqual(errs[0][2], 11)
Example #4
0
 def test_out_of_order_alternation_longer(self):
     r = Regex.get_parse_tree(r"(a|ab|c)")
     print("\n".join(fmttree(r)))
     errs = []
     check_prefix_ordering(r, errs)
     self.assertEqual(len(errs), 1)