Chaaya is an R7RS Scheme implementation written in C. It is a free redesign inspired by Kaappi (Zig), not a line-by-line port. Long-term goals match Kaappi’s breadth: R7RS-small, SRFIs, FFI, fibers, LLVM native backend, WASM, LSP, and packaging — delivered in phases.
Bootstrap interpreter:
- NaN-boxed values + mark-sweep GC
- Datum reader / printer
- Register bytecode VM
- Special forms:
quote,if,lambda,define,set!,begin,and,or,let - Core primitives (lists, arithmetic, equality, I/O)
- Control:
call/cc,dynamic-wind,with-exception-handler,raise/raise-continuable,error - Lists/
apply/map/for-each, strings, vectors,values/call-with-values - Ports: stdio + string ports;
read/display/writetake optional ports - Kaappi-shaped CLI (
features,doctor,ast, …) and linenoise REPL (chaaya>, multiline,,help,_)
Requires CMake 3.21+, a C23-capable compiler, and libc. On POSIX, the interactive REPL uses vendored linenoise (arrow keys, history).
make # configure + build → build/chaaya
make test # build + ctest
make run # REPLOr with CMake directly:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
ctest --test-dir build --output-on-failure./build/chaaya # REPL
./build/chaaya program.scm # run a file
./build/chaaya --version # Chaaya Scheme v0.1.0
./build/chaaya features
./build/chaaya doctor
./build/chaaya ast program.scmREPL history is stored in ~/.chaaya/history (or $CHAAYA_HOME/history).
See docs/dev/cli.md and docs/dev/repl.md.
(define (fact n)
(if (= n 0)
1
(* n (fact (- n 1)))))
(fact 10)| Phase | Focus |
|---|---|
| 0–3 | Scaffold, values/GC, reader, bytecode REPL (done) |
| 4 | call/cc, dynamic-wind, exceptions (done) |
| 5 | Hygienic syntax-rules + derived forms (done) |
| 6 | R7RS libraries + portable .sld reuse from Kaappi (done) |
| 7 | Full R7RS-small surface (R7RS CTest green; kaappi-deferred compliance/smoke batches in progress) |
| 8 | IR/opts, generational GC, CLI tooling (check, expand, fmt, cache) (MVP done) |
| 9 | Portable SRFI subset + import resolution (partial: ~192 vendored under lib/srfi/) |
| 10 | Fibers + FFI + reactor + SRFI-18 MVP (done) |
| 11 | LLVM / WASM / LSP / thottam integration (MVP in progress; see backlog below) |
| Item | Current state | Next milestones |
|---|---|---|
| LLVM native | Real LLVM IR emit + constant-exit lowering + chaaya_rt fallback (src/llvm_backend.c) |
broader form lowering, full C ABI runtime bridge |
| WASM | chaaya wasm runs scripts/build-wasm.sh; host-stub / WASI CMake paths |
wasm32-wasi CI matrix, browser playground binary |
| LSP | Diagnostics, symbols, completion, hover, definition, references (src/lsp.c, src/lsp_analysis.c) |
workspace/project indexing, richer docs |
| Compile cache | Auto .chbc read/write + cache status|clear (src/cache.c) |
import-aware caching, richer per-entry status |
| CLI observability | --disassemble, --timings, --gc-stats, --compile, profile/coverage/timeout/sandbox MVPs |
deeper coverage of library exports, parallel test --changed |
| thottam | Use Kaappi's Zig thottam (docs/dev/thottam.md); not reimplemented in C |
consumer docs / smoke wiring only |
| R7RS / deferred | R7RS CTest green; large kaappi-deferred batch wired | triage remaining Kaappi compliance/smoke files |
Language-parity target (≈99% Kaappi language surface): R7RS-small + portable SRFIs. Tooling/backends continue as incremental MVP hardening.
Chaaya reuses Kaappi as a behavioral reference and will vendor portable Scheme
libraries where licenses allow (MIT). Bytecode, IR, and ABI are intentionally
independent. Note that Kaappi’s R7RS (scheme …) libraries are built-in (not
lib/scheme/*.sld); portable .sld is primarily for SRFIs and user code.
Contributor documentation lives in docs/dev/:
- Architecture — pipeline, values, GC, VM, layout
- Backends — LLVM
--native+ WASM target stub status - C23 — language standard, C23 vs C17 features to leverage
- CLI — help shape, exit codes, stubs
- REPL — prompts, comma-commands, history
- Scheme tests — bootstrap suites, probes, deferred Kaappi/R7RS
- TODO — remaining unwired smokes, SRFI import failures, Phase 11+ backlog
- Thottam — using sibling Kaappi thottam with Chaaya
MIT — see LICENSE.