1 \ ** ficl/softwords/softcore.fr
2 \ ** FICL soft extensions
3 \ ** John Sadler (john_sadler@alum.mit.edu)
6 \ $FreeBSD: src/sys/boot/ficl/softwords/softcore.fr,v 1.8.2.1 2000/07/06 23:51:46 obrien Exp $
8 \ ** Ficl USER variables
9 \ ** See words.c for primitive def'n of USER
12 variable nUser 0 nUser !
14 nUser dup @ user 1 swap +! ;
19 \ EMPTY cleans the parameter stack
20 : empty ( xn..x1 -- ) depth 0 ?do drop loop ;
22 : cell- ( addr -- addr ) [ 1 cells ] literal - ;
23 : -rot ( a b c -- c a b ) 2 -roll ;
27 dup 0< if negate endif ;
28 decimal 32 constant bl
30 : space ( -- ) bl emit ;
32 : spaces ( n -- ) 0 ?do space loop ;
60 false invert constant true
64 : erase ( addr u -- ) 0 fill ;
65 : nip ( y x -- x ) swap drop ;
66 : tuck ( y x -- x y x) swap over ;
67 : within ( test low high -- flag ) over - >r - r> u< ;
70 \ ** LOCAL EXT word set
71 \ #if FICL_WANT_LOCALS
72 : locals| ( name...name | -- )
75 dup 0= abort" where's the delimiter??"
80 repeat 2drop 0 0 (local)
83 : local ( name -- ) bl word count (local) ; immediate
85 : 2local ( name -- ) bl word count (2local) ; immediate
87 : end-locals ( -- ) 0 0 (local) ; immediate
91 \ ** TOOLS word set...
96 i 7 and 7 = if cr endif
100 \ ** SEARCH+EXT words and ficl helpers
105 \ DO_VOCABULARY handles the DOES> part of a VOCABULARY
106 \ When executed, new voc replaces top of search stack
107 : do-vocabulary ( -- )
108 does> @ search> drop >search ;
110 : vocabulary ( name -- )
111 wordlist create , do-vocabulary ;
113 : ficl-vocabulary ( nBuckets name -- )
114 ficl-wordlist create , do-vocabulary ;
116 \ ALSO dups the search stack...
118 search> dup >search >search ;
120 \ FORTH drops the top of the search stack and pushes FORTH-WORDLIST
123 forth-wordlist >search ;
125 \ ONLY sets the search order to a default state
129 \ ORDER displays the compile wid and the search order list
132 get-order 0 ?do x. loop cr
133 ." Compile: " get-current x. cr ;
135 \ PREVIOUS drops the search order stack
136 : previous ( -- ) search> drop ;
138 \ FICL-SET-CURRENT sets the compile wordlist and pushes the previous value
139 : ficl-set-current ( wid -- old-wid )
140 get-current swap set-current ;
142 wordlist constant hidden
143 : hide hidden dup >search ficl-set-current ;
145 \ ** E N D S O F T C O R E . F R