return self._run(tokens, s)
def _run(self, tokens, s):
return self._run(tokens, s)
def _run(self, tokens, s):
def __add__(self, other):
"""Parser(a, b), Parser(a, c) -> Parser(a, _Tuple(b, c))
def __add__(self, other):
"""Parser(a, b), Parser(a, c) -> Parser(a, _Tuple(b, c))
# or in terms of bind and pure:
# _add = self.bind(lambda x: other.bind(lambda y: pure(magic(x, y))))
# or in terms of bind and pure:
# _add = self.bind(lambda x: other.bind(lambda y: pure(magic(x, y))))
except NoParseError as e:
return other.run(tokens, State(s.pos, e.state.max))
except NoParseError as e:
return other.run(tokens, State(s.pos, e.state.max))
(v, s2) = self.run(tokens, s)
return f(v).run(tokens, s2)
(v, s2) = self.run(tokens, s)
return f(v).run(tokens, s2)
except NoParseError as e:
return res, State(s.pos, e.state.max)
except NoParseError as e:
return res, State(s.pos, e.state.max)
- log.debug(u'failed "%s", state = %s' % (t, s))
- raise NoParseError(u'got unexpected token', s)
+ log.debug('failed "%s", state = %s' % (t, s))
+ raise NoParseError('got unexpected token', s)
Returns a parser that parses a token that is equal to the value value.
"""
name = getattr(value, 'name', value)
Returns a parser that parses a token that is equal to the value value.
"""
name = getattr(value, 'name', value)
Returns a parser that applies the parser p one or more times.
"""
q = p + many(p) >> (lambda x: [x[0]] + x[1])
Returns a parser that applies the parser p one or more times.
"""
q = p + many(p) >> (lambda x: [x[0]] + x[1])