Module Csexp
Canonical S-expressions
module type Sexp = sig ... end
module type S = sig ... end
include S with type S.sexp := t
val parse_string : string -> (sexp, int * string) Stdlib.result
parse_string s
parses a single S-expression encoded in canonical form ins
. It is an error fors
to contain a S-expression followed by more data. In case of error, the offset of the error as well as an error message is returned.
val parse_string_many : string -> (sexp list, int * string) Stdlib.result
parse_string s
parses a sequence of S-expressions encoded in canonical form ins
val input : Stdlib.in_channel -> (sexp, string) Stdlib.result
Read exactly one canonical S-expressions from the given channel. Note that this function never raises
End_of_file
. Instead, it returnsError
.
val input_opt : Stdlib.in_channel -> (sexp option, string) Stdlib.result
Same as
input
but returnsOk None
if the end of file has already been reached. If some more characters are available but the end of file is reached before reading a complete S-expression, this function returnsError
.
val input_many : Stdlib.in_channel -> (sexp list, string) Stdlib.result
Read many S-expressions until the end of input is reached.
Serialising
val serialised_length : sexp -> int
The length of the serialised representation of a S-expression
val to_string : sexp -> string
to_string sexp
converts S-expressionsexp
to a string in canonical form.
val to_buffer : Stdlib.Buffer.t -> sexp -> unit
to_buffer buf sexp
outputs the S-expressionsexp
converted to its canonical form to bufferbuf
.
val to_channel : Stdlib.out_channel -> sexp -> unit
output oc sexp
outputs the S-expressionsexp
converted to its canonical form to channeloc
.
Low level parser
For efficiently parsing from sources other than strings or input channel. For instance in Lwt or Async programs.
module Parser : sig ... end
Deprecated low-level parser
module type Input = sig ... end
module Make_parser : functor (Input : Input) -> sig ... end