ocaml: phase 2 evaluator slice (+42 tests, 165 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 52s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 52s
ocaml-eval walks the AST and yields SX values. ocaml-run / ocaml-run-program wrap parse + eval. Coverage: atoms, vars, app (curried), 22 binary ops, prefix - and not, if/seq/tuple/list, fun (auto-curried via host SX lambdas), let, let-rec (mutable-cell knot for recursive functions). Initial env: not/succ/pred/abs/max/min/fst/snd/ignore. Tests: arithmetic, comparison, string concat, closures, fact 5 / fib 10 / sum 100, top-level decls, |> pipe.
This commit is contained in:
@@ -144,13 +144,15 @@ SX CEK evaluator (both JS and OCaml hosts)
|
||||
|
||||
### Phase 2 — Core evaluator (untyped)
|
||||
|
||||
- [ ] `ocaml-eval` entry: walks OCaml AST, produces SX values.
|
||||
- [ ] `let`/`let rec`/`let ... in` (mutually recursive with `and`).
|
||||
- [ ] Lambda + application (curried by default — auto-curry multi-param defs).
|
||||
- [ ] `fun`/`function` (single-arg lambda with immediate match on arg).
|
||||
- [ ] `if`/`then`/`else`, `begin`/`end`, sequence `;`.
|
||||
- [ ] Arithmetic, comparison, boolean ops, string `^`, `mod`.
|
||||
- [ ] Unit `()` value; `ignore`.
|
||||
- [x] `ocaml-eval` entry: walks OCaml AST, produces SX values.
|
||||
- [~] `let`/`let rec`/`let ... in` (single-binding done; mutually recursive
|
||||
`and` deferred).
|
||||
- [x] Lambda + application (curried by default — auto-curry multi-param defs).
|
||||
- [ ] `fun`/`function` (single-arg lambda with immediate match on arg). _(`fun`
|
||||
done; `function` blocked on parser support.)_
|
||||
- [x] `if`/`then`/`else`, `begin`/`end`, sequence `;`.
|
||||
- [x] Arithmetic, comparison, boolean ops, string `^`, `mod`.
|
||||
- [x] Unit `()` value; `ignore`.
|
||||
- [ ] References: `ref`, `!`, `:=`.
|
||||
- [ ] Mutable record fields.
|
||||
- [ ] `for i = lo to hi do ... done` loop; `while cond do ... done`.
|
||||
@@ -315,6 +317,16 @@ the "mother tongue" closure: OCaml → SX → OCaml. This means:
|
||||
|
||||
_Newest first._
|
||||
|
||||
- 2026-05-08 Phase 2 — `lib/ocaml/eval.sx`: ocaml-eval + ocaml-run +
|
||||
ocaml-run-program. Coverage: atoms, var lookup, :app (curried),
|
||||
:op (arithmetic/comparison/boolean/^/mod/::/|>), :neg, :not, :if,
|
||||
:seq, :tuple, :list, :fun (auto-curried host-SX closures), :let,
|
||||
:let-rec (recursive knot via one-element-list mutable cell). Initial
|
||||
env exposes `not`/`succ`/`pred`/`abs`/`max`/`min`/`fst`/`snd`/`ignore`
|
||||
as host-SX functions. Tests: literals, arithmetic, comparison, boolean,
|
||||
string concat, conditionals, lambda + closures + recursion (fact 5,
|
||||
fib 10, sum 100), sequences, top-level program decls, |> pipe. 165/165
|
||||
passing (+42).
|
||||
- 2026-05-07 Phase 1 — sequence operator `;`. Lowest-precedence binary;
|
||||
`e1; e2; e3` → `(:seq e1 e2 e3)`. Two-phase grammar: `parse-expr-no-seq`
|
||||
is the prior expression entry point; new `parse-expr` wraps it with
|
||||
|
||||
Reference in New Issue
Block a user