1 \ ** ficl/softwords/softcore.fr
2 \ ** FICL soft extensions
3 \ ** John Sadler (john_sadler@alum.mit.edu)
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 ;
51 : erase ( addr u -- ) 0 fill ;
52 : nip ( y x -- x ) swap drop ;
53 : tuck ( y x -- x y x) swap over ;
54 : within ( test low high -- flag ) over - >r - r> u< ;
57 \ ** LOCAL EXT word set
58 \ #if FICL_WANT_LOCALS
59 : locals| ( name...name | -- )
62 dup 0= abort" where's the delimiter??"
67 repeat 2drop 0 0 (local)
70 : local ( name -- ) bl word count (local) ; immediate
72 : end-locals ( -- ) 0 0 (local) ; immediate
76 \ ** TOOLS word set...
81 i 7 and 7 = if cr endif
85 \ ** SEARCH+EXT words and ficl helpers
90 \ DO_VOCABULARY handles the DOES> part of a VOCABULARY
91 \ When executed, new voc replaces top of search stack
92 : do-vocabulary ( -- )
93 does> @ search> drop >search ;
95 : vocabulary ( name -- )
96 wordlist create , do-vocabulary ;
98 : ficl-vocabulary ( nBuckets name -- )
99 ficl-wordlist create , do-vocabulary ;
101 \ ALSO dups the search stack...
103 search> dup >search >search ;
105 \ FORTH drops the top of the search stack and pushes FORTH-WORDLIST
108 forth-wordlist >search ;
110 \ ONLY sets the search order to a default state
114 \ ORDER displays the compile wid and the search order list
117 get-order 0 ?do x. loop cr
118 ." Compile: " get-current x. cr ;
120 \ PREVIOUS drops the search order stack
121 : previous ( -- ) search> drop ;
123 \ FICL-SET-CURRENT sets the compile wordlist and pushes the previous value
124 : ficl-set-current ( wid -- old-wid )
125 get-current swap set-current ;
127 wordlist constant hidden
128 : hide hidden dup >search ficl-set-current ;
130 \ ** E N D S O F T C O R E . F R