plans: Phase 7 — end-to-end pipeline + close gaps (operators in eval-ast, :quad-name, idiom expansion, :Trap)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 33s

This commit is contained in:
2026-05-07 11:46:42 +00:00
parent d755caeb9a
commit 52df09655d

View File

@@ -104,6 +104,35 @@ Core mapping:
- [x] Drive corpus to 100+ green
- [x] Idiom corpus — `lib/apl/tests/idioms.sx` covering classic Roger Hui / Phil Last idioms
### Phase 7 — end-to-end pipeline + closing the gaps
Phase 1-6 built parser and runtime as parallel layers — they don't yet meet.
Phase 7 wires them together so APL source actually runs through the full stack,
and tightens loose ends.
- [ ] **Operators in `apl-eval-ast`** — handle `:derived-fn` (e.g. `+/`, `f¨`),
`:outer` (`∘.f`), `:derived-fn2` (`f.g`). Each derived-fn-node wraps an inner
function; eval-ast resolves the inner glyph to a runtime fn and dispatches
to the matching operator helper (`apl-reduce`, `apl-each`, `apl-outer`,
`apl-inner`, `apl-commute`, `apl-compose`, `apl-power`, `apl-rank`).
- [ ] **End-to-end pipeline** — entry point `apl-run : string → array` that
chains `apl-tokenize``parse-apl``apl-eval-ast` against an empty env.
Verify with one-liners (`+/5` → 15, `1 2 3 + 4 5 6` → 7 9 11, etc.) and
with the actual `.apl` source files in `tests/programs/`.
- [ ] **`:quad-name` AST + handler** — extend tokenizer/parser to recognise
`⎕name`, then handle in `apl-eval-ast` by dispatching to `apl-quad-*`
runtime fns (`⎕IO`, `⎕ML`, `⎕FR`, `⎕TS`, `⎕FMT`, `⎕←`).
- [ ] **Bracket indexing verification** — load programs that use `A[I]` /
`A[I;J]` end-to-end; confirm parser desugars to `⌷` and runtime returns
expected slices. Add 5+ tests.
- [ ] **Idiom corpus expansion** — extend `idioms.sx` from 34 to 60+ once
end-to-end works (we can express idioms as APL strings, not as runtime
calls). Source-string-based idioms validate the whole stack.
- [ ] **`:Trap` / `:EndTrap`** — minimal exception machinery: `:Trap n`
catches errors with code `n`, body runs in `apl-tradfn-eval-block`,
on error switches to the trap branch. Define `apl-throw` and a small
set of error codes; use `try`/`catch` from the host.
## SX primitive baseline
Use vectors for arrays; numeric tower + rationals for numbers; ADTs for tagged data;
@@ -118,6 +147,7 @@ data; format for string templating.
_Newest first._
- 2026-05-07: Phase 7 added — end-to-end pipeline, operators in eval-ast, :quad-name, bracket-indexing verify, idiom expansion, :Trap; aim is to wire parser↔runtime so .apl source files actually run
- 2026-05-07: Phase 6 idiom corpus — lib/apl/tests/idioms.sx; 34 classic idioms (sum, mean, max/min/range, scan, sort, reverse, first/last, take/drop, tally, mod, identity matrix, mult-table, factorial, parity count, all/any, mean-centered, ravel, rank); **all unchecked items in plan now ticked**; 362/362
- 2026-05-07: Phase 6 system fns + 100+ corpus — apl-quad-{io,ml,fr,ts,fmt,print}; ⎕FMT formats scalar/vector/matrix; ⎕TS returns 7-vector (epoch default); 328 tests >> 100 target; **drive-to-100 ticked**; +13 tests
- 2026-05-07: Phase 6 quicksort — recursive less/eq/greater partition via apl-compress, deterministic-pivot variant; tests cover empty/single/sorted/reverse/duplicates/negatives; **all 5 classic programs done**; +9 tests; 315/315