Commit Graph

326 Commits

Author SHA1 Message Date
ab66b29a74 cl: Phase 3 classic programs — restart-demo (7 tests) + parse-recover (6 tests)
restart-demo.sx: safe-divide with division-by-zero condition, use-zero
and retry restarts. Demonstrates handler-bind invoking a restart to
resume computation with a corrected value.

parse-recover.sx: token parser signalling parse-error on non-integer
tokens, skip-token and use-zero restarts. Demonstrates recovery-via-
restart and handler-case abort patterns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 11:16:35 +00:00
32a82a2e12 cl: unwind-protect — 8 new tests (159 eval, 331 total green)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 44s
cl-eval-unwind-protect evaluates protected form, runs cleanup via
for-each (results discarded, sentinels preserved), returns original
result — correctly propagates block-return/go-tag through cleanup.
2026-05-05 11:14:39 +00:00
7d6df6fd5f cl: Phase 3 conditions + restarts — handler-bind, handler-case, restart-case, 55 tests (123 total runtime)
define-condition with 15-type ANSI hierarchy (condition/error/warning/
simple-error/simple-warning/type-error/arithmetic-error/division-by-zero/
cell-error/unbound-variable/undefined-function/program-error/storage-condition).

cl-condition-of-type? walks the hierarchy; cl-make-condition builds tagged
dicts {:cl-type "cl-condition" :class name :slots {...}}. cl-signal-obj
walks cl-handler-stack for non-unwinding dispatch. cl-handler-case and
cl-restart-case use call/cc escape continuations for unwinding. All stacks
are mutable SX globals (the built-in handler-bind/restart-case only accept
literal AST specs — not computed lists). Key fix: cl-condition-of-type?
captures cl-condition-classes at define-time via let-closure to avoid
free-variable failure through env_merge parent chain.

55 tests in lib/common-lisp/tests/conditions.sx, wired into test.sh.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 11:14:04 +00:00
fd16776dd2 cl: unwind-protect — cleanup frame in cl-eval-ast, 8 new tests (159 eval)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-05 11:13:53 +00:00
a12a6a11cb cl: tagbody + go — 11 new tests (151 eval, 323 total green)
Sentinel-based tagbody: cl-build-tag-map indexes tags by str-normalised key
(handles integer tags); cl-eval-tagbody loops with go-jump restart;
go-tag propagates through cl-eval-body alongside block-return.
2026-05-05 11:07:43 +00:00
ce7243a1fb cl: block + return-from — 13 new tests (140 eval, 312 total green)
Sentinel propagation in cl-eval-body; cl-eval-block catches matching
sentinels; BLOCK/RETURN-FROM/RETURN dispatch added to cl-eval-list.
Parser: CL strings now {:cl-type "string"} dicts for proper CL semantics.
2026-05-05 10:57:33 +00:00
3f8fe41d4d Merge architecture into loops/common-lisp 2026-05-05 10:47:02 +00:00
086ad028ce Merge loops/erlang into architecture — 530/530 tests, all phases complete 2026-05-05 10:42:07 +00:00
97ccd61f74 Merge loops/smalltalk into architecture — 847/847 tests, all phases complete 2026-05-05 10:41:58 +00:00
8019e5725b phase 22 forth: bitwise/string-buffer/memory in lib/forth/runtime.sx (36 forms), 64/64 tests 2026-05-01 23:30:48 +00:00
3e07727d6b phase 22 tcl: string-buffer/channel/regexp/format/coroutine in lib/tcl/runtime.sx (37 forms), 56/56 tests 2026-05-01 23:24:56 +00:00
182e6f63ef phase 22 ruby: Hash/Set/Regexp/StringIO/Bytevectors/Fiber in lib/ruby/runtime.sx (61 forms), 76/76 tests 2026-05-01 23:18:04 +00:00
912de5a274 phase-22 APL: runtime.sx vectors/bitwise/sets/reduce/format
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 34s
lib/apl/runtime.sx (60 forms):
- Core: apl-iota (1..N), apl-rho (shape), apl-at (1-indexed access).
- Rank-polymorphic apl-dyadic/apl-monadic helpers: scalar×scalar,
  scalar×vector, vector×vector all supported uniformly.
- Arithmetic: add/sub/mul/div/mod/pow/max/min, neg/abs/floor/ceil/sqrt.
- Comparison: eq/neq/lt/le/gt/ge → 0/1 result vectors.
- Boolean: and/or/not on 0/1 values, element-wise.
- Bitwise: bitand/bitor/bitxor/bitnot/lshift/rshift — element-wise.
- Reduction: reduce-add/mul/max/min/and/or; scan-add/mul.
- Vector ops: reverse, cat (scalar/vector catenate), take (±N), drop (±N),
  rotate, compress (boolean mask), index (multi-index).
- Set ops: member (∊, → 0/1), nub (∪, unique preserve-order),
  union, intersect (∩), without (~). All use SX make-set internally.
- Format (⍕): vector → space-separated string, scalar → str.

lib/apl/tests/runtime.sx + lib/apl/test.sh: 73/73 pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 22:49:38 +00:00
077f4a5d38 phase-22 Smalltalk: runtime.sx numeric/char/Array/Dict/Set/Stream
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 36s
lib/smalltalk/runtime.sx (72 forms):
- Numeric helpers: abs/max/min/gcd/lcm/quo/rem/mod/even?/odd?/floor/ceil/truncate/round.
- Character: st-char-value/from-int/is-letter?/is-digit?/uppercase?/lowercase?/
  separator?/as-uppercase/as-lowercase/digit-value. SX chars via char->integer.
- Array: 1-indexed mutable arrays backed by dict {__st_array__ size "1" v1 ...};
  at/at-put!/do/->list/list->array/copy-from-to.
- Dictionary: any-key hash map via list-of-pairs + linear scan;
  at/at-put!/includes-key?/at-default/remove-key!/keys/values/do/do-associations.
- Set: backed by SX make-set; set-member?/add!/includes?/remove! take (set item) order.
- WriteStream/ReadStream: dict-backed buffers; printString for nil/bool/number/
  string/symbol/char/list/array.

lib/smalltalk/tests/runtime.sx + lib/smalltalk/test.sh: 86/86 pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 22:43:04 +00:00
36e6762539 phase-22 JS: stdlib.sx bitwise/Map/Set/RegExp + 25 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 38s
lib/js/stdlib.sx (36 forms):
- Bitwise ops (js-bitand/bitor/bitxor/lshift/rshift/urshift/bitnot) use
  truncate instead of js-num-to-int (which calls integer /0 and crashes).
- Map class: dict-backed list-of-pairs with linear-scan find, mutable via
  dict-set!; js-map-new/get/set!/has/delete!/clear/keys/vals/entries/for-each.
- Set class: backed by SX make-set primitive; set-member?/set-add!/set-remove!
  all take (set item) argument order — fixed from (item set) which threw.
- RegExp: callable lambda wrapping js-regex-new (not a dict, so directly callable).
- Wires Map/Set/RegExp into js-global.

lib/js/test.sh: epochs 6000-6032 (25 tests) — all pass.
Result: 492/585 tests pass (was 466/560 before this phase).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 22:33:27 +00:00
c02ffcf316 phase 22 Haskell: runtime.sx + 143 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
lib/haskell/runtime.sx (113 forms): numeric type class helpers
(hk-div/mod/rem/quot floor semantics), rational numbers (dict-based,
GCD-normalised), hk-force for lazy promises, Data.Char (hk-ord/chr,
inline ASCII predicates, digit-to-int), Data.Set wrappers, Data.List
(take/drop/zip/nub/foldl/foldr/scanl/etc), Maybe/Either ADTs, tuple
helpers (hk-pair/fst/snd/curry/uncurry), string helpers (words/lines/
is-prefix-of/is-infix-of/etc), hk-show.

test.sh updated to pre-load runtime.sx alongside tokenizer.sx.
143/143 runtime tests + 5/5 parse tests = 148/148 total.
2026-05-01 21:41:11 +00:00
3c0a963229 erlang-runtime: add lib/erlang/runtime.sx + test.sh (55/55 pass)
Numeric tower (is-integer?/float?/number?, float/trunc/round/abs/max/min),
div/rem (quotient/remainder), bitwise (band/bor/bxor/bnot/bsl/bsr),
sets module (new/add/member/union/intersection/subtract/size/to-list/from-list),
re module (run/replace/replace-all/match-groups/split),
list BIFs (hd/tl/length/member/reverse/nth/foldl/foldr/seq/flatten/zip),
type conversions (integer-to-list, list-to-integer, atom-to-list, etc.),
ok/error tuple helpers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 21:21:39 +00:00
ec3512d63b lua-runtime: add math/string/table stdlib + delay/force (185/185 pass)
math: abs/ceil/floor/sqrt/sin/cos/tan/asin/acos/atan/exp/log/max/min/pi/huge
string: len/sub/upper/lower/rep/reverse/byte/char/find/match/gmatch/gsub
table: insert/remove/concat/sort
lua-force: force promises (delay thunk protocol)
Fix lua-len: replace has? (unavailable in sx_server) with nil-check.
Fix string.byte: use string->list to get char type, not nth on string.
Fix string.char: truncate float codes before integer->char.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 21:14:14 +00:00
1ad8e74aa6 cl-runtime: add lib/common-lisp/runtime.sx + test.sh (68/68 pass)
Type predicates, arithmetic, chars (inline α/digit/case),
format, gensym, values, sets, radix, list utilities.
cl-empty? guards all list traversal against () vs nil in sx_server.
Load spec/stdlib.sx in test.sh to expose format.
Fix lib/r7rs.sx number->string to use (= (len r) 0) not (nil? r).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 21:00:22 +00:00
4d7b3e299c spec: format — CL-style string formatting (~a ~s ~d ~x ~o ~b ~f ~% ~& ~~ ~t)
28 tests, passes on both JS and OCaml.
- spec/stdlib.sx: pure SX format function
- spec/primitives.sx: format primitive declaration
- lib/r7rs.sx: fix number->string to support optional radix arg
- hosts/ocaml: add format-decimal primitive, load stdlib.sx in test runner
- hosts/javascript: load stdlib.sx in test runner

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 19:58:54 +00:00
4da91bb9b4 cl: Phase 2 eval — 127 tests, 299 total green
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 12s
lib/common-lisp/eval.sx: cl-eval-ast implementing quote, if, progn,
let/let*, flet, labels, setq/setf, function, lambda, the, locally,
eval-when, defun, defvar/defparameter/defconstant, built-in arithmetic
(+/-/*//, min/max/abs/evenp/oddp), comparisons, predicates, list ops,
string ops, funcall/apply/mapcar.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 18:58:48 +00:00
f247cb2898 js: let/const TDZ infrastructure — sentinel + kind threading in transpiler
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 11s
Threads declaration kind ("var"/"let"/"const") through js-transpile-var →
js-vardecl-forms so the transpiler knows which kind is being declared.
Infrastructure for full TDZ enforcement: js-tdz-check can wrap let/const
reads to raise TypeError before initialization.

Updates plans/js-on-sx.md: ticks [x] for TDZ, marks regex blocker RESOLVED,
adds progress log entry for 2026-04-25.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 18:35:32 +00:00
f8023cf74e js: regex engine (lib/js/regex.sx) — pure-SX recursive backtracker
Adds a full regex engine written in SX, installed via js-regex-platform-override!.
Supports char classes (.  \d\D\w\W\s\S  [abc]  [^abc]  ranges), anchors (^ $ \b \B),
quantifiers (* + ? {n,m} greedy and lazy), capturing/non-capturing groups,
alternation (a|b), flags i/g/m.  exec() returns {:match :index :input :groups}.

Also fixes String.prototype.match to dispatch through the platform engine
(was calling js-regex-stub-exec directly, bypassing regex.sx).
Adds TDZ sentinel infrastructure: __js_tdz_sentinel__, js-tdz?, js-tdz-check.
Updates test.sh (+34 regex tests + 4 TDZ infra tests), conformance.sh,
and test262-runner.py to load regex.sx as epoch 6.

Tests: 559/560 unit (1 pre-existing failure), 148/148 conformance.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 18:35:23 +00:00
cdee007185 cl: Phase 1 lambda-list parser + 31 tests (172 total green)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 18:26:58 +00:00
bcf6057ac5 common-lisp: Phase 1 reader + 62 tests (141 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
lib/common-lisp/parser.sx — cl-read/cl-read-all: lists, dotted
pairs (a . b) → cons dict, quote/backquote/unquote/splice as
wrapper lists, #' → FUNCTION, #(…) → vector dict, #:foo →
uninterned dict, NIL→nil, T→true, integer radix conversion
(#xFF/#b1010/#o17). Floats/ratios kept as annotated dicts.

lib/common-lisp/tests/parse.sx — 62 tests, all green.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 18:15:07 +00:00
13d0ebcce8 common-lisp: Phase 1 tokenizer + 79 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
lib/common-lisp/reader.sx — CL tokenizer: symbols with package
qualification (pkg:sym/pkg::sym), integers, floats, ratios, hex/
binary/octal (#xFF/#b1010/#o17), strings with escapes, #\ char
literals (named + bare), reader macros (#' #( #: ,@), line and
nested block comments.

lib/common-lisp/tests/read.sx — 79 tests, all green.
lib/common-lisp/test.sh — test runner (sx_server pipe protocol).

Key SX gotcha: use str not concat for string building.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 18:06:30 +00:00
7e7a9c06e9 smalltalk: GNU Smalltalk compare harness; all briefing checkboxes done
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 11s
2026-04-25 16:32:26 +00:00
75032c5789 smalltalk: block intrinsifier (8 idioms) + 24 tests -> 847/847
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 16:10:27 +00:00
df62c02a21 smalltalk: per-call-site inline cache + 10 IC tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 15:30:36 +00:00
5d369daf2b smalltalk: ANSI X3J20 validator subset + 62 tests -> 813/813
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 14:48:47 +00:00
446a0e7d68 smalltalk: Pharo Kernel/Collections-Tests slice (91 tests) -> 751/751
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 14:14:11 +00:00
0ca664b81c smalltalk: SUnit port (TestCase/TestSuite/TestResult/TestFailure) + 19 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 13:43:18 +00:00
fa600442d6 smalltalk: String>>format: + universal printOn: + 18 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 13:11:17 +00:00
15da694c0d smalltalk: Number tower (Fraction, factorial, gcd:/lcm:, etc.) + 47 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 12:31:05 +00:00
47249900f2 smalltalk: Stream hierarchy + 21 tests; test.sh timeout 60s -> 180s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 12:02:37 +00:00
496447ae36 smalltalk: HashedCollection/Set/Dictionary/IdentityDictionary + 29 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 11:27:00 +00:00
3be722d5b6 smalltalk: SequenceableCollection methods (13) + String at:/copyFrom:to: + 28 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 10:58:08 +00:00
0b5f3c180e smalltalk: Exception/on:do:/ensure:/ifCurtailed: + 15 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 10:31:59 +00:00
fdd8e18cc3 smalltalk: Object>>becomeForward: + 6 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 09:54:40 +00:00
3e83624317 smalltalk: Behavior>>compile: + addSelector:/removeSelector: + 9 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 09:30:18 +00:00
1c4ac47450 smalltalk: respondsTo:/isKindOf:/isMemberOf: + 26 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 09:06:40 +00:00
4ced16f04e smalltalk: Object>>perform: family + 10 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 08:42:08 +00:00
9954a234ae smalltalk: reflection accessors (Object>>class, methodDict, selectors)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 08:18:32 +00:00
44dc32aa54 erlang: round-out BIFs (+40 tests), full plan ticked at 530/530
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 10s
2026-04-25 08:06:17 +00:00
ae94a24de5 smalltalk: conformance.sh + scoreboard.{json,md}
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 07:54:48 +00:00
a8cfd84f18 erlang: ETS-lite (+13 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 07:32:24 +00:00
5ef07a4d8d smalltalk: Conway Life + dynamic-array literal {…}; classic corpus complete
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 07:31:47 +00:00
7c5c49c529 smalltalk: mandelbrot + literal-array mutability fix
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 06:57:03 +00:00
ce8ff8b738 erlang: binary pattern matching <<...>> (+21 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 06:54:58 +00:00
a446d31d0d smalltalk: quicksort classic program + 9 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
2026-04-25 06:30:27 +00:00