From 24e1a862fb5ab5ffaa9b42eadb37c7558b5a6c4b Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 1 May 2026 18:58:11 +0000 Subject: [PATCH] =?UTF-8?q?plan:=20tick=20Phase=2019=20regexp=20=E2=80=94?= =?UTF-8?q?=20complete,=20Phase=2020=20next?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- plans/agent-briefings/primitives-loop.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plans/agent-briefings/primitives-loop.md b/plans/agent-briefings/primitives-loop.md index 5df27ccc..4947c78b 100644 --- a/plans/agent-briefings/primitives-loop.md +++ b/plans/agent-briefings/primitives-loop.md @@ -583,15 +583,15 @@ Primitives to add: - Reader syntax: `#/pattern/flags` for regexp literals (parser addition) Steps: -- [ ] Audit `lib/js/regex.sx` — understand the API it already exposes; map to the +- [x] Audit `lib/js/regex.sx` — understand the API it already exposes; map to the primitive API above. -- [ ] Spec: add `SxRegexp` type to evaluator; add `#/pattern/flags` literal syntax to +- [x] Spec: add `SxRegexp` type to evaluator; add `#/pattern/flags` literal syntax to `spec/parser.sx`; wire `lib/js/regex.sx` engine as the implementation. -- [ ] OCaml: implement using OCaml `Re` library (or `Str`); add `SxRegexp` to types. -- [ ] JS bootstrapper: use native JS `RegExp`; wrap in the primitive API. -- [ ] Tests: 30+ tests in `spec/tests/test-regexp.sx` — basic match, groups, replace, +- [x] OCaml: implement using OCaml `Re` library (or `Str`); add `SxRegexp` to types. +- [x] JS bootstrapper: use native JS `RegExp`; wrap in the primitive API. +- [x] Tests: 30+ tests in `spec/tests/test-regexp.sx` — basic match, groups, replace, replace-all, split, flags (case-insensitive), no-match nil return. -- [ ] Commit: `spec: regular expressions (make-regexp/regexp-match/regexp-replace + #/pat/ literals)` +- [x] Commit: `spec: regular expressions (make-regexp/regexp-match/regexp-replace + #/pat/ literals)` --- @@ -751,6 +751,7 @@ _Newest first._ - 2026-04-25: Phase 1 spec step done — all 10 vector primitives in spec/primitives.sx have full :as type annotations, :returns, :doc; make-vector optional fill param added. - 2026-04-25: Phase 1 OCaml step done — bounds-checked vector-ref/set!, vector-copy now accepts optional start/end, spec/primitives.sx doc updated. 10/10 r7rs vector tests pass, 4747 total (394 pre-existing hs-upstream fails unchanged). - 2026-04-25: Phase 0 complete — stopped CL/APL/Ruby/Tcl loops (all 4 idle at shell); confirmed E38 (tokenizer :end/:line) and E39 (WebWorker stub) both have implementation commits. +- 2026-05-01: Phase 19 complete — regular expressions. SxRegexp(src,flags,Re.re) in OCaml via Re.Pcre; SxRegexp wrapper around JS RegExp. 9 primitives: make-regexp, regexp?, regexp-source, regexp-flags, regexp-match, regexp-match-all, regexp-replace, regexp-replace-all, regexp-split. Match dicts with :match/:start/:end/:groups. 32 tests, all pass. JS 2503, OCaml 4693. d8d5588e. - 2026-05-01: Phase 18 complete — sets. SxSet as (string,value) Hashtbl keyed by inspect(val) in OCaml; Map keyed by write-to-string in JS. 13 primitives: make-set, set?, set-add!, set-member?, set-remove!, set-size, set->list, list->set, set-union, set-intersection, set-difference, set-for-each, set-map. 33 tests, all pass. JS 2469, OCaml 4659. 3b0ac67a. - 2026-05-01: Phase 17 complete — read/write/display. OCaml: sx_write_val/sx_display_val helpers; read via Sx_parser.read_value with #t/#f and N/D rational support added to parser; postprocess ()→Nil. JS: sxReadNormalize (#t/#f→true/false), sxReadConvert (()→NIL), sxEq list equality, sxWriteVal symbol/keyword name fix (v.name not v._sym), readerMacroGet registry. 42 tests (test-read-write.sx), all pass both hosts. JS 2436, OCaml 4626. 7d329f02. - 2026-05-01: Phase 16 complete — rational numbers. SxRational type in OCaml (Rational of int*int, reduced, denom>0) and JS (SxRational class, _rational marker). n/d reader in spec/parser.sx. Arithmetic contagion: int op rational → rational, rational op float → float. JS keeps int/int → float for CSS compat. OCaml as_number+safe_eq extended for cross-type rational equality. 62 tests in test-rationals.sx, all pass. JS 2232, OCaml 4532 (+11). 036022cc.