Module Encore.Syntax
val fail : string -> 'a t
fail msg
creates a combinator that will always fail with the messagemsg
.
val map : ('a, 'b) Bij.t -> 'a t -> 'b t
val product : 'a t -> 'b t -> ('a * 'b) t
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 - seechoice
).
val fix : ('a t -> 'a t) -> 'a t
val pure : compare:('a -> 'a -> bool) -> 'a -> 'a t
val peek : 'a t -> 'b t -> ('a, 'b) Either.t t
peek p q
accepts/computesp
and returns it. Otherwise, it accepts/computesq
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
val rep1 : 'a t -> 'a list t
rep1 t
runst
one or more times and accepts/produces a list of results from the runs oft
.
val rep0 : 'a t -> 'a list t
rep0 t
runst
zero of more times and accepts/produces a list of results from the runs oft
.
val sep_by0 : sep:unit t -> 'a t -> 'a list t
val sep_by1 : sep:unit t -> 'a t -> 'a list t
val while0 : (char -> bool) -> string t
while0 p
accepts/produces astring
which respects the predicatep
. 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 astring
which respects the predicatep
. Thestring
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 anystring
withn
bytes.
val choice : 'a t list -> 'a t
val sequence : 'a t list -> 'a list t
val count : int -> 'a t -> 'a list t
val option : 'a t -> 'a option t
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
islower <|> upper
.
val digit : char t
digit
accepts/produces any US-ASCII digit'0'
..'9'
, that is a byte in the range [0x30
;0x39
].