forth: WITHIN/ABORT/ABORT"/EXIT/UNLOOP (+7; Hayes 486/638, 76%)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-25 01:55:38 +00:00
parent b1a7852045
commit 8ca2fe3564
5 changed files with 107 additions and 9 deletions

View File

@@ -92,7 +92,7 @@ Representation:
- [x] Number formatting: `<#`, `#`, `#S`, `#>`, `HOLD`, `SIGN`, `.R`, `U.`, `U.R`
- [x] Parsing/dictionary: `WORD`, `FIND`, `EXECUTE`, `'`, `[']`, `LITERAL`, `POSTPONE`, `>BODY` (DOES> deferred — needs runtime-rebind of last CREATE)
- [x] Source/state: `EVALUATE`, `STATE`, `[`, `]` (`SOURCE`/`>IN` stubbed; tokenized input means the exact byte/offset semantics aren't useful here)
- [ ] Misc Core: `WITHIN`, `MAX`/`MIN` (already), `ABORT`, `ABORT"`, `EXIT`, `UNLOOP`
- [x] Misc Core: `WITHIN`, `MAX`/`MIN` (already), `ABORT`, `ABORT"`, `EXIT`, `UNLOOP`
- [ ] File Access word set (via SX IO)
- [ ] String word set (`SLITERAL`, `COMPARE`, `SEARCH`)
- [ ] Target: 100% Hayes Core
@@ -106,6 +106,17 @@ Representation:
_Newest first._
- **Phase 5 — `WITHIN`/`ABORT`/`ABORT"`/`EXIT`/`UNLOOP` (+7;
Hayes 477→486, 76%).** `WITHIN` uses the ANS two's-complement
trick: `(n1-n2) U< (n3-n2)`. `ABORT` wipes the data/return/control
stacks and raises — the conformance runner catches it at the
chunk boundary. `ABORT"` parses its message like `S"`, then at
runtime pops a flag and raises only if truthy. `EXIT` adds a new
`:kind "exit"` op that the PC-driven body runner treats as a
jump-to-end; added a matching cond clause in `forth-step-op`.
`UNLOOP` pops two from the return stack — usable paired with
`EXIT` to bail from inside `DO`/`LOOP`.
- **Phase 5 — `[`, `]`, `STATE`, `EVALUATE` (+5; Hayes 463→477, 74%).**
`[` (IMMEDIATE) clears `state.compiling`, `]` sets it. `STATE`
pushes the sentinel address `"@@state"` and `@` reads it as