Module CCSexp
Handling S-expressions
type 'a or_error= ('a, string) Pervasives.resulttype 'a sequence= ('a -> unit) -> unittype 'a gen= unit -> 'a option
module type SEXP = CCSexp_intf.SEXP
module type S = CCSexp_intf.S
Basics
type t=[|`Atom of string|`List of t list]A simple, structural representation of S-expressions.
include S with type S.t := t
type ttype sexp= t
Re-exports
val atom : string -> tMake an atom out of this string.
- since
- 2.8
Constructors
val of_int : int -> tval of_bool : bool -> tval of_list : t list -> tval of_rev_list : t list -> tReverse the list.
val of_float : float -> tval of_unit : tval of_pair : (t * t) -> tval of_triple : (t * t * t) -> tval of_quad : (t * t * t * t) -> tval of_variant : string -> t list -> tof_variant name argsis used to encode algebraic variants into a S-expr. For instanceof_variant "some" [of_int 1]represents the valueSome 1.
Printing
val to_buf : Buffer.t -> t -> unitval to_string : t -> stringval to_file : string -> t -> unitval to_file_seq : string -> t CCSexp_intf.sequence -> unitPrint the given sequence of expressions to a file.
val to_chan : Pervasives.out_channel -> t -> unitval pp : Format.formatter -> t -> unitPretty-printer nice on human eyes (including indentation).
val pp_noindent : Format.formatter -> t -> unitRaw, direct printing as compact as possible.
Parsing
type 'a parse_result=|Yield of 'a|Fail of string|EndA parser of
'acan returnYield xwhen it parsed a value, orFail ewhen a parse error was encountered, orEndif the input was empty.
module Decoder : sig ... endval parse_string : string -> t CCSexp_intf.or_errorParse a string.
val parse_string_list : string -> t list CCSexp_intf.or_errorParse a string into a list of S-exprs.
- since
- 2.8
val parse_chan : Pervasives.in_channel -> t CCSexp_intf.or_errorParse 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 : Pervasives.in_channel -> t CCSexp_intf.or_error CCSexp_intf.genParse a channel into a generator of S-expressions.
val parse_chan_list : Pervasives.in_channel -> t list CCSexp_intf.or_errorval parse_file : string -> t CCSexp_intf.or_errorOpen the file and read a S-exp from it.
val parse_file_list : string -> t list CCSexp_intf.or_errorOpen the file and read a S-exp from it.
val atom : string -> tBuild an atom directly from a string.