Source code

Installing

There is nothing to compile. Either let Akku, a Scheme package manager, fetch the library and set Chez's library path, or clone this repository and put two of its folders on the path yourself.

With Akku

From your project's folder:

akku install chez-httparse
. .akku/bin/activate

akku install adds chez-httparse to your project's Akku.manifest, creating one if there is none, and records the exact versions in Akku.lock. It installs chez-httparse and the one library it needs, byte-machine's runtime, under .akku/lib/. activate sets CHEZSCHEMELIBDIRS to that folder for the rest of your shell session, so no --libdirs is needed:

echo '(import (generated httparse-message)) (display "ok") (newline)' | chez -q

It prints ok. (Your Chez may be called scheme or chezscheme instead of chez.) Skip to usage.md.

From a clone

What you need

  • Chez Scheme 10.4.1 or newer. Petite Chez won't do: it can't compile programs, so the build turns it away.
  • This repository, with its submodule. The submodule, vendor/byte-machine, holds the one library the parser needs at run time.

1. Get the source

git clone --recursive https://github.com/Kiyomi-Computation-Systems/chez-httparse.git

Already cloned without --recursive? Fetch the submodule from inside the checkout:

git submodule update --init

2. Know the two folders

Chez finds a library by its name, inside the folders on its library path. Everything you import lives under one of two folders:

FolderLibraries in it
src/(generated httparse-message), (generated httparse-url), (httparse modes), (httparse methods), (httparse decisions)
vendor/byte-machine/src(byte-machine runtime)

That is the whole dependency list. These libraries import (rnrs) and each other, and nothing else; none of them imports (chezscheme).

src/ also holds the grammars the parsers are generated from. You never import those. They matter only if you change the parser (see building.md).

3. Put them on the library path

Pick one of three ways. The examples run from the repository root, so the paths are relative; from anywhere else, use absolute paths. Separate the two folders with : on macOS and Linux, and ; on Windows.

On the command line:

chez --libdirs src:vendor/byte-machine/src --program app.sps

In the environment. Chez reads CHEZSCHEMELIBDIRS when it starts:

HTTPARSE=/path/to/chez-httparse
export CHEZSCHEMELIBDIRS=$HTTPARSE/src:$HTTPARSE/vendor/byte-machine/src
chez --program app.sps

From Scheme. A program's imports are resolved before its first line runs, so set the path in a small launcher and load your program from it:

;; run.ss -- start with: chez --script run.ss
(library-directories (list "src" "vendor/byte-machine/src"))
(load-program "app.sps")

4. Check it works

From the repository root:

echo '(import (generated httparse-message)) (display "ok") (newline)' \
  | chez -q --libdirs src:vendor/byte-machine/src

It prints ok. (Your Chez may be called scheme or chezscheme instead of chez.)

If you forget the second folder, the import fails and says which library it could not find:

Exception: library (byte-machine runtime) not found

Akku in a clone

Akku also works inside a clone, which is handy when you work on chez-httparse itself. You don't need --recursive: Akku downloads byte-machine from its index instead of the submodule.

git clone https://github.com/Kiyomi-Computation-Systems/chez-httparse.git
cd chez-httparse
akku install
. .akku/bin/activate

Next: usage.md makes a parser and feeds it a request.