Fixing a bug in CASE.

This commit is contained in:
Brad Nelson
2022-11-08 19:42:44 -08:00
parent 23ec00d7cd
commit 4751b31c40
2 changed files with 20 additions and 3 deletions

View File

@ -17,9 +17,9 @@ variable cases
forth definitions internals
: CASE ( n -- ) cases @ 0 cases ! ; immediate
: ENDCASE cases @ for aft postpone then then next
cases ! postpone drop ; immediate
: OF ( n -- ) postpone over postpone = postpone if ; immediate
: ENDCASE postpone drop cases @ for aft postpone then then next
cases ! ; immediate
: OF ( n -- ) postpone over postpone = postpone if postpone drop ; immediate
: ENDOF 1 cases +! postpone else ; immediate
forth definitions

View File

@ -46,3 +46,20 @@ e: test-case-dup
3 foo
out: other: 3
;e
e: test-case-string
: foo
case
1 of s" one" endof
2 of s" two" endof
1 of s" onemore" endof
>r s" other" r>
endcase
;
1 foo type cr
out: one
2 foo type cr
out: two
3 foo type cr
out: other
;e