Spec M15 — bundled standard library, #include <name>, #embed
Goal: the mc binary serves everything a program or a taught compiler needs; no repository checkout.
Bundle #
tools/bundle.list: manifest, onename<TAB>pathper line, sorted by name. Names:sys,sys_svc,io,prelude,user_default,backend_arm64, ... forlib/*.mc, andmc/core,mc/arena,mc/macho, ... for everysrc/*.mcthatsrc/core.mcincludes (NOTbundle_data.mc).tools/bundle.mc(anmcprogram): reads the manifest, compresses each file withsrc/lz.mc, writessrc/bundle_data.mc:u8 bundle_blob[] = { ... }(decimal bytes, 24 per line) plus flat index arraysuptr bundle_name[],i64 bundle_off[],bundle_csize[],bundle_rsize[]and#define BUNDLE_COUNT N. Byte-for-byte reproducible (make bundletwice ->cmpidentical).src/lz.mc: LZ77 with a 64 KiB window, greedy longest match, tokensliteral run/(len,dist);lz_deflate(src, n, dst) -> csize,lz_inflate(src, n, dst, rsize). Deterministic, ~150 lines. Round-trip test on every file of the manifest and on random data.src/bundle.mc:bundle_find(name) -> index or -1,bundle_read(i) -> uptr(inflated, cached). Special namemc/bundle_data: regenerated on the fly from the in-memory blob (the bundle cannot contain itself) so<mc/core>is complete for a taught compiler.
Lexer / includes #
#include <name>->bundle_find; pushed as file<name>(that is what error messages show). Unknown name ->unknown bundled include: <name>listing nothing else.#include "x"search order: includer directory, then[include].pathsfrom the TOML (M14), in order.src/core.mckeeps#include "..."between compiler modules (they are inside the bundle by name and the lexer resolves relative includes among bundled files by name).
#embed #
#embed name "path" [lz](directive at top level): declaresu8 name[]with the file bytes (or the LZ stream whenlzis given) and#define name_size N(bytes in the array) andname_raw N(original size). Path resolves like#include "x". Programs decompress with<lz>:lz_inflate(name, name_size, buf, name_raw).- Limits: file <= 16 MiB; error otherwise.
Driver #
mc buildwith[compiler].modulesbuilds the taught compiler from#include <mc/core>+ modules, no repository paths.examples/api/mc-api.mcswitches to#include <mc/core>.
Tests / acceptance #
tests/070-embed.mc(embed a small text file, print it),tests/071-embed-lz.mc(round trip),tests/072-include-bundle.mc(#include <sys>/<prelude>; runs).- Empty-directory test (
scripts/check-standalone.sh, inmake check): copybuild/mc-exeto a temp dir, compile a program using<sys>and<prelude>, build a taught compiler from<mc/core>+ a syntax module, use it — all without the repository. make bundlereproducible;make checkgreen; fixed point holds (the bundle is part ofsrc/).- Size report:
mc-exebefore/after; blob compressed vs raw.