cc — C compiler in scheme1
A single-file C compiler written in scheme1 (see docs/SCHEME1.md)
that emits P1pp text, replacing MesCC at the live-bootstrap tcc-mes stage.
Specs
Read in this order:
- docs/CC.md — accepted C subset.
- docs/CCSCM.md —
cc.scmcode map: subsystems, data structures, pipeline. - docs/CC-EXT.md — platform extensions accepted beyond the base subset (the deltas tcc-0.9.26 actually uses).
Files
| File | Purpose |
|---|---|
cc.scm |
All compiler modules in one file: util, data, lex, pp, cg, parse, and the cc-main driver. Sections are still labeled with their original ;; cc/<name>.scm — headers. |
main.scm |
One-liner production entry point: (sys-exit (cc-main (argv))). Tests omit it so they can run their own drivers. |
Build (single source for scheme1):
catm build/$ARCH/cc/cc.scm \
scheme1/prelude.scm cc/cc.scm cc/main.scm
Tests
tests/cc-util/— util helpers (Scheme unit tests)tests/cc-lex/— lexer token-stream goldenstests/cc-pp/— preprocessor token-stream goldenstests/cc-cg/— direct cg API → ELF → run; assert runtimetests/cc/— full pipeline via .c → ELF → run; assert runtime
Both cc-cg and cc are runtime-validating: the harness builds the emitted P1pp into a real ELF, runs it, and asserts exit code / stdout. No P1pp-text goldens.