Module CCSexp
Handling S-expressions
type 'a or_error
= ('a, string) Result.result
type 'a sequence
= ('a -> unit) -> unit
type 'a gen
= unit -> 'a option
Basics
val equal : t -> t -> bool
val compare : t -> t -> int
val hash : t -> int
val atom : string -> t
Build an atom directly from a string.
val of_int : int -> t
val of_bool : bool -> t
val of_list : t list -> t
val of_rev_list : t list -> t
Reverse the list.
val of_float : float -> t
Reverse the list.
Printing
val to_buf : Stdlib.Buffer.t -> t -> unit
val to_string : t -> string
val to_file : string -> t -> unit
val to_file_seq : string -> t sequence -> unit
Print the given sequence of expressions to a file.
val to_chan : Stdlib.out_channel -> t -> unit
val pp : Stdlib.Format.formatter -> t -> unit
Pretty-printer nice on human eyes (including indentation).
val pp_noindent : Stdlib.Format.formatter -> t -> unit
Raw, direct printing as compact as possible.
Parsing
type 'a parse_result
=
|
Yield of 'a
|
Fail of string
|
End
A parser of
'a
can returnYield x
when it parsed a value, orFail e
when a parse error was encountered, orEnd
if the input was empty.
module Decoder : sig ... end
val parse_chan : Stdlib.in_channel -> t or_error
Parse a S-expression from the given channel. Can read more data than necessary, so don't use this if you need finer-grained control (e.g. to read something else after the S-exp).
val parse_chan_gen : Stdlib.in_channel -> t or_error gen
Parse a channel into a generator of S-expressions.