package containers

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module CCSexp.MakeSource

Functorized operations

This builds a parser and printer for S-expressions represented as in the Sexp argument.

  • since 2.7

Parameters

module Sexp : SEXP

Signature

Sourcetype t = Sexp.t
Sourcetype sexp = t

Re-exports

Sourceval atom : string -> t

Make an atom out of this string.

  • since 2.8
Sourceval list : t list -> t

Make a Sexpr of this list.

  • since 2.8

Constructors

Sourceval of_int : int -> t
Sourceval of_bool : bool -> t
Sourceval of_list : t list -> t
Sourceval of_rev_list : t list -> t

Reverse the list.

Sourceval of_float : float -> t
Sourceval of_unit : t
Sourceval of_pair : (t * t) -> t
Sourceval of_triple : (t * t * t) -> t
Sourceval of_quad : (t * t * t * t) -> t
Sourceval of_variant : string -> t list -> t

of_variant name args is used to encode algebraic variants into a S-expr. For instance of_variant "some" [of_int 1] represents the value Some 1.

Sourceval of_field : string -> t -> t

Used to represent one record field.

Sourceval of_record : (string * t) list -> t

Represent a record by its named fields.

Printing

Sourceval to_buf : Buffer.t -> t -> unit
Sourceval to_string : t -> string
Sourceval to_file : string -> t -> unit
Sourceval to_file_iter : string -> t CCSexp_intf.iter -> unit

Print the given iter of expressions to a file.

Sourceval to_chan : out_channel -> t -> unit
Sourceval pp : Format.formatter -> t -> unit

Pretty-printer nice on human eyes (including indentation).

Sourceval pp_noindent : Format.formatter -> t -> unit

Raw, direct printing as compact as possible.

Parsing

Sourcetype 'a parse_result =
  1. | Yield of 'a
  2. | Fail of string
  3. | End

A parser of 'a can return Yield x when it parsed a value, or Fail e when a parse error was encountered, or End if the input was empty.

Sourcemodule Decoder : sig ... end
Sourceval parse_string : string -> t CCSexp_intf.or_error

Parse a string.

Sourceval parse_string_list : string -> t list CCSexp_intf.or_error

Parse a string into a list of S-exprs.

  • since 2.8

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).

Parse a channel into a generator of S-expressions.

Sourceval parse_chan_list : in_channel -> t list CCSexp_intf.or_error
Sourceval parse_file : string -> t CCSexp_intf.or_error

Open the file and read a S-exp from it.

Sourceval parse_file_list : string -> t list CCSexp_intf.or_error

Open the file and read a S-exp from it.

OCaml

Innovation. Community. Security.