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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
|
(* ------------------- VERSION 3 17.03.86 ------------------- *)
PACKET name set DEFINES (* Autor: J.Liedtke *)
ALL ,
SOME ,
LIKE ,
+ ,
- ,
/ ,
do ,
FILLBY ,
remainder ,
fetch ,
save ,
fetch all ,
save all ,
forget ,
erase ,
insert ,
edit :
LET cr lf = ""13""10"" ;
TEXT VAR name ;
DATASPACE VAR edit space ;
THESAURUS VAR remaining thesaurus := empty thesaurus ;
THESAURUS OP + (THESAURUS CONST left, right) :
THESAURUS VAR union := left ;
INT VAR index := 0 ;
get (right, name, index) ;
WHILE name <> "" REP
IF NOT (union CONTAINS name)
THEN insert (union, name)
FI ;
get (right, name, index)
PER ;
union .
ENDOP + ;
THESAURUS OP + (THESAURUS CONST left, TEXT CONST right) :
THESAURUS VAR union := left ;
IF NOT (union CONTAINS right)
THEN insert (union, right)
FI ;
union .
ENDOP + ;
THESAURUS OP - (THESAURUS CONST left, right) :
THESAURUS VAR difference := empty thesaurus ;
INT VAR index := 0 ;
get (left, name, index) ;
WHILE name <> "" REP
IF NOT (right CONTAINS name)
THEN insert (difference, name)
FI ;
get (left, name, index)
PER ;
difference .
ENDOP - ;
THESAURUS OP - (THESAURUS CONST left, TEXT CONST right) :
THESAURUS VAR difference := left ;
INT VAR index ;
delete (difference, right, index) ;
difference .
ENDOP - ;
THESAURUS OP / (THESAURUS CONST left, right) :
THESAURUS VAR intersection := empty thesaurus ;
INT VAR index := 0 ;
get (left, name, index) ;
WHILE name <> "" REP
IF right CONTAINS name
THEN insert (intersection, name)
FI ;
get (left, name, index)
PER ;
intersection .
ENDOP / ;
THESAURUS OP ALL (TEXT CONST file name) :
FILE VAR file := sequential file (input, file name) ;
THESAURUS VAR thesaurus := empty thesaurus ;
thesaurus FILLBY file ;
thesaurus .
ENDOP ALL ;
THESAURUS OP SOME (THESAURUS CONST thesaurus) :
copy thesaurus into file ;
edit file ;
copy file into thesaurus .
copy thesaurus into file :
forget (edit space) ;
edit space := nilspace ;
FILE VAR file := sequential file (output, edit space) ;
file FILLBY thesaurus .
edit file :
modify (file) ;
edit (file) .
copy file into thesaurus :
THESAURUS VAR result := empty thesaurus ;
input (file) ;
result FILLBY file ;
forget (edit space) ;
result .
ENDOP SOME ;
THESAURUS OP SOME (TASK CONST task) :
SOME ALL task
ENDOP SOME ;
THESAURUS OP SOME (TEXT CONST file name) :
SOME ALL file name
ENDOP SOME ;
THESAURUS OP LIKE (THESAURUS CONST thesaurus, TEXT CONST pattern) :
THESAURUS VAR result:= empty thesaurus ;
INT VAR index:= 0 ;
REP get (thesaurus, name, index) ;
IF name = ""
THEN LEAVE LIKE WITH result
ELIF name LIKE pattern
THEN insert (result, name)
FI
PER ;
result .
ENDOP LIKE ;
THESAURUS PROC remainder :
remaining thesaurus
ENDPROC remainder ;
PROC do (PROC (TEXT CONST) operate, THESAURUS CONST thesaurus) :
INT VAR index := 0 , operation number := 0 ;
TEXT VAR name ;
remaining thesaurus := empty thesaurus ;
disable stop ;
work off thesaurus ;
fill leftover with remainder .
work off thesaurus :
REP
get (thesaurus, name, index) ;
IF name = ""
THEN LEAVE work off thesaurus
FI ;
operation number INCR 1 ;
cout (operation number) ;
execute (PROC (TEXT CONST) operate, name)
UNTIL is error ENDREP .
fill leftover with remainder :
WHILE name <> "" REP
insert (remaining thesaurus, name) ;
get (thesaurus, name, index)
PER .
ENDPROC do ;
PROC execute (PROC (TEXT CONST) operate, TEXT CONST name) :
enable stop ;
operate (name)
ENDPROC execute ;
PROC do (PROC (TEXT CONST, TASK CONST) operate, THESAURUS CONST thesaurus,
TASK CONST task) :
INT VAR index := 0 , operation number := 0 ;
TEXT VAR name ;
remaining thesaurus := empty thesaurus ;
disable stop ;
work off thesaurus ;
fill leftover with remainder .
work off thesaurus :
REP
get (thesaurus, name, index) ;
IF name = ""
THEN LEAVE work off thesaurus
FI ;
operation number INCR 1 ;
cout (operation number) ;
execute (PROC (TEXT CONST, TASK CONST) operate, name, task)
UNTIL is error ENDREP .
fill leftover with remainder :
WHILE name <> "" REP
insert (remaining thesaurus, name) ;
get (thesaurus, name, index)
PER .
ENDPROC do ;
PROC execute (PROC (TEXT CONST, TASK CONST) operate,
TEXT CONST name, TASK CONST task) :
enable stop ;
operate (name, task)
ENDPROC execute ;
OP FILLBY (THESAURUS VAR thesaurus, FILE VAR file) :
WHILE NOT eof (file) REP
getline (file, name) ;
delete trailing blanks ;
IF name <> "" CAND NOT (thesaurus CONTAINS name)
THEN insert (thesaurus, name)
FI
PER .
delete trailing blanks :
WHILE (name SUB LENGTH name) = " " REP
name := subtext (name, 1, LENGTH name - 1)
PER .
ENDOP FILLBY ;
OP FILLBY (FILE VAR file, THESAURUS CONST thesaurus) :
INT VAR index := 0 ;
REP
get (thesaurus, name, index) ;
IF name = ""
THEN LEAVE FILLBY
FI ;
putline (file, name)
PER .
ENDOP FILLBY ;
OP FILLBY (TEXT CONST file name, THESAURUS CONST thesaurus) :
FILE VAR f := sequential file (output, file name) ;
f FILLBY thesaurus
ENDOP FILLBY ;
PROC fetch (THESAURUS CONST nameset) :
do (PROC (TEXT CONST) fetch, nameset)
ENDPROC fetch ;
PROC fetch (THESAURUS CONST nameset, TASK CONST task) :
do (PROC (TEXT CONST, TASK CONST) fetch, nameset, task)
ENDPROC fetch ;
PROC save (THESAURUS CONST nameset) :
do (PROC (TEXT CONST) save, nameset)
ENDPROC save ;
PROC save (THESAURUS CONST nameset, TASK CONST task) :
do (PROC (TEXT CONST, TASK CONST) save, nameset, task)
ENDPROC save ;
PROC fetch all :
fetch all (father)
ENDPROC fetch all ;
PROC fetch all (TASK CONST manager) :
fetch (ALL manager, manager)
ENDPROC fetch all ;
PROC save all :
save all (father)
ENDPROC save all ;
PROC save all (TASK CONST manager) :
save (ALL myself, manager)
ENDPROC save all ;
PROC forget (THESAURUS CONST nameset) :
do (PROC (TEXT CONST) forget, nameset)
ENDPROC forget ;
PROC erase (THESAURUS CONST nameset) :
do (PROC (TEXT CONST) erase, nameset)
ENDPROC erase ;
PROC erase (THESAURUS CONST nameset, TASK CONST task) :
do (PROC (TEXT CONST, TASK CONST) erase, nameset, task)
ENDPROC erase ;
PROC insert (THESAURUS CONST nameset) :
do (PROC (TEXT CONST) insert, nameset)
ENDPROC insert ;
PROC edit (THESAURUS CONST nameset) :
do (PROC (TEXT CONST) edit, nameset)
ENDPROC edit ;
ENDPACKET name set ;
|