package csexp

  1. Overview
  2. Docs
Parsing and printing of S-expressions in Canonical form

Install

Dune Dependency

Authors

Maintainers

Sources

csexp-1.2.0.tbz
sha256=04afa50ca96ce07b395e58b7b7f574fa4f6f21c98f3c19fc386305a29b167c28
sha512=5bf09f4bea1503c5893fb1728a3a7db55d90c1f1871623579738946523e9f3e0d6080d214f519d88a8df549424e21468fe6550f302c2a9e3f3a2e1a7cd641c15

README.md.html

Csexp - Canonical S-expressions

This project provides minimal support for parsing and printing S-expressions in canonical form, which is a very simple and canonical binary encoding of S-expressions.

Example

# #require "csexp";;
# module Sexp = struct type t = Atom of string | List of t list end;;
module Sexp : sig type t = Atom of string | List of t list end
# module Csexp = Csexp.Make(Sexp);;
module Csexp :
  sig
    val parse_string : string -> (Sexp.t, int * string) result
    val parse_string_many : string -> (Sexp.t list, int * string) result
    val input : in_channel -> (Sexp.t, string) result
    val input_opt : in_channel -> (Sexp.t option, string) result
    val input_many : in_channel -> (Sexp.t list, string) result
    val serialised_length : Sexp.t -> int
    val to_string : Sexp.t -> string
    val to_buffer : Buffer.t -> Sexp.t -> unit
    val to_channel : out_channel -> Sexp.t -> unit
  end
# Csexp.to_string (List [ Atom "Hello"; Atom "world!" ]);;
- : string = "(5:Hello6:world!)"
OCaml

Innovation. Community. Security.