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 information11;;> on individual procedures.12;;>13;;> Regarding error handling, this document makes a distinction between14;;> errors occurring during parser constructing (e.g. creating an empty15;;> struct) and errors occurring during parsing (e.g. parsing a tagged16;;> union containing an unsupported type). The former result in an17;;> R\superscript{7}RS exception, the latter result in the invocation of a18;;> specified failure continuation which defaults to a function ignoring19;;> the failure reason and returning false. Refer to the documentation20;;> of \scheme{call-with-parse} for more information.2122(define-library (kahl)23 (import (scheme base) (scheme file) (scheme write) (srfi 151))2425 (export make-parse-stream bytevector->parse-stream parse call-with-parse)26 (export parse-uint parse-int parse-u8 parse-u1627 parse-u32 parse-u64 parse-i8 parse-i16 parse-i3228 parse-i64 parse-bool parse-string parse-optional29 parse-map parse-list parse-union parse-struct30 parse-data parse-enum parse-void)3132 (include "lib/util.scm"33 "lib/convert.scm"34 "lib/parser.scm"35 "lib/bare.scm"))