1# kahl23R⁷RS Scheme parser combinator library for decoding [BARE][bare web] messages.45## Status67With the exception of floating-point numbers (`f32` and `f64`), all8types from [`draft-devault-bare-01`][draft-devault-bare-01] are9supported. The BARE schema language is currently not supported, but may10be supported in future version of this library. Additionally, this11hasn't been tested extensively and the API may still change.1213## Usage1415Depends on your Scheme implementation. I have tested this with16[CHICKEN Scheme][chicken scheme] and [chibi-scheme][chibi github].17For simple experiments, simply use the following commands:1819 $ git clone https://github.com/nmeum/kahl20 $ cd kahl21 $ chibi-scheme22 > (import (kahl))23 > (parse (parse-struct parse-u8 parse-u8) #u8(23 42))24 #(23 42)2526Tests require [`(chibi test)`][chibi test] and can be run as follows:2728 $ ./run-tests.scm2930## Extended Example3132Consider the following [BARE schema][bare schema] definition:3334 type Customer {35 name: string36 email: string37 orders: []{38 orderId: i6439 quantity: i3240 }41 }4243Messages of this type can be parsed using the following Scheme code:4445 (import (kahl))4647 ;; Define a parser for the Customer type.48 (define parse-customer49 (parse-struct50 parse-string ;; name51 parse-string ;; email52 (parse-list ;; orders53 (parse-struct54 parse-i6455 parse-i32))))5657 ;; Create a parse stream for the file customer.bin58 ;; and use the parse-customer parser to parse it.59 (let ((s (make-parse-stream "customer.bin")))60 (parse parse-customer s))6162Refer to the documentation for more information on individual procedures.6364## Documentation6566This library is documented using Scheme Scribble syntax as implemented by67[chibi scribble][chibi scribble]. Documentation can be generated using68`chibi-doc(1)`. To generate HTML documentation run:6970 $ chibi-doc -h kahl > kahl.html7172If you want to improve the existing documentation, take a look at the73[Scribble quick start guide][racket scribble]. Commands supported in the74default Chibi-Scheme doc environment can be obtained by importing75[`(chibi doc)`][chibi doc] and running `(make-default-doc-env)`.7677## License7879This program is free software: you can redistribute it and/or modify80it under the terms of the GNU General Public License as published by81the Free Software Foundation, either version 3 of the License, or82(at your option) any later version.8384This program is distributed in the hope that it will be useful,85but WITHOUT ANY WARRANTY; without even the implied warranty of86MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the87GNU General Public License for more details.8889You should have received a copy of the GNU General Public License90along with this program. If not, see <https://www.gnu.org/licenses/>.9192[bare web]: https://baremessages.org/93[draft-devault-bare-01]: https://datatracker.ietf.org/doc/html/draft-devault-bare-0194[bare schema]: https://datatracker.ietf.org/doc/html/draft-devault-bare-01#section-395[langsec web]: https://langsec.org/96[bratus parser]: https://www.usenix.org/publications/login/spring2017/bratus97[chibi parse]: https://synthcode.com/scheme/chibi/lib/chibi/parse.html98[chibi test]: https://synthcode.com/scheme/chibi/lib/chibi/test.html99[chibi scribble]: https://synthcode.com/scheme/chibi/lib/chibi/scribble.html100[chibi doc]: https://synthcode.com/scheme/chibi/lib/chibi/doc.html101[racket scribble]: https://docs.racket-lang.org/scribble/getting-started.html102[chicken scheme]: https://call-cc.org103[chibi github]: https://github.com/ashinn/chibi-scheme