Csexp.Sparse_string s parses a single S-expression encoded in canonical form in s. It is an error for s 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.
parse_string s parses a sequence of S-expressions encoded in canonical form in s
val input : in_channel -> (sexp, string) resultRead exactly one canonical S-expressions from the given channel. Note that this function never raises End_of_file. Instead, it returns Error.
val input_opt : in_channel -> (sexp option, string) resultSame as input but returns Ok 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 returns Error.
val input_many : in_channel -> (sexp list, string) resultRead many S-expressions until the end of input is reached.
val serialised_length : sexp -> intThe length of the serialised representation of a S-expression
val to_string : sexp -> stringto_string sexp converts S-expression sexp to a string in canonical form.
to_buffer buf sexp outputs the S-expression sexp converted to its canonical form to buffer buf.
val to_channel : out_channel -> sexp -> unitoutput oc sexp outputs the S-expression sexp converted to its canonical form to channel oc.
For efficiently parsing from sources other than strings or input channel. For instance in Lwt or Async programs.
module Parser : sig ... endThe Parser module offers an API that is a balance between sharing the common logic of parsing canonical S-expressions while allowing to write parsers that are as efficient as possible, both in terms of speed and allocations. A carefully written parser using this API will be:
The above are deprecated as the Input signature does not allow to distinguish between IO errors and end of input conditions. Additionally, the use of monads tend to produce parsers that allocates a lot.
It is recommended to use the Parser module instead.
module type Input = sig ... endmodule Make_parser (Input : Input) : sig ... end