def test_fails_to_parse_non_ll1(self): e = self.assertSimpleParseFailure( combinators.option( combinators.sequence(primitives.match(lambda c: c == "h"), primitives.match(lambda c: c == "e"))), "hzllo") self.assertEqual("z", e.value) self.assertEqual(list("llo"), list(e.it)) self.assertEqual(set(), e.expected)
def test_parses_none(self): self.assertParse(combinators.option(primitives.error(set())), None, "hello", "hello")
def test_parses(self): self.assertParse(combinators.option(primitives.any_), "h", "ello", "hello")