kolibrios-gitea/programs/develop/SPForth/lib/ext/case.f
Kirill Lipatov (Leency) 09488af869 KolSPForth12 uploaded to SVN
git-svn-id: svn://kolibrios.org@4867 a494cfbc-eb01-0410-851d-a64ba20cac60
2014-04-21 19:22:58 +00:00

43 lines
867 B
Forth

\ Ęîíńňđóęöč˙ âűáîđŕ CASE
\ ń ó÷ĺňîě âîçěîćíîé âëîćĺííîńňč îďĺđŕňîđîâ CASE
DECIMAL
VARIABLE CSP \ Óęŕçŕňĺëü ńňĺęŕ ęîíňđîë˙
6 CONSTANT L-CAS# \ Äîďóńňčěűé óđîâĺíü âëîćĺííîńňč
CREATE S-CSP L-CAS# CELLS ALLOT \ Ńňĺę ęîíňđîë˙
S-CSP CSP !
: +CSP ( -> P) \ Äîáŕâčňü óđîâĺíü
CSP @ DUP CELL+ CSP !
;
: -CSP ( -> ) \ Óáđŕňü óđîâĺíü
CSP @ 1 CELLS - CSP !
;
: !CSP ( -> ) \ Číčöčŕëčçčđîâŕňü óđîâĺíü
SP@ +CSP !
;
: CSP@ ( -> A)
CSP @ 1 CELLS - @
;
: ?CSP ( -> ) \ Ďđîâĺđčňü âűäĺđćŕííîńňü ńňĺęŕ
\ SP@ CSP@ <> 37 ?ERROR ( ABORT" Ńáîé ńňĺęŕ ďî CSP !")
-CSP
;
: CASE ( -> )
!CSP
; IMMEDIATE
: OF
POSTPONE OVER POSTPONE =
[COMPILE] IF POSTPONE DROP
; IMMEDIATE
: ENDOF
[COMPILE] ELSE
; IMMEDIATE
: ENDCASE
POSTPONE DROP BEGIN SP@ CSP@ =
0= WHILE [COMPILE] THEN REPEAT -CSP
; IMMEDIATE