Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ocaml-dune/csexp
Minimal support for Canonical S-expressions
https://github.com/ocaml-dune/csexp
Last synced: 2 months ago
JSON representation
Minimal support for Canonical S-expressions
- Host: GitHub
- URL: https://github.com/ocaml-dune/csexp
- Owner: ocaml-dune
- License: mit
- Created: 2020-03-11T18:04:09.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-18T15:53:47.000Z (over 1 year ago)
- Last Synced: 2024-08-04T01:28:40.752Z (6 months ago)
- Language: OCaml
- Size: 120 KB
- Stars: 26
- Watchers: 2
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome-list - csexp - expressions | ocaml-dune | 23 | (OCaml)
README
Csexp - Canonical S-expressions
===============================This project provides minimal support for parsing and printing
[S-expressions in canonical form][wikipedia], which is a very simple
and canonical binary encoding of S-expressions.[wikipedia]: https://en.wikipedia.org/wiki/Canonical_S-expressions
Example
-------```ocaml
# #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!)"
```