kahl

R⁷RS Scheme parser combinator library for decoding BARE messages

git clone https://git.8pit.net/kahl.git

 1;;> A parser combinator library for decoding \hyperlink["https://baremessages.org/"]{BARE} messages.
 2;;>
 3;;> The structure of this document is inspired by the BARE draft,
 4;;> it is highly recommended to at least briefly read Section 2 of
 5;;> \hyperlink[https://datatracker.ietf.org/doc/draft-devault-bare/]{draft-devault-bare-01}
 6;;> before continuing.
 7
 8;;> The implemented parser combinators are based on a modified version of
 9;;> \hyperlink["https://synthcode.com/scheme/chibi/lib/chibi/parse.html"]{(chibi parse)}
10;;> the documentation of which may also be consulted for more background information
11;;> on individual procedures.
12;;>
13;;> Regarding error handling, this document makes a distinction between
14;;> errors occurring during parser constructing (e.g. creating an empty
15;;> struct) and errors occurring during parsing (e.g. parsing a tagged
16;;> union containing an unsupported type). The former result in an
17;;> R\superscript{7}RS exception, the latter result in the invocation of a
18;;> specified failure continuation which defaults to a function ignoring
19;;> the failure reason and returning false. Refer to the documentation
20;;> of \scheme{call-with-parse} for more information.
21
22(define-library (kahl)
23  (import (scheme base) (scheme file) (scheme write) (srfi 151))
24
25  (export make-parse-stream bytevector->parse-stream parse call-with-parse)
26  (export parse-uint parse-int parse-u8 parse-u16
27          parse-u32 parse-u64 parse-i8 parse-i16 parse-i32
28          parse-i64 parse-bool parse-string parse-optional
29          parse-map parse-list parse-union parse-struct
30          parse-data parse-enum parse-void)
31
32  (include "lib/util.scm"
33           "lib/convert.scm"
34           "lib/parser.scm"
35           "lib/bare.scm"))