ocaml: phase 1+6 Buffer + parser !x in app args (+3 tests, 425 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 48s

Parser fix: at-app-start? and parse-app's loop recognise prefix !
as a deref of the next app arg. So 'List.rev !b' parses as
'(:app List.rev (:deref b))' instead of stalling at !.

Buffer module backed by a ref holding string list:
  create _ = ref []
  add_string b s = b := s :: !b
  contents b = String.concat "" (List.rev !b)
  add_char/length/clear/reset
This commit is contained in:
2026-05-08 16:16:52 +00:00
parent dbe3c6c203
commit 2f271fa6a6
4 changed files with 39 additions and 3 deletions

View File

@@ -264,6 +264,9 @@ SX CEK evaluator (both JS and OCaml hosts)
- [~] `Hashtbl`: `create`, `add`, `find`, `find_opt`, `replace`, `mem`,
`length`. Backed by a one-element list cell holding a SX dict;
keys coerced to strings via `str` for polymorphic-key support.
- [~] `Buffer`: `create`, `add_string`, `add_char`, `contents`, `length`,
`clear`, `reset`. Backed by a ref holding a list of strings; reverse +
`String.concat` on `contents`. Mostly-OCaml impl.
- [~] `Sys`: `os_type` (`"SX"`), `word_size`, `max_array_length`,
`max_string_length`, `executable_name`, `big_endian`, `unix`,
`win32`, `cygwin`. Constants only; `argv`/`getenv_opt`/`command`
@@ -386,6 +389,11 @@ the "mother tongue" closure: OCaml → SX → OCaml. This means:
_Newest first._
- 2026-05-08 Phase 1+6 — Buffer module + parser fix for `f !x` (+3
tests, 425 total). Parser: at-app-start? and parse-app's loop now
recognise `!` as the prefix-deref of an application argument, so
`String.concat "" (List.rev !b)` parses as `(... (deref b))`. Buffer
uses a ref holding a string list; contents reverses and concats.
- 2026-05-08 Phase 5.1 — word_count.ml baseline (10/10 pass). Uses
Map.Make(StrOrd) + List.fold_left to count word frequencies; tests
the full functor pipeline with a real OCaml idiom.