Library
Module
Module type
Parameter
Class
Class type
This is an implementation of (a subset of) Emacs s-expressions.
Recursively transform a sexp. map
function is applied on each atom and at the root of each list
Recursively transform a sexp. map
function is applied on each atom and each cons-cell
val sym_nil : 'a sexp
nil constant: S "nil"
val sym_t : 'a sexp
t constant: S "t"
Build a sexp list, -> nil x :: xs -> C (x, sexp_of_list xs)
val void : void -> 'a
val tell_sexp : (string -> unit) -> basic -> unit
Serialize an s-exp by repetively calling a string printing function.
val read_sexp : (unit -> char) -> basic * char
Read an basic by repetively calling a character reading function.
The character reading function can return '\000' to signal EOF.
Returns the basic and, if any, the last character read but not part of the sexp, or '\000'.
If the basic is not well-formed, a Failure is raised. You can catch it and add relevant location information. The error is always due to the last call to the reading function, which should be enough to locate the erroneous input, except for unterminated string.
val to_string : basic -> string
val of_string : string -> basic
val of_file_descr :
on_read:(Unix.file_descr -> unit) ->
Unix.file_descr ->
unit ->
basic option
Read from a file descriptor.
on_read
is called before a potentially blocking read is done, so that you can act before blocking (select, notify scheduler ...).
Partial application (stopping before the last ()
) allows to read a stream of sexp.
val of_channel : in_channel -> unit -> basic option
Read from a channel.
Partial application (stopping before the last ()
) allows to read a stream of sexp.