forth: [, ], STATE, EVALUATE (+5; Hayes 463→477, 74%)
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:
@@ -649,10 +649,13 @@
|
||||
(s)
|
||||
(let
|
||||
((addr (forth-pop s)))
|
||||
(if
|
||||
(string? addr)
|
||||
(forth-push s (or (get (get s "vars") addr) 0))
|
||||
(forth-push s (forth-mem-read s addr))))))
|
||||
(cond
|
||||
((= addr "@@state")
|
||||
(forth-push s (if (get s "compiling") -1 0)))
|
||||
((= addr "@@in") (forth-push s 0))
|
||||
((string? addr)
|
||||
(forth-push s (or (get (get s "vars") addr) 0)))
|
||||
(else (forth-push s (forth-mem-read s addr)))))))
|
||||
(forth-def-prim!
|
||||
state
|
||||
"!"
|
||||
@@ -788,6 +791,31 @@
|
||||
(let
|
||||
((w (forth-pop s)))
|
||||
(forth-push s (or (get w "body-addr") 0)))))
|
||||
(forth-def-prim-imm!
|
||||
state
|
||||
"["
|
||||
(fn (s) (dict-set! s "compiling" false)))
|
||||
(forth-def-prim! state "]" (fn (s) (dict-set! s "compiling" true)))
|
||||
(forth-def-prim! state "STATE" (fn (s) (forth-push s "@@state")))
|
||||
(forth-def-prim!
|
||||
state
|
||||
"EVALUATE"
|
||||
(fn
|
||||
(s)
|
||||
(let
|
||||
((u (forth-pop s)) (addr (forth-pop s)))
|
||||
(let
|
||||
((src (forth-mem-read-string s addr u)))
|
||||
(let
|
||||
((saved-input (get s "input")))
|
||||
(dict-set! s "input" (forth-tokens src))
|
||||
(forth-interpret-loop s)
|
||||
(dict-set! s "input" saved-input))))))
|
||||
(forth-def-prim!
|
||||
state
|
||||
"SOURCE"
|
||||
(fn (s) (forth-push s 0) (forth-push s 0)))
|
||||
(forth-def-prim! state ">IN" (fn (s) (forth-push s "@@in")))
|
||||
(forth-def-prim!
|
||||
state
|
||||
"WORD"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"source": "gerryjackson/forth2012-test-suite src/core.fr",
|
||||
"generated_at": "2026-04-25T00:54:55Z",
|
||||
"generated_at": "2026-04-25T01:22:10Z",
|
||||
"chunks_available": 638,
|
||||
"chunks_fed": 638,
|
||||
"total": 638,
|
||||
"pass": 463,
|
||||
"fail": 10,
|
||||
"error": 165,
|
||||
"percent": 72,
|
||||
"pass": 477,
|
||||
"fail": 14,
|
||||
"error": 147,
|
||||
"percent": 74,
|
||||
"note": "completed"
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
| chunks available | 638 |
|
||||
| chunks fed | 638 |
|
||||
| total | 638 |
|
||||
| pass | 463 |
|
||||
| fail | 10 |
|
||||
| error | 165 |
|
||||
| percent | 72% |
|
||||
| pass | 477 |
|
||||
| fail | 14 |
|
||||
| error | 147 |
|
||||
| percent | 74% |
|
||||
|
||||
- **Source**: `gerryjackson/forth2012-test-suite` `src/core.fr`
|
||||
- **Generated**: 2026-04-25T00:54:55Z
|
||||
- **Generated**: 2026-04-25T01:22:10Z
|
||||
- **Note**: completed
|
||||
|
||||
A "chunk" is any preprocessed segment ending at a `}T` (every Hayes test
|
||||
|
||||
@@ -201,6 +201,31 @@
|
||||
": A 5 ; BL WORD A FIND SWAP DROP"
|
||||
-1)))
|
||||
|
||||
(define
|
||||
forth-p5-state-tests
|
||||
(fn
|
||||
()
|
||||
(forth-p5-check-top
|
||||
"STATE @ in interpret mode"
|
||||
"STATE @"
|
||||
0)
|
||||
(forth-p5-check-top
|
||||
"STATE @ via IMMEDIATE inside compile"
|
||||
": GT8 STATE @ ; IMMEDIATE : T GT8 LITERAL ; T"
|
||||
-1)
|
||||
(forth-p5-check-top
|
||||
"[ ] LITERAL captures"
|
||||
": SEVEN [ 7 ] LITERAL ; SEVEN"
|
||||
7)
|
||||
(forth-p5-check-top
|
||||
"EVALUATE in interpret mode"
|
||||
"S\" 5 7 +\" EVALUATE"
|
||||
12)
|
||||
(forth-p5-check-top
|
||||
"EVALUATE inside def"
|
||||
": A 100 ; : B S\" A\" EVALUATE ; B"
|
||||
100)))
|
||||
|
||||
(define
|
||||
forth-p4-check-output-passthrough
|
||||
(fn
|
||||
@@ -221,6 +246,7 @@
|
||||
(forth-p5-double-tests)
|
||||
(forth-p5-format-tests)
|
||||
(forth-p5-dict-tests)
|
||||
(forth-p5-state-tests)
|
||||
(dict
|
||||
"passed"
|
||||
forth-p5-passed
|
||||
|
||||
Reference in New Issue
Block a user