-
Notifications
You must be signed in to change notification settings - Fork 1
/
WORDS
100 lines (76 loc) · 2.77 KB
/
WORDS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
\ $Id: words.f $
cr .( Loading WORDS...)
\ display words from one or two patterns
\ use: words
\ or: words +!
\ or: words ! 2
: horizontal-line ( -- )
getcolrow drop getxy drop - 1- 0max 8 /mod 0
?do ." --------"
loop s" --------" drop swap type
cr ;
only forth also hidden also definitions
variable vocsave
create words-pad 260 allot
create words-pocket 260 allot
10000 value words-limit
: .voc-once ( -- )
vocsave @ ?dup
if cr ." ----------- " >name .id
horizontal-line
vocsave off
then ;
: match? ( addr len -- f )
2dup >r >r words-pocket count search nip nip
pocket c@
if r> r> pocket count search nip nip and
else r> r> 2drop
then words-pocket c@ 0= or ;
0 value w#threads
: (words) ( voc -- )
dup voc#threads to w#threads
dup voc>vcfa call@
dup doClass = \ don't look through classes
swap do|Class = or 0= \ don't look through classes
if dup here 500 + w#threads cells move \ copy vocabulary up
voc>vcfa vocsave !
begin here 500 + w#threads largest dup
words-cnt words-limit < and
while dup l>name nfa-count 2dup 255 min words-pad place
words-pad ?uppercase count match?
if .voc-once
type 20 #tab space 20 ?cr
1 +to words-cnt
else 2drop
then
@ swap !
start/stop cursor-off
repeat 2drop
else drop
then vocsave off ;
: nwords ( -<optional-name>- )
to words-limit
0 to words-cnt
words-pocket off
bl word ?uppercase c@
if pocket count words-pocket place
bl word ?uppercase drop
voc-link @
begin dup vlink>voc
(words) @ dup 0=
until drop
else context @ (words)
then
base @ >r decimal
cr horizontal-line
." Displayed " words-cnt . ." of the "
count-words . ." words in the system."
r> base ! ;
forth definitions
: words
10000 nwords
;
: latest-words ( -<optional-name>- )
25 nwords
;
only forth also