package csexp
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=8e3d6fca87f102a126dee8b72a2a0d146f10439c47218dfc149d51bf3edf364e
sha512=604a5094fbbf61f497b342ad0aa8ec25275b2a904cd0c1823fc40daa54a15796b360374ff495c0d8ca3b4c1e6723b2ce37e030857fae131222606de818fb8129
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: 21 Feb 2021
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!)"
Dev Dependencies
None
Used by (15)
-
containers
>= "3.5"
-
coq-of-ocaml
>= "2.4.1" & < "2.5.3+4.14"
-
dot-merlin-reader
< "4.2"
-
dune-configurator
>= "2.7.1" & < "3.0.2"
- dune-rpc
-
earlybird
>= "1.0.1"
-
gopcaml-mode-merlin
< "0.0.6"
-
lsp
< "1.8.2"
-
mdx
>= "1.8.1"
-
merlin
>= "3.4.0" & < "4.5-411"
-
ocaml-lsp-server
< "1.8.2"
-
ocamlformat
>= "0.22.4" & < "0.25.1"
- ocamlformat-lib
- ocamlformat-rpc-lib
- ocamlmerlin-mlx
Conflicts
None