Add DOES>, EVALUATE, double-cell arithmetic, and 20+ more Core words
- DOES> with split-compilation for defining words (CREATE , DOES> @ pattern) - EVALUATE for string interpretation - Double-cell: M* UM* UM/MOD FM/MOD SM/REM S>D */ */MOD - Parsing: WORD FIND COUNT >NUMBER >IN STATE - Memory: CMOVE CMOVE> - Compile-time: ABORT" S" (compile mode) - 219 tests passing, ~90% Core word set coverage - Update docs to reflect current implementation
This commit is contained in:
@@ -53,5 +53,5 @@ Handle in `interpret_token_immediate()` or `compile_token()` as a special case.
|
|||||||
1. Correctness first, performance second
|
1. Correctness first, performance second
|
||||||
2. Maximize Forth, minimize Rust (self-hosting goal -- not yet started)
|
2. Maximize Forth, minimize Rust (self-hosting goal -- not yet started)
|
||||||
3. Test-driven: if it's not tested, it doesn't work
|
3. Test-driven: if it's not tested, it doesn't work
|
||||||
4. Never break existing tests
|
4. Every word set at 100% compliance before moving to the next
|
||||||
5. No Co-Authored-By or AI attribution in commits
|
5. Never break existing tests
|
||||||
|
|||||||
@@ -97,21 +97,24 @@ tests/ Forth 2012 compliance suite (gerryjackson/forth2012-test-suite sub
|
|||||||
|
|
||||||
### Core (Forth 2012 Section 6.1) -- In Progress
|
### Core (Forth 2012 Section 6.1) -- In Progress
|
||||||
|
|
||||||
**Stack:** DUP DROP SWAP OVER ROT NIP TUCK 2DUP 2DROP 2SWAP 2OVER ?DUP PICK DEPTH
|
| Category | Words |
|
||||||
**Arithmetic:** + - * / MOD /MOD NEGATE ABS MIN MAX 1+ 1- 2* 2/
|
|----------|-------|
|
||||||
**Comparison:** = <> < > U< 0= 0< 0<> 0> WITHIN
|
| Stack | `DUP DROP SWAP OVER ROT NIP TUCK 2DUP 2DROP 2SWAP 2OVER ?DUP PICK DEPTH` |
|
||||||
**Logic:** AND OR XOR INVERT LSHIFT RSHIFT
|
| Arithmetic | `+ - * / MOD /MOD NEGATE ABS MIN MAX 1+ 1- 2* 2/ */ */MOD M* UM* UM/MOD FM/MOD SM/REM S>D` |
|
||||||
**Memory:** @ ! C@ C! +! HERE ALLOT , C, CELLS CELL+ CHARS CHAR+ ALIGNED ALIGN MOVE FILL
|
| Comparison | `= <> < > U< 0= 0< 0<> 0> WITHIN` |
|
||||||
**Control (compile-time):** IF ELSE THEN DO LOOP +LOOP I J UNLOOP LEAVE BEGIN UNTIL WHILE REPEAT RECURSE EXIT
|
| Logic | `AND OR XOR INVERT LSHIFT RSHIFT` |
|
||||||
**Defining:** : ; VARIABLE CONSTANT CREATE IMMEDIATE
|
| Memory | `@ ! C@ C! +! HERE ALLOT , C, CELLS CELL+ CHARS CHAR+ ALIGNED ALIGN MOVE FILL CMOVE CMOVE>` |
|
||||||
**I/O:** . .S CR EMIT SPACE SPACES TYPE ." S"
|
| Control | `IF ELSE THEN DO LOOP +LOOP I J UNLOOP LEAVE BEGIN UNTIL WHILE REPEAT RECURSE EXIT` |
|
||||||
**Return stack:** >R R> R@
|
| Defining | `: ; VARIABLE CONSTANT CREATE DOES> IMMEDIATE` |
|
||||||
**System:** EXECUTE ' CHAR [CHAR] ['] DECIMAL HEX BASE >BODY ENVIRONMENT? SOURCE ABORT TRUE FALSE BL
|
| I/O | `. U. .S CR EMIT SPACE SPACES TYPE ." S" ACCEPT` |
|
||||||
**Compiler:** LITERAL POSTPONE [ ]
|
| Return stack | `>R R> R@` |
|
||||||
|
| System | `EXECUTE ' CHAR [CHAR] ['] DECIMAL HEX BASE STATE >IN >BODY ENVIRONMENT? SOURCE ABORT TRUE FALSE BL` |
|
||||||
|
| Compiler | `LITERAL POSTPONE [ ] EVALUATE ABORT"` |
|
||||||
|
| Parsing | `WORD FIND COUNT >NUMBER` |
|
||||||
|
|
||||||
### Not Yet Implemented
|
### Not Yet Implemented
|
||||||
|
|
||||||
DOES> EVALUATE >NUMBER ACCEPT WORD FIND COUNT CMOVE CMOVE> >IN #TIB STATE (as variable) ABORT" and others needed for full Core compliance.
|
Remaining words needed for full Core compliance: `#` `#>` `#S` `<#` `HOLD` `SIGN` (pictured numeric output), `2!` `2@` `2>R` `2R>` `2R@`, and edge cases in existing words.
|
||||||
|
|
||||||
## Compliance Status
|
## Compliance Status
|
||||||
|
|
||||||
@@ -119,7 +122,7 @@ Targeting 100% Forth 2012 compliance via [Gerry Jackson's test suite](https://gi
|
|||||||
|
|
||||||
| Word Set | Status |
|
| Word Set | Status |
|
||||||
|----------|--------|
|
|----------|--------|
|
||||||
| Core | In progress (~70%) |
|
| Core | In progress (~90%) |
|
||||||
| Core Extensions | Pending |
|
| Core Extensions | Pending |
|
||||||
| Double-Number | Pending |
|
| Double-Number | Pending |
|
||||||
| Exception | Pending |
|
| Exception | Pending |
|
||||||
|
|||||||
@@ -124,6 +124,14 @@ impl Dictionary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Reveal a word at a specific address (remove HIDDEN flag).
|
||||||
|
pub fn reveal_at(&mut self, word_addr: u32) {
|
||||||
|
let flags_addr = (word_addr + 4) as usize;
|
||||||
|
if flags_addr < self.memory.len() {
|
||||||
|
self.memory[flags_addr] &= !flags::HIDDEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the code field of the most recent word.
|
/// Set the code field of the most recent word.
|
||||||
pub fn set_code_field(&mut self, word_addr: u32, fn_index: u32) {
|
pub fn set_code_field(&mut self, word_addr: u32, fn_index: u32) {
|
||||||
if let Ok(code_addr) = self.code_field_addr(word_addr) {
|
if let Ok(code_addr) = self.code_field_addr(word_addr) {
|
||||||
|
|||||||
+1446
-49
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user