Exemple #1
0
 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)
Exemple #2
0
 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)
Exemple #3
0
 def or_not(self):
     return maybe(self) | _trick_just(Result())
Exemple #4
0
def skip_many1(parser: Parser) -> Parser:
    return many1(parser) >> _trick_just(Result())
Exemple #5
0
def skip(parser: Parser) -> Parser:
    return parser >> _trick_just(Result())
Exemple #6
0
 def inner(loc: LocatedText) -> State:
     return State(Success(Result(v)), loc)
Exemple #7
0
 def inner(loc: LocatedText) -> State:
     if loc.isEOF():
         return State(Success(Result()), loc)
     else:
         return State(ParseError("Excepted: <EOF>"), loc)