Apply this parser to the next segment.
Apply this parser to the next segment.
the segment to parse for the next message
a parse result
The name of this parser (used for debugging)
The name of this parser (used for debugging)
name of this parser
Request result because there is no more data
Returns a parser that repeatedly parses what this parser parses
Returns a parser that repeatedly parses what this parser parses
rep(this)
Returns a parser that repeatedly (at least once) parses what this parser parses.
Returns a parser that repeatedly (at least once) parses what this parser parses.
rep1(this)
A parser combinator for sequential composition which keeps only the left result
A parser combinator for sequential composition which keeps only the left result
p <~ q' succeeds if
p' succeeds and q' succeeds on the input
left over by
p'.
Note: <~ has lower operator precedence than ~ or ~>.
a Parser' that -- on success -- returns the result of
p'.
Returns a parser that optionally parses what this parser parses.
Returns a parser that optionally parses what this parser parses.
opt(this)
A parser combinator for function application
A parser combinator for function application
p ^^ f' succeeds if
p' succeeds; it returns
f' applied to the result of p'.
a function that will be applied to this parser's result (see map' in
ParseResult').
a parser that has the same behaviour as the current parser, but whose result is
transformed by f'.
A parser combinator for substituting a result with another
A parser combinator for substituting a result with another
p ^^^ r' succeeds if
p' succeeds; it returns
r'
the substitution result
a parser that has the same behaviour as the current parser, but whose result is
replaced by r'.
transforms this
of type Parser[A,B]
into a parser of type Parser[Z,B]
.
transforms this
of type Parser[A,B]
into a parser of type Parser[Z,B]
.
function that maps a message of type Z into a message of type A.
Given an input stream ichan: IChan[Z]
and a parser: Parser[A,B]
,
the stream transformation ichan.parse(parser.contraMap(g,h))
is equivalent to ichan.map(g).parse(parser)
.
The reason for contraMap is to be able to apply g until a first parsed result on a input:Input[Z]
;
input.read(parser.contraMap(g,h))
will leave, after reading the first parsed result,
the stream untouched and of type Z, so one map want to apply another parser of type Parser[Z,C] afterwards.
function to generate a partially consumed message type Z in case the inverse function of g does not exists.
A parser may partially consume a message of an input stream.
So if this
leaves a partially consumed message of type A on the stream,
an equally consumed message of type Z will generated with function consume
.
In the function consume(z:A,a:A):Z
, z
is the message to be partially consumed,
a
is the partially consume value of g(z); the return value must be the partially consume z such that
g( consume(z,a) ) == a
and when
g(z) == a
than consume(z,a) == z
If consume is not correctly specified, the contraMapped parser may give unexpected results in case of partially consumed messages.
a contraMapped parser
transforms this
of type Parser[A,B]
into a parser of type Parser[Z,B]
.
transforms this
of type Parser[A,B]
into a parser of type Parser[Z,B]
.
function that maps a message of type Z into a message of type A.
Given an input stream ichan: IChan[Z]
and a parser: Parser[A,B]
,
the stream transformation ichan.parse(parser.contraMap(g,h))
is equivalent to ichan.map(g).parse(parser)
.
The reason for contraMap is to be able to apply g until a first parsed result on a input:Input[Z]
;
input.read(parser.contraMap(g,h))
will leave, after reading the first parsed result,
the stream untouched and of type Z, so one map want to apply another parser of type Parser[Z,C] afterwards.
inverse function of g.
A parser may partially consume a message of an input stream.
So if this
leaves a partially consumed message of type A on the stream,
that message will be reverse mapped to Z with function h.
If h(g(a)) is not equal to a, the contraMapped parser may give unexpected results in case of partially consumed messages.
In case the function h is not defined, one must use contraMap[Z](g: Z => A, consume:(Z,A) => Z): Parser[Z, B]
.
a contraMapped parser
Filter results of this parser.
Filter results of this parser.
predicate that returns true for results accepted by this parser
a filtered parser
Sequence with a second parsers only after this one produced a result.
Sequence with a second parsers only after this one produced a result.
the resulting parser
Map the result of this parser to another result C
Apply this parser to the last segment.
Apply this parser to the last segment.
the segment to parse for a new message
the signal accompanying the last segment
Nothing if there is no new message left. Some Fail or Done depending on if the last parse failed or succeeded.
A parser combinator for alternative composition
A parser combinator for alternative composition
p | q' succeeds if
p' succeeds or q' succeeds
Note that
q' is only tried if p's failure is non-fatal (i.e., back-tracking is
allowed).
a Parser' that returns the result of the first parser to succeed (out of
p' and q')
The resulting parser succeeds if (and only if)
p' succeeds, or
p' fails allowing back-tracking and
q' succeeds.
A parser combinator for sequential composition
A parser combinator for sequential composition
p ~ q' succeeds if
p' succeeds and q' succeeds on the input
left over by
p'.
a Parser' that -- on success -- returns a
~' (like a Pair, but easier to pattern match on)
that contains the result of p' and that of
q'.
The resulting parser fails if either p' or
q' fails.
A parser combinator for sequential composition which keeps only the right result
A parser combinator for sequential composition which keeps only the right result
p ~> q' succeeds if
p' succeeds and q' succeeds on the input
left over by
p'.
a Parser' that -- on success -- returns the result of
q'.
Incremental parser
the type of the input messages accepted by a parser B the type of the result