Recover agent-loop progress: lua/prolog/forth/erlang/haskell phases 1-2

Salvaged from worktree-agent-* branches killed during sx-tree MCP outage:
- lua: tokenizer + parser + phase-2 transpile (~157 tests)
- prolog: tokenizer + parser + unification (72 tests, plan update lost to WIP)
- forth: phase-1 reader/interpreter + phase-2 colon/VARIABLE (134 tests)
- erlang: tokenizer + parser (114 tests)
- haskell: tokenizer + parse tests (43 tests)

Cherry-picked file contents only, not branch history, to avoid pulling in
unrelated ocaml-vm merge commits that were in those branches' bases.
This commit is contained in:
2026-04-24 16:03:00 +00:00
parent e274878052
commit 99753580b4
32 changed files with 7803 additions and 36 deletions

View File

@@ -37,18 +37,18 @@ Runtime shims in `lib/lua/runtime.sx`: `lua-truthy?`, string coercion for `..`/a
Each item: implement → tests → tick box → update progress log.
### Phase 1 — tokenizer + parser
- [ ] Tokenizer: numbers (int, float, hex), strings (short + long `[[…]]`), idents, keywords, operators, comments (`--`, `--[[…]]`)
- [ ] Parser: blocks, `local`, `if/elseif/else/end`, `while`, numeric `for`, `function`, `return`, expressions, table constructors, indexing (`.`, `[]`), calls (`f(…)`, `f:m(…)`)
- [ ] Skip for phase 1: generic `for … in …`, goto/labels, nested varargs `...`
- [ ] Unit tests in `lib/lua/tests/parse.sx`: source → expected AST
- [x] Tokenizer: numbers (int, float, hex), strings (short + long `[[…]]`), idents, keywords, operators, comments (`--`, `--[[…]]`)
- [x] Parser: blocks, `local`, `if/elseif/else/end`, `while`, numeric `for`, `function`, `return`, expressions, table constructors, indexing (`.`, `[]`), calls (`f(…)`, `f:m(…)`)
- [x] Skip for phase 1: generic `for … in …`, goto/labels, nested varargs `...`
- [x] Unit tests in `lib/lua/tests/parse.sx`: source → expected AST
### Phase 2 — transpile: control flow + arithmetic
- [ ] `lua-eval-ast` entry
- [ ] Arithmetic (Lua 5.1 semantics — `/` is float)
- [ ] Comparison + logical (short-circuit, Lua truthy)
- [ ] `..` concat with string/number coercion
- [ ] `if`, `while`, numeric `for`, `local`, assignment, blocks
- [ ] 30+ eval tests in `lib/lua/tests/eval.sx`
- [x] `lua-eval-ast` entry
- [x] Arithmetic (Lua 5.1 semantics — `/` is float)
- [x] Comparison + logical (short-circuit, Lua truthy)
- [x] `..` concat with string/number coercion
- [x] `if`, `while`, numeric `for`, `local`, assignment, blocks
- [x] 30+ eval tests in `lib/lua/tests/eval.sx`
### Phase 3 — tables + functions + first PUC-Rio slice
- [ ] `function` (anon, local, top-level), closures
@@ -82,7 +82,9 @@ Each item: implement → tests → tick box → update progress log.
_Newest first. Agent appends on every commit._
- _(awaiting phase 1)_
- 2026-04-24: lua: phase 2 transpile — arithmetic, comparison, short-circuit logical, `..` concat, if/while/repeat/for-num/local/assign. 157 total tests green.
- 2026-04-24: lua: parser (exprs with precedence, all phase-1 statements, funcbody, table ctors, method/chained calls) — 112 total tokenizer+parser tests
- 2026-04-24: lua: tokenizer (numbers/strings/long-brackets/keywords/ops/comments) + 56 tests
## Blockers