diff options
| author | 2026-10-14 10:05:40 +0000 | |
|---|---|---|
| committer | 2026-10-14 10:05:40 +0000 | |
| commit | ce920b6ff47f32bc06dd27124e1b882f82f3d6ae (patch) | |
| tree | 89f3dac0aa670294053320599a742d670c0ec5a4 /README.md | |
| parent | todo: tick the parity runner; zc0 follow-ups it found (diff) | |
split compiler.zc into files by phase
src/compiler/compiler.zc is now twelve files under src/compiler/, listed in
order in src/compiler/parts. cat of the parts in order is byte-identical to
the old file, so every compiler and image except the language server's is
unchanged. no function was edited.
consumers read the list: the makefile, bootstrap-check, genmap (which still
writes one compiler.zc into a generated map directory), tinyvm.bat,
test.sh, test_win.ps1 and the lsp drivers. the language server embeds each
part and serves them joined as the one document tinyvm:/compiler.zc.
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -6,7 +6,7 @@ this folder has the latest code. `docs/LEARN.md` is a tour of the language. `doc ## files -`src/core/core.c` is the native core. it contains the arm64 jit, the llvm backend (behind `-DZYLLVM`), the portable interpreter, the enhancement unit (recipe parser, vm-code lifter, optimizer and lowering), and the o3 region compiler. `src/runtime/rt.zc` provides i/o, native division enhancements, the heap, and the collector; `src/compiler/compiler.zc` is the compiler. both are written in zc and begin with an overview. together they make up the genome. `src/tools/zc0.c` is stage 0 of the bootstrap, a c compiler for the subset of zc used by `src/compiler/compiler.zc`. `src/tools/build.zc` has the resident compiler compile its own source into a fresh image, and `src/tools/mkgenome.c` checks that image against the memory map before it becomes `build/core/genome.bin`. an image is a file of little-endian 64-bit words, and every core takes its genome in at compile time with c23 `#embed` (`src/core/genome.h`). `examples/` contains small programs (hello, factorial, echo, self-patching code, an owning list, a repl, a typed program, and an enhancement demo) and larger proofs of concept: +`src/core/core.c` is the native core. it contains the arm64 jit, the llvm backend (behind `-DZYLLVM`), the portable interpreter, the enhancement unit (recipe parser, vm-code lifter, optimizer and lowering), and the o3 region compiler. `src/runtime/rt.zc` provides i/o, native division enhancements, the heap, and the collector; the compiler is the files of `src/compiler/`, named in order by `src/compiler/parts` (the lexer, types, expressions, statements, analyzer, declarations, check mode and image building each have a file; `base.zc` begins with the overview). all are written in zc. together they make up the genome. `src/tools/zc0.c` is stage 0 of the bootstrap, a c compiler for the subset of zc used by the compiler. `src/tools/build.zc` has the resident compiler compile its own source into a fresh image, and `src/tools/mkgenome.c` checks that image against the memory map before it becomes `build/core/genome.bin`. an image is a file of little-endian 64-bit words, and every core takes its genome in at compile time with c23 `#embed` (`src/core/genome.h`). `examples/` contains small programs (hello, factorial, echo, self-patching code, an owning list, a repl, a typed program, and an enhancement demo) and larger proofs of concept: - `mandel.zc`: the mandelbrot set in 16.16 fixed point, with the fixed-point multiply wired in as a custom opcode. - `bf.zc`: a brainfuck compiler. it turns brainfuck into zc source, has the resident compiler compile it, and runs it (native code on the jit). it takes a program after a backtick, or runs hello world. @@ -89,9 +89,9 @@ clang -O2 -fwrapv -DJTYPE=int -DZYLLVM $(llvm-config --cflags) src/core/core.c s ### language server -`src/lsp/server.zc` is a language server written in zc. it runs the compiler (`src/compiler/compiler.zc`) in check mode and provides a json-rpc protocol. diagnostics use the compiler's messages. parse words such as `immediate fn`, `run.add_binop` and `quote` execute during checks, so editor parsing and highlighting reflect syntax added by the program. +`src/lsp/server.zc` is a language server written in zc. it runs the compiler (`src/compiler/`) in check mode and provides a json-rpc protocol. diagnostics use the compiler's messages. parse words such as `immediate fn`, `run.add_binop` and `quote` execute during checks, so editor parsing and highlighting reflect syntax added by the program. -hover shows declaration signatures and documentation. a top-level function, global or struct shows its declaration line; a method or static function shows its indented declaration. comments directly above a declaration provide its documentation, and a declaration without comments still shows its signature. parameters show their declarations, while `let` locals show the compiler-assigned type. untyped locals, parameters and function returns show inferred types; the server obtains these by checking the document again with unresolved names open. it caches the result until the document changes, so the first hover after an edit may take longer. hovering an imported module name shows its module overview and include form; source libraries can provide the same overview in a comment after their namespace and include headers. embedded `core.zc` is provided alongside runtime, compiler and standard-library sources, so `core.syscall` and `rt.syscall` navigate to and reference their distinct declarations. keywords such as `static`, `micro` and `unchecked` show their form and meaning from one table in `src/lsp/server.zc`. +hover shows declaration signatures and documentation. a top-level function, global or struct shows its declaration line; a method or static function shows its indented declaration. comments directly above a declaration provide its documentation, and a declaration without comments still shows its signature. parameters show their declarations, while `let` locals show the compiler-assigned type. untyped locals, parameters and function returns show inferred types; the server obtains these by checking the document again with unresolved names open. it caches the result until the document changes, so the first hover after an edit may take longer. hovering an imported module name shows its module overview and include form; source libraries can provide the same overview in a comment after their namespace and include headers. embedded `core.zc` is provided alongside runtime, compiler (its parts joined into the one document `tinyvm:/compiler.zc`) and standard-library sources, so `core.syscall` and `rt.syscall` navigate to and reference their distinct declarations. keywords such as `static`, `micro` and `unchecked` show their form and meaning from one table in `src/lsp/server.zc`. check mode records errors instead of printing them and continues after an error, up to 20 diagnostics per document. each record contains a line and token offset; the server maps these to utf-16 ranges. check mode also reports non-error findings as hints. @@ -516,7 +516,7 @@ tables: `run.add_binop("**", 11, "ipow c")` adds or replaces a binary operator w ## the bootstrap -`src/tools/zc0.c` compiles the subset of zc used by `src/compiler/compiler.zc` (without the analyzer, types, quote, parse words, or block expressions, but with `enhance` and top-level `embed` declarations) into the first genome, `build/s0/genome.bin`. a core built around that image compiles `src/compiler/compiler.zc` again in the VM using the full compiler, analyzer, and native division code, and `mkgenome` accepts the result only if it is an image (a compiler that rejects its own source prints diagnostics instead, which `mkgenome` shows). a core built around the second image compiles the source a third time; the two self-compiled images must be identical, and the first becomes `build/core/genome.bin`. the test suite checks this fixpoint on the interpreter, microcore, jit and llvm backends when available. in the zc0 subset `u`, `m` and `d` are recast tags, not names. an image build (`build_image(org, dst)`) compiles with only the image's names, keywords, and built-in types visible, writes code for the requested address, and appends a symbol table containing its names and enhancements. an image build (`build_image(org, dst)`) compiles with only the image's names, keywords, and built-in types visible, writes code for the requested address, and appends a symbol table containing its names and enhancements. +`src/tools/zc0.c` compiles the subset of zc used by the compiler, the files of `src/compiler/parts` read as one stream (without the analyzer, types, quote, parse words, or block expressions, but with `enhance` and top-level `embed` declarations) into the first genome, `build/s0/genome.bin`. a core built around that image compiles the compiler again in the VM using the full compiler, analyzer, and native division code, and `mkgenome` accepts the result only if it is an image (a compiler that rejects its own source prints diagnostics instead, which `mkgenome` shows). a core built around the second image compiles the source a third time; the two self-compiled images must be identical, and the first becomes `build/core/genome.bin`. the test suite checks this fixpoint on the interpreter, microcore, jit and llvm backends when available. in the zc0 subset `u`, `m` and `d` are recast tags, not names. an image build (`build_image(org, dst)`) compiles with only the image's names, keywords, and built-in types visible, writes code for the requested address, and appends a symbol table containing its names and enhancements. an image build (`build_image(org, dst)`) compiles with only the image's names, keywords, and built-in types visible, writes code for the requested address, and appends a symbol table containing its names and enhancements. ## the instruction set |
