Library
Module
Module type
Parameter
Class
Class type
val fail : string -> 'a t
fail msg
creates a combinator that will always fail with the message msg
.
val commit : unit t
commit
prevents backtracking beyong the current position of the input, allowing the manager of the input buffer to reuse the preceding bytes for other purposes when the combinator is used as a parser.
As a serializer, commit
forces to flush the internal buffer to the manager of the output buffer (if the current state is not into an alteration - see choice
).
val pure : compare:('a -> 'a -> bool) -> 'a -> 'a t
peek p q
accepts/computes p
and returns it. Otherwise, it accepts/computes q
and returns it. It does not advance the input as a parser or produce something into the output as a serializer.
val const : string -> string t
val any : char t
any
accepts/produces any character. As a parser, it returns it. As a serializer, it writes it.
val nil : 'a list t
rep1 t
runs t
one or more times and accepts/produces a list of results from the runs of t
.
rep0 t
runs t
zero of more times and accepts/produces a list of results from the runs of t
.
val while0 : (char -> bool) -> string t
while0 p
accepts/produces a string
which respects the predicate p
. For example, this description:
NUMBER = *DIGIT
can be translated to:
let number = while0 is_digit
val while1 : (char -> bool) -> string t
while1 p
accepts/produces a string
which respects the predicate p
. The string
must be not empty. This description:
NUMBER = 1*DIGIT
can be translated to:
let number = while1 is_digit
val fixed : int -> string t
fixed n
accepts/produces any string
with n
bytes.
val lower : char t
lower
accepts/produces any US-ASCII lowercase letter 'a'
.. 'z'
, that is a byte in the range [0x61
;0x7A
].
val upper : char t
upper
accepts/produces any US-ASCII uppercase letter 'A'
.. 'Z'
, that is a byte in the range [0x41
;0x5A
].
val alpha : char t
alpha
is lower <|> upper
.
val digit : char t
digit
accepts/produces any US-ASCII digit '0'
.. '9'
, that is a byte in the range [0x30
;0x39
].