Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d9dc57a
test: epc self-hosting parity scoreboard (baseline 13/54 runnable, 5/…
MettaMazza Jul 1, 2026
1b8d509
refactor: extract C runtime to runtime/ep_runtime.c; make emitted C d…
MettaMazza Jul 1, 2026
e3f2b20
refactor: extract static builtin layer to runtime/ep_builtins.c (byte…
MettaMazza Jul 1, 2026
8faaf88
GC: align conservative scan bases down to 8 bytes (UB on strict platf…
MettaMazza Jul 1, 2026
79db0b2
feat(self-host): epc embeds the modern shared C runtime (generational…
MettaMazza Jul 1, 2026
469993e
feat(self-host): f-string interpolation + builtin return-type registr…
MettaMazza Jul 1, 2026
91a5b99
fix(self-host): '_' locals, builtin-shadowing skip, sqlite/crypto lin…
MettaMazza Jul 1, 2026
5cefd78
feat(self-host): closures + higher-order functions (parity 26->31/54)
MettaMazza Jul 1, 2026
cdb6998
fix(self-host): 'equals' on unknown-typed operands compiled to pointe…
MettaMazza Jul 1, 2026
abe81a3
fix(self-host): purge non-runtime names from builtin registry; harden…
MettaMazza Jul 1, 2026
e85fe5f
feat(self-host): English keyword aliases + keyword-as-identifier leni…
MettaMazza Jul 1, 2026
1cad11e
feat(self-host): import "x" as alias (parity 32->33/54)
MettaMazza Jul 1, 2026
3eeec0f
feat(self-host): bare enum-variant identifiers construct the variant …
MettaMazza Jul 1, 2026
a6a6126
feat(self-host): boolean display (true/false) (parity 34->35/54)
MettaMazza Jul 1, 2026
1de9c36
feat(bootstrap): frozen pure-C bootstrap — toolchain builds without Rust
MettaMazza Jul 1, 2026
3c4ecbb
docs: self-hosting status, shared runtime, and pure-C bootstrap instr…
MettaMazza Jul 1, 2026
5924061
feat(self-host): floats end-to-end (parity 35->36/54)
MettaMazza Jul 2, 2026
3a8f661
feat(self-host): semantic checker pass — epc now enforces hard errors…
MettaMazza Jul 2, 2026
d906d1d
feat(self-host): 'epc check <file>' subcommand (Phase 8 tooling)
MettaMazza Jul 2, 2026
c8b3e15
docs: record self-hosted parity (36/54) and epc check in README
MettaMazza Jul 2, 2026
cc813a1
feat(self-host): constant-folding optimizer + fix negative cg_int_to_…
MettaMazza Jul 2, 2026
cd77f2f
test: align epc parity output comparison with run_tests.sh (36->40/54)
MettaMazza Jul 2, 2026
2fb1a9f
chore: final polish — tree cleanup, .dSYM ignore, docs at 40/54
MettaMazza Jul 2, 2026
d591734
feat(self-host): top-level constant globals (parity 40->41/54)
MettaMazza Jul 2, 2026
94de27d
feat(self-host): sanitize C-keyword identifiers (parity 41->42/54)
MettaMazza Jul 2, 2026
1347602
feat(self-host): check on string/int literals (parity 42->44/54)
MettaMazza Jul 2, 2026
3b05540
feat(self-host): resolve all stdlib module imports (sync with Rust dr…
MettaMazza Jul 2, 2026
71f535c
feat(self-host): full English comparison-phrase aliases (parity 44->4…
MettaMazza Jul 2, 2026
9719ab2
feat(self-host): emit trait-implementation methods (parity 45->46/54)
MettaMazza Jul 2, 2026
3befd06
fix(self-host): closures and spawn share a counter (parity 46->47/54)
MettaMazza Jul 2, 2026
fc0f114
feat(self-host): try/Result unwrapping + typed check bindings (parity…
MettaMazza Jul 2, 2026
f0a4643
docs: self-hosted parity now 48/54
MettaMazza Jul 2, 2026
4d26578
fix(self-host): don't free lists that escape via return (UAF) (parity…
MettaMazza Jul 2, 2026
31d7fa8
fix(self-host): 'set x to y' is aliasing, not a move (parity 49->51/54)
MettaMazza Jul 2, 2026
cb56a79
docs: self-hosted parity 50/54 (stable)
MettaMazza Jul 2, 2026
0304b15
feat(self-host): iterator protocol for 'for each' over custom iterato…
MettaMazza Jul 2, 2026
5439ab4
fix(self-host): rely on GC for local-list cleanup (fixes transitive-e…
MettaMazza Jul 2, 2026
cd3c781
feat(self-host): auto-detect string vs int when displaying accessor r…
MettaMazza Jul 2, 2026
0465c04
fix(runtime): GC-register sqlite column text; parity stable at 52/54
MettaMazza Jul 2, 2026
53134f1
fix(runtime): wait_task_group polls thread-completed futures (task_gr…
MettaMazza Jul 2, 2026
54b028e
docs: self-hosted parity 53/54 (only nondeterministic async_loop rema…
MettaMazza Jul 2, 2026
8503865
feat(self-host): coroutine (event-loop) async — deterministic orderin…
MettaMazza Jul 2, 2026
4720841
docs: self-hosted parity 54/54 — full runnable suite passes
MettaMazza Jul 2, 2026
08d100e
fix(self-host): enum field-type check no longer triggers use-after-fr…
MettaMazza Jul 3, 2026
130cd6e
feat(transpiler,async): JS trait-impl/enum-class emission + async_wai…
MettaMazza Jul 3, 2026
91ff82a
docs: truth-up README + AGENT.md — accurate counts, zero-caveat self-…
MettaMazza Jul 3, 2026
69ae883
fix: differential-testing findings — miscompilation, grammar drift, 3…
MettaMazza Jul 3, 2026
1f8e690
fix(diagnostics): error hints match what the user wrote, not the pars…
MettaMazza Jul 3, 2026
560e607
perf(codegen): numeric functions skip GC rooting when args go to Int-…
MettaMazza Jul 3, 2026
c821d5b
test+ci: permanent differential suite (37 programs), real gates in CI…
MettaMazza Jul 3, 2026
9c07d3b
feat: MIT license + flagship demo (The Plainville Bakery) + float f-s…
MettaMazza Jul 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 41 additions & 51 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,32 @@ jobs:
- name: Run unit tests
run: cargo test --release

- name: Syntax check — test_core.ep
run: cargo run --release -- --check tests/test_core.ep
- name: Full test suite (run_tests.sh)
run: ./run_tests.sh

- name: Syntax check — test_strings.ep
run: cargo run --release -- --check tests/test_strings.ep
- name: Build the self-hosted compiler (epc)
run: ./target/release/ernos epc.ep

- name: Syntax check — test_math.ep
run: cargo run --release -- --check tests/test_math.ep
- name: Self-hosted parity + rejection suite
run: bash tests/run_epc_parity.sh

- name: Syntax check — test_data.ep
run: cargo run --release -- --check tests/test_data.ep
- name: Differential suite (ernos vs epc must agree)
run: bash tests/run_differential.sh

- name: Compile and run test_core.ep
run: |
cargo run --release -- tests/test_core.ep
./tests/test_core

- name: Compile and run test_strings.ep
run: |
cargo run --release -- tests/test_strings.ep
./tests/test_strings
- name: 3-stage self-compilation fixpoint (gen2 == gen3)
run: bash tests/run_fixpoint.sh

- name: Compile and run test_math.ep
run: |
cargo run --release -- tests/test_math.ep
./tests/test_math
- name: Clang-only bootstrap (no Rust) — build, fixpoint, freshness
run: bash bootstrap/verify.sh

- name: Compile and run test_float_ffi.ep
- name: Flagship demo — both compilers, identical output
run: |
cargo run --release -- tests/test_float_ffi.ep
./tests/test_float_ffi

- name: Compile demo — creature_quest_demo5.ep
run: cargo run --release -- demos/creature_quest_demo5.ep

- name: Syntax check — epc.ep (self-hosted compiler)
run: cargo run --release -- --check epc.ep
./target/release/ernos examples/bakery.ep
./examples/bakery > /tmp/bakery_rust.out
./epc examples/bakery.ep
./examples/bakery > /tmp/bakery_epc.out
diff /tmp/bakery_rust.out /tmp/bakery_epc.out
echo "flagship output identical across compilers"

- name: Run conformance tests
run: |
Expand Down Expand Up @@ -90,39 +79,40 @@ jobs:
uses: dtolnay/rust-toolchain@stable

- name: Install build dependencies
run: sudo apt-get update && sudo apt-get install -y gcc
run: sudo apt-get update && sudo apt-get install -y clang

- name: Build (release)
run: cargo build --release

- name: Run unit tests
run: cargo test --release

- name: Syntax check — test_core.ep
run: cargo run --release -- --check tests/test_core.ep
- name: Full test suite (run_tests.sh)
run: ./run_tests.sh

- name: Compile and run test_core.ep
run: |
cargo run --release -- tests/test_core.ep
./tests/test_core
- name: Build the self-hosted compiler (epc)
run: ./target/release/ernos epc.ep

- name: Compile and run test_strings.ep
run: |
cargo run --release -- tests/test_strings.ep
./tests/test_strings
- name: Self-hosted parity + rejection suite
run: bash tests/run_epc_parity.sh

- name: Compile and run test_math.ep
run: |
cargo run --release -- tests/test_math.ep
./tests/test_math
- name: Differential suite (ernos vs epc must agree)
run: bash tests/run_differential.sh

- name: Compile and run test_float_ffi.ep
run: |
cargo run --release -- tests/test_float_ffi.ep
./tests/test_float_ffi
- name: 3-stage self-compilation fixpoint (gen2 == gen3)
run: bash tests/run_fixpoint.sh

- name: Clang-only bootstrap (no Rust) — build, fixpoint, freshness
run: bash bootstrap/verify.sh

- name: Syntax check — epc.ep (self-hosted compiler)
run: cargo run --release -- --check epc.ep
- name: Flagship demo — both compilers, identical output
run: |
./target/release/ernos examples/bakery.ep
./examples/bakery > /tmp/bakery_rust.out
./epc examples/bakery.ep
./examples/bakery > /tmp/bakery_epc.out
diff /tmp/bakery_rust.out /tmp/bakery_epc.out
echo "flagship output identical across compilers"

- name: Run conformance tests
run: |
Expand Down
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,13 @@ tests/*
!tests/*.ep
!tests/*.expected
!tests/*.md
!tests/*.sh

# Bootstrap build output (keep the frozen C, not the binary)
/epc-bootstrapped

# Debug bundles under tests/ (the !tests/*/ negation would otherwise re-include them)
tests/**/*.dSYM/
/epc_stage1
bakery_report.txt
examples/bakery
18 changes: 15 additions & 3 deletions AGENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,21 @@ If a function isn't registered in `src/type_check.rs` (`register_builtins`) AND
```bash
# This MUST pass after any change to the type system, parser, or codegen:
cargo run -- epc.ep && ./epc tests/test_basic_math.ep && ./test_basic_math

# Stronger gates (run after any epc-visible change):
bash tests/run_fixpoint.sh # 3-stage byte-identical self-compile
bash tests/run_epc_parity.sh # self-hosted coverage scoreboard (must not regress)
bash tests/run_differential.sh # both compilers must AGREE on 37 adversarial programs
bash bootstrap/verify.sh # clang-only, Rust-free 3-stage fixpoint + parity + freshness
```

The self-hosted compiler is 5,800+ lines of real ErnosPlain that exercises the full type system, all builtin functions, list operations, string operations, struct creation, pattern matching, and closures. If it doesn't compile, you broke something.
Current state of these gates: `run_tests.sh` **71/71**, `run_epc_parity.sh` **53/53 runnable + 12/12 compile-error rejections** (0 wrongly accepted), `run_differential.sh` **37/37 agree**, `run_fixpoint.sh` byte-identical, `bootstrap/verify.sh` green.

The self-hosted compiler is ~6,400 lines of real ErnosPlain — `ep_lexer.ep` (lexer), `ep_parser.ep` (parser), `ep_check.ep` (semantic checker), `ep_optimizer.ep` (constant folding + DCE), `ep_codegen.ep` (C codegen), `epc.ep` (driver) — that exercises the full type system, all builtin functions, list/string operations, struct creation, pattern matching, closures, floats, traits, `try`/Result, and coroutine async. If it doesn't compile, you broke something.

**Shared runtime.** `runtime/ep_runtime.c` + `runtime/ep_builtins.c` are the single source of truth for the emitted C runtime. The Rust compiler embeds them via `include_str!`; the self-hosted compiler embeds them via the generated `ep_runtime_gen.ep`. After editing either `runtime/*.c` file, regenerate: `./target/release/ernos tools/gen_runtime_ep.ep && ./tools/gen_runtime_ep`.

**Bootstrap freshness.** `bootstrap/epc_bootstrap.c` is `epc` compiled by `epc`. After ANY change that alters epc's output, regenerate it in the same commit: `./epc epc.ep && cp epc_compiled.c bootstrap/epc_bootstrap.c`. `bash bootstrap/verify.sh` enforces freshness and the clang-only fixpoint.

### Rule 5: Read Source, Never Guess

Expand Down Expand Up @@ -144,7 +156,7 @@ Every language construct should read like a sentence a non-programmer could unde
Symbol shortcuts (`+`, `<`, `==`, `&&`) are allowed as opt-in shorthands for experienced programmers. The plain English form is always the primary syntax.

### Self-Hosting is Non-Negotiable
The self-hosted compiler (`epc.ep` + modules) must always compile itself using the Rust bootstrap compiler. This is the ultimate integration test. If the type checker rejects the self-hosted compiler, the type checker is too strict — not the self-hosted compiler is wrong. The self-hosted compiler is 5,800+ lines of real, working ErnosPlain. It is the language's own dogfood.
The self-hosted compiler (`epc.ep` + modules) must always compile itself using the Rust bootstrap compiler. This is the ultimate integration test. If the type checker rejects the self-hosted compiler, the type checker is too strict — not the self-hosted compiler is wrong. The self-hosted compiler is ~6,400 lines of real, working ErnosPlain. It is the language's own dogfood, and it bootstraps from a frozen C snapshot with no Rust in the loop.

### Cross-Platform by Default
Ernos must work on:
Expand Down Expand Up @@ -508,7 +520,7 @@ Usage: `import "stdlib/bridge/sqlite"` — all functions use `ep_dlopen`/`ep_dls
- Source files: `snake_case.ep`
- Test files: `tests/test_feature_name.ep` with optional `tests/test_feature_name.expected`
- Stdlib modules: `stdlib/module_name.ep`
- Self-hosted compiler: `epc.ep`, `ep_lexer.ep`, `ep_parser.ep`, `ep_codegen.ep`
- Self-hosted compiler: `epc.ep`, `ep_lexer.ep`, `ep_parser.ep`, `ep_check.ep`, `ep_optimizer.ep`, `ep_codegen.ep` (+ generated `ep_runtime_gen.ep`)
- Generated C: `filename_compiled.c` (temporary, cleaned up by compiler)
- Generated binary: `./dirname/filename` (next to source file, same stem)

Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 MettaMazza

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading