package yocaml

  1. Overview
  2. Docs
include module type of Sexp

Definition

An S-Expression is a data structure with an extremely simple recursive syntax tree. It is made up of atoms (character strings) and nodes (also S-Expressions).

type t =
  1. | Atom of string
  2. | Node of t list

S-Expression AST.

type parsing_error =
  1. | Nonterminated_node of int
  2. | Nonterminated_atom of int
  3. | Expected_number_or_colon of char * int
  4. | Expected_number of char * int
  5. | Unexepected_character of char * int
  6. | Premature_end_of_atom of int * int

Errors that can occur when parsing S-expressions.

type invalid =
  1. | Invalid_sexp of t * string

Used to describe an invalid S-expression (correctly parsed but does not respect a schema).

val atom : string -> t

atom x lift a given string, x, into a t.

val node : t list -> t

nod x lift a given list of t, x, into a t.

Serialization

Tools for serializing a Sexp.

val to_string : t -> string

convert a S-expression to a string (with indent).

Deserialization

val from_string : string -> (t, parsing_error) result

from_string str Try deserializing a string in Sexp.

val from_seq : char Seq.t -> (t, parsing_error) result

from_string str Try deserializing a string in Sexp.

module Canonical : sig ... end

S-Canonical expression used to describe compressed data sources.

Utils

val equal : t -> t -> bool

Equality between t.

val pp : Format.formatter -> t -> unit

Pretty-printer for t (mostly used for debugging issue).

val pp_pretty : Format.formatter -> t -> unit

Pretty-printer for t with indentation.

module Provider : sig ... end
OCaml

Innovation. Community. Security.