forth: String word set COMPARE/SEARCH/SLITERAL (+9)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -94,7 +94,7 @@ Representation:
|
||||
- [x] Source/state: `EVALUATE`, `STATE`, `[`, `]` (`SOURCE`/`>IN` stubbed; tokenized input means the exact byte/offset semantics aren't useful here)
|
||||
- [x] Misc Core: `WITHIN`, `MAX`/`MIN` (already), `ABORT`, `ABORT"`, `EXIT`, `UNLOOP`
|
||||
- [x] File Access word set (in-memory — `read-file` is not reachable from the epoch eval env)
|
||||
- [ ] String word set (`SLITERAL`, `COMPARE`, `SEARCH`)
|
||||
- [x] String word set (`SLITERAL`, `COMPARE`, `SEARCH`)
|
||||
- [ ] Target: 100% Hayes Core
|
||||
|
||||
### Phase 6 — speed
|
||||
@@ -106,6 +106,17 @@ Representation:
|
||||
|
||||
_Newest first._
|
||||
|
||||
- **Phase 5 — String word set `COMPARE`/`SEARCH`/`SLITERAL` (+9).**
|
||||
`COMPARE` walks bytes via the new `forth-compare-bytes-loop`,
|
||||
returning -1/0/1 with standard prefix semantics (shorter string
|
||||
compares less than its extension). `SEARCH` scans the haystack
|
||||
with a helper `forth-search-bytes` and `forth-match-at`, returning
|
||||
the tail after the first match or the original string with flag=0.
|
||||
Empty needle returns at offset 0 with flag=-1 per ANS. `SLITERAL`
|
||||
is IMMEDIATE: pops `(c-addr u)` at compile time, copies the bytes
|
||||
into a fresh allocation, and emits the two pushes so the compiled
|
||||
word yields the interned string at runtime.
|
||||
|
||||
- **Phase 5 — File Access word set (in-memory backing; +4).**
|
||||
`OPEN-FILE`/`CREATE-FILE`/`CLOSE-FILE`/`READ-FILE`/`WRITE-FILE`/
|
||||
`FILE-POSITION`/`FILE-SIZE`/`REPOSITION-FILE`/`DELETE-FILE` plus
|
||||
|
||||
Reference in New Issue
Block a user