home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
RiscOS
/
APP
/
DEVS
/
FORTH
/
WIMPFO.ZIP
/
!WimpForth
/
order
< prev
next >
Wrap
Text File
|
1996-03-21
|
5KB
|
150 lines
\ Vocabulary search order specification
cr .( Loading Vocabulary support...)
\ provides WORDLIST
\ VOCABULARY name
\ ONLY
\ ALSO
\ PREVIOUS
\ ORDER
\ VOCS
\ FORTH
: #WORDLIST ( #threads -- wid )
1 16 0 do 2dup <= ?leave 2* loop nip
2 MAX DUP , VOC-LINK LINK,
HERE DUP>R OVER CELLS ALLOT
SWAP CELLS ERASE R> ;
: WORDLIST ( -- wid )
#THREADS #WORDLIST ;
warning off
: #VOCABULARY ( #threads -<name>- )
CREATE #WORDLIST DROP
DOES> BODY> VCFA>VOC CONTEXT ! VOC-ALSO ;
: VOCABULARY ( -- )
#THREADS #VOCABULARY ;
warning on
VOCABULARY ROOT
' ROOT call@ ' FORTH call! \ Patch the FORTH vocabulary to be like other vocabularies
: ALSO ( -- )
CONTEXT DUP CELL+ #VOCS 1- CELLS MOVE ;
: ONLY ( -- )
CONTEXT #VOCS CELLS ERASE ROOT ALSO VOC-ALSO ;
: PREVIOUS ( -- )
CONTEXT DUP CELL+ SWAP #VOCS 1- CELLS MOVE
CONTEXT @ 0=
IF ROOT
THEN VOC-ALSO ;
: FORTH-WORDLIST ( -- wid )
['] FORTH VCFA>VOC ;
: GET-CURRENT ( -- wid )
CURRENT @ ;
: SET-CURRENT ( wid -- )
CURRENT ! ;
: GET-ORDER ( -- widn .. wid1 n )
DEPTH >R
0 #VOCS 1-
DO CONTEXT I CELLS+ @
DUP 0=
IF DROP
THEN
-1 +LOOP DEPTH R> - ;
: SET-ORDER ( widn .. wid1 n -- )
DUP 0<
IF DROP ONLY
ELSE CONTEXT #VOCS CELLS ERASE
0
?DO CONTEXT I CELLS+ !
LOOP VOC-ALSO
THEN ;
: ORDER ( -- )
CR ." Context: " CONTEXT
#VOCS 0
DO DUP @ ?DUP
IF voc>vcfa >NAME .ID 14 ?CR
THEN CELL+
LOOP DROP
CR ." Current: " CURRENT @ voc>vcfa >NAME .ID ;
: VOCS ( -- )
cr ." Vocabularies #Threads #Words #Average"
cols 59 >
if ." #Headerbytes"
then
cr VOC-LINK @
BEGIN DUP VLINK>VOC
dup voc>vcfa call@
dup doClass =
swap do|Class = or 0=
IF dup voc>vcfa >NAME .ID 18 #tab
dup voc#threads dup>r 4 .r
0 to words-cnt
0 to header-cnt
count-voc words-cnt dup 9 .r
10 * r> / 8 .r.1
cols 59 >
if header-cnt 15 .r
then
cr
ELSE DROP
THEN @ DUP 0=
UNTIL DROP
." ----------------------------------------"
cols 59 >
if ." --------------"
then
cr ." Total System Words: " count-words 11 .r
cols 59 >
if ." Header bytes:" header-cnt 8 .r
then cr ;
ROOT DEFINITIONS
: FORTH FORTH ;
: FORTH-WORDLIST FORTH-WORDLIST ;
: SET-ORDER SET-ORDER ;
ONLY FORTH ALSO DEFINITIONS
: anyfind ( a1 -- a2 f1 ) \ find a word in any vocabulary
dup c@ 0=
if 0 exit
then
?uppercase find ?dup 0=
if context @ >r
voc-link
begin @ ?dup
while dup vlink>voc ( #threads cells - )
dup voc>vcfa @
dup doClass =
swap do|Class = or 0=
if context ! \ set voc
over find ?dup
if 2swap 2drop
r> context !
EXIT \ *** EXITS HERE ****
then
then drop
repeat 0
r> context !
then ;