Ejemplo n.º 1
0
 def test_bygroups_check_overlap_descending2(self):
     r = Regex.get_parse_tree(r"(?:^|xx)(foo)")
     print("\n".join(fmttree(r)))
     errs = []
     bygroups_check_overlap(r, errs, (Text, ))
     print(errs)
     self.assertEqual(len(errs), 1)
Ejemplo n.º 2
0
 def test_bygroups_check_overlap_but_none_for_token(self):
     r = Regex.get_parse_tree(r"(<(%)?)(\w+)((?(2)%)>)")
     print("\n".join(fmttree(r)))
     errs = []
     bygroups_check_overlap(r, errs, (Punctuation, None, Name, Punctuation))
     print(errs)
     self.assertEqual(len(errs), 0)
Ejemplo n.º 3
0
 def test_bygroups_check_overlap_lookaround_ok(self):
     r = Regex.get_parse_tree(r"(?<!\.)(Class|Structure|Enum)(\s+)")
     print("\n".join(fmttree(r)))
     errs = []
     bygroups_check_overlap(r, errs, (Text, Text))
     print(errs)
     self.assertEqual(len(errs), 0)
Ejemplo n.º 4
0
 def test_bygroups_check_overlap_fail2(self):
     r = Regex.get_parse_tree(r"\b(a)$")
     print("\n".join(fmttree(r)))
     errs = []
     bygroups_check_overlap(r, errs, (Text, ))
     print(errs)
     self.assertEqual(len(errs), 0)
Ejemplo n.º 5
0
 def test_bygroups_check_overlap_descending_with_capture_and_gap(self):
     r = Regex.get_parse_tree(
         r"(?:([A-Za-z_][A-Za-z0-9_]*)x(\.))?([A-Za-z_][A-Za-z0-9_]*)")
     print("\n".join(fmttree(r)))
     errs = []
     bygroups_check_overlap(r, errs, (Text, Text, Text))
     print(errs)
     self.assertEqual(len(errs), 1)
Ejemplo n.º 6
0
 def test_bygroups_check_overlap_nested_length2(self):
     r = Regex.get_parse_tree(r"\b(a)((b)c)$")
     print("\n".join(fmttree(r)))
     errs = []
     bygroups_check_overlap(r, errs, (Text, Text, Text))
     print(errs)
     self.assertEqual(len(errs), 1)
     self.assertEqual(errs[0][1], logging.ERROR)
Ejemplo n.º 7
0
 def test_bygroups_check_overlap_success(self):
     r = Regex.get_parse_tree(r"(a)?(b)")
     print("\n".join(fmttree(r)))
     errs = []
     bygroups_check_overlap(r, errs, (Text, Text))
     self.assertEqual(len(errs), 0)