Module CCSexpM

module CCSexpM: sig .. end

Simple and efficient S-expression parsing/printing


Since 0.7

type 'a or_error = [ `Error of string | `Ok of 'a ] 
type 'a sequence = ('a -> unit) -> unit 
type 'a gen = unit -> 'a option 

Basics


type t = [ `Atom of string | `List of t list ] 
type sexp = t 

Serialization (encoding)


val to_buf : 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 : Pervasives.out_channel -> t -> unit
val print : Format.formatter -> t -> unit
Pretty-printer nice on human eyes (including indentation)
val print_noindent : Format.formatter -> t -> unit
Raw, direct printing as compact as possible

Deserialization (decoding)


module type MONAD = sig .. end
type 'a parse_result = [ `End | `Error of string | `Ok of 'a ] 
A parser of 'a can return `Ok x when it parsed a value, or `Error e when a parse error was encountered, or `End if the input was empty
module MakeDecode (M : MONAD) : sig .. end
module ID_MONAD: MONAD  with type 'a t = 'a
The monad that just uses blocking calls as bind
module D: module type of MakeDecode(ID_MONAD)
Decoder that just blocks when input is not available
val parse_string : string -> t or_error
Parse a string
val parse_chan : ?bufsize:int -> Pervasives.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 : ?bufsize:int ->
Pervasives.in_channel -> t or_error gen
Parse a channel into a generator of S-expressions
val parse_chan_list : ?bufsize:int -> Pervasives.in_channel -> t list or_error
val parse_file : string -> t or_error
Open the file and read a S-exp from it
val parse_file_list : string -> t list or_error
Open the file and read a S-exp from it