Still messing around with vocabs.
[forth.jl.git] / src / lib_9_vocab.4th
1 \ Vocabulary management
2
3 : FORGET
4         BL WORD FIND >LINK  ( find the word, gets the dictionary entry address )
5         DUP @ LATEST !      ( set LATEST to point to the previous word )
6         H !                 ( and store H with the dictionary address )
7 ;
8
9 : HIDE
10         BL WORD FIND DROP >NAME
11         DUP @ F_HIDDEN OR SWAP !
12 ;
13
14 : VOCAB>LATEST ( vcfa -- vlatest )
15         1+ @ @ ;
16
17 : ALSO
18         context #context @ + dup 1- @ swap !
19         1 #context +!
20 ;
21
22 \ Create new vocabulary
23 : VOCABULARY
24         create 0 ,
25 does>
26         body> context #context @ 1- + !
27 ;
28
29 : DEFINITIONS
30         context @ current !
31 ;
32
33 vocabulary root
34 also root definitions
35
36 : FORTH forth ;
37
38 : ONLY
39         1 #context !
40         root 
41         2 #context !
42 ;
43
44 \ only forth
45
46 \ Display search order and compilation dictionary
47 : ORDER
48
49         \ Search order
50         context #context @ 1- + context swap
51         do
52             i @ >name .name space
53         -1 +loop
54
55         \ Current (definitions)
56         9 emit
57         current @ >name .name
58 ;