Exemplo n.º 1
0
 def test_invert_bug_4(self):
     #basicConfig(level=DEBUG)
     bad = BLine(Token('[^a]*'))
     bad.config.line_aware(block_policy=2).left_memoize()
     parser = bad.get_parse_string()
     result = parser('123')
     assert result == ['123'], result
Exemplo n.º 2
0
 def test_line(self):
     #basicConfig(level=DEBUG)
     text = Token('[^\n\r]+')
     quoted = Regexp("'[^']'")
     line = BLine(text(quoted))
     line.config.default_line_aware(block_start=0)
     parser = line.get_parse_string()
     assert parser("'a'") == ["'a'"]
Exemplo n.º 3
0
 def test_invert_bug_6(self):
     #basicConfig(level=DEBUG)
     bad = BLine(Token(str('[^(*SOL)(*EOL)a]*')))
     bad.config.default_line_aware(block_policy=2,
                                   parser_factory=make_str_parser)
     bad.config.trace(True)
     parser = bad.get_parse_string()
     result = parser(str('123'))
     assert result == [str('123')], result
Exemplo n.º 4
0
 def test_offset(self):
     #basicConfig(level=DEBUG)
     text = Token('[^\n\r]+')
     line = BLine(text(~Literal('aa') & Regexp('.*')))
     line.config.default_line_aware(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') == ['']
Exemplo n.º 5
0
 def test_bad_config(self):
     #basicConfig(level=DEBUG)
     text = Token('[^\n\r]+')
     quoted = Regexp("'[^']'")
     line = BLine(text(quoted))
     line.config.default_line_aware()
     parser = line.get_parse_string()
     try:
         parser("'a'")
         assert False, 'Expected error'
     except OffsideError as error:
         assert str(error).startswith('No initial indentation has been set.')