def inner(loc: LocatedText) -> State: res = re.match(rex, loc.remaining()) if res is None: return State(ParseError("不满足正则条件"), loc) else: e = res.end() loc.advance(e) return State(Success(Result(res.group())), loc)
def inner(loc: LocatedText) -> State: if loc.isEOF(): return State(ParseError("再无输入可解析"), loc) else: c = loc.remaining()[0] if pred(c): loc.advance() return State(Success(Result(c)), loc) else: return State(ParseError("不满足条件"), loc)
def or_not(self): return maybe(self) | _trick_just(Result())
def skip_many1(parser: Parser) -> Parser: return many1(parser) >> _trick_just(Result())
def skip(parser: Parser) -> Parser: return parser >> _trick_just(Result())
def inner(loc: LocatedText) -> State: return State(Success(Result(v)), loc)
def inner(loc: LocatedText) -> State: if loc.isEOF(): return State(Success(Result()), loc) else: return State(ParseError("Excepted: <EOF>"), loc)