Пример #1
0
 def test_line(self):
     #basicConfig(level=DEBUG)
     text = Token('[^\n\r]+')
     quoted = Regexp("'[^']'")
     line = Line(text(quoted))
     line.config.lines(block_start=0)
     parser = line.get_parse_string()
     assert parser("'a'") == ["'a'"]
Пример #2
0
 def test_offset(self):
     #basicConfig(level=DEBUG)
     text = Token('[^\n\r]+')
     line = Line(text(~Literal('aa') & Regexp('.*')))
     line.config.lines(block_start=0)
     parser = line.get_parse_string()
     assert parser('aabc') == ['bc']
     # what happens with an empty match?
     check = ~Literal('aa') & Regexp('.*')
     check.config.no_full_first_match()
     assert check.parse('aa') == ['']
     assert parser('aa') == ['']