package csexp

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

Install

Dune Dependency

Authors

Maintainers

Sources

csexp-1.5.2.tbz
sha256=1a14dd04bb4379a41990248550628c77913a9c07f3c35c1370b6960e697787ff
sha512=be281018bcfc20d4db14894ef51c4b836d6338d2fdfe22e63d46f405f8dea7349e16f1c0ecd65f73d4c85a2a80e618cdbb8c9dafcbb9f229f04f1adca5b1973c

Description

This library provides minimal support for Canonical S-expressions [1]. Canonical S-expressions are a binary encoding of S-expressions that is super simple and well suited for communication between programs.

This library only provides a few helpers for simple applications. If you need more advanced support, such as parsing from more fancy input sources, you should consider copying the code of this library given how simple parsing S-expressions in canonical form is.

To avoid a dependency on a particular S-expression library, the only module of this library is parameterised by the type of S-expressions.

[1] https://en.wikipedia.org/wiki/Canonical_S-expressions

Published: 19 Apr 2023

README

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!)"

Dependencies (2)

  1. ocaml >= "4.03.0"
  2. dune >= "3.4"

Dev Dependencies (1)

  1. odoc with-doc

Used by (21)

  1. containers >= "3.5"
  2. coq-of-ocaml >= "2.5.0"
  3. dot-merlin-reader != "4.4~5.0.preview" & < "4.6"
  4. dune-action-plugin >= "3.0.2"
  5. dune-configurator >= "2.7.1"
  6. dune-private-libs >= "3.0.2"
  7. dune-rpc
  8. dune-rpc-lwt
  9. earlybird >= "1.0.1"
  10. gopcaml-mode-merlin < "0.0.6"
  11. lsp < "1.10.5"
  12. mdx >= "1.8.1"
  13. merlin >= "3.4.0" & < "4.6-414" | >= "4.7-412" & < "4.7-414"
  14. merlin-lib
  15. ocaml-lsp-server
  16. ocamlformat >= "0.22.4" & < "0.25.1"
  17. ocamlformat-lib
  18. ocamlformat-rpc-lib
  19. ometrics < "0.2.0"
  20. sexp_decode
  21. stdune

Conflicts

None