package containers

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

S-expressions Parser

  • since 0.4
type 'a or_error = [
  1. | `Ok of 'a
  2. | `Error of string
]
type 'a sequence = ('a -> unit) -> unit
type 'a gen = unit -> 'a option
type t = [
  1. | `Atom of string
  2. | `List of t list
]

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

type 'a parse_result = [
  1. | 'a or_error
  2. | `End
]
type 'a partial_result = [
  1. | 'a parse_result
  2. | `Await
]
module Source : sig ... end
module Lexer : sig ... end
module ParseGen : sig ... end
Stream Parser

Returns a lazy stream of S-expressions.

val parse_string : string -> t ParseGen.t

Parse a string

val parse_chan : ?bufsize:int -> in_channel -> t ParseGen.t

Parse a channel

val parse_gen : string gen -> t ParseGen.t

Parse chunks of string

Blocking API

Parse one S-expression from some source.

val of_chan : 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 of_string : string -> t or_error
val of_file : string -> t or_error

Open the file and read a S-exp from it

Lists of S-exps
module L : sig ... end
OCaml

Innovation. Community. Security.