-
Notifications
You must be signed in to change notification settings - Fork 128
/
np1.c
415 lines (349 loc) · 7.21 KB
/
np1.c
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
/* SPARSE- START OF PARSE */
/*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
/* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
/* WRITTEN BY R. M. SUPNIK */
#include "funcs.h"
#include "vars.h"
#undef EXTERN
#define EXTERN
#define INIT
#include "parse.h"
/* THIS ROUTINE DETAILS ON BIT 2 OF PRSFLG */
integer sparse_(lbuf, llnt, vbflag)
const integer *lbuf;
integer llnt;
logical vbflag;
{
/* Initialized data */
/* DATA R50MIN/1RA/,R50WAL/3RWAL/ */
const integer r50min = 1600;
const integer r50wal = 36852;
/* System generated locals */
volatile integer ret_val, i__1, i__2;
/* Local variables */
integer i, j, adj;
integer obj;
integer prep, pptr, lbuf1, lbuf2;
integer buzlnt, prplnt, dirlnt;
/* Parameter adjustments */
--lbuf;
/* Function Body */
/* SET UP FOR PARSING */
ret_val = -1;
/* !ASSUME PARSE FAILS. */
adj = 0;
/* !CLEAR PARTS HOLDERS. */
pv_1.act = 0;
prep = 0;
pptr = 0;
pv_1.o1 = 0;
pv_1.o2 = 0;
pv_1.p1 = 0;
pv_1.p2 = 0;
buzlnt = 20;
prplnt = 48;
dirlnt = 75;
/* SPARSE, PAGE 8 */
/* NOW LOOP OVER INPUT BUFFER OF LEXICAL TOKENS. */
i__1 = llnt;
for (i = 1; i <= i__1; i += 2) {
/* !TWO WORDS/TOKEN. */
lbuf1 = lbuf[i];
/* !GET CURRENT TOKEN. */
lbuf2 = lbuf[i + 1];
if (lbuf1 == 0) {
goto L1500;
}
/* !END OF BUFFER? */
/* CHECK FOR BUZZ WORD */
i__2 = buzlnt;
for (j = 1; j <= i__2; j += 2) {
if (lbuf1 == buzvoc_1.bvoc[j - 1] && lbuf2 == buzvoc_1.bvoc[j]) {
goto L1000;
}
/* L50: */
}
/* CHECK FOR ACTION OR DIRECTION */
if (pv_1.act != 0) {
goto L75;
}
/* !GOT ACTION ALREADY? */
j = 1;
/* !CHECK FOR ACTION. */
L125:
if (lbuf1 == vvoc[j - 1] && lbuf2 == vvoc[j]) {
goto L3000;
}
/* L150: */
j += 2;
/* !ADV TO NEXT SYNONYM. */
if (! (vvoc[j - 1] > 0 && vvoc[j - 1] < r50min)) {
goto L125;
}
/* !ANOTHER VERB? */
j = j + vvoc[j - 1] + 1;
/* !NO, ADVANCE OVER SYNTAX. */
if (vvoc[j - 1] != -1) {
goto L125;
}
/* !TABLE DONE? */
L75:
if (pv_1.act != 0 && (vvoc[pv_1.act - 1] != r50wal || prep != 0)) {
goto L200;
}
i__2 = dirlnt;
for (j = 1; j <= i__2; j += 3) {
/* !THEN CHK FOR DIR. */
if (lbuf1 == dirvoc_1.dvoc[j - 1] && lbuf2 == dirvoc_1.dvoc[j]) {
goto L2000;
}
/* L100: */
}
/* NOT AN ACTION, CHECK FOR PREPOSITION, ADJECTIVE, OR OBJECT. */
L200:
i__2 = prplnt;
for (j = 1; j <= i__2; j += 3) {
/* !LOOK FOR PREPOSITION. */
if (lbuf1 == prpvoc_1.pvoc[j - 1] && lbuf2 == prpvoc_1.pvoc[j]) {
goto L4000;
}
/* L250: */
}
j = 1;
/* !LOOK FOR ADJECTIVE. */
L300:
if (lbuf1 == avoc[j - 1] && lbuf2 == avoc[j]) {
goto L5000;
}
++j;
L325:
++j;
/* !ADVANCE TO NEXT ENTRY. */
if (avoc[j - 1] > 0 && avoc[j - 1] < r50min) {
goto L325;
}
/* !A RADIX 50 CONSTANT? */
if (avoc[j - 1] != -1) {
goto L300;
}
/* !POSSIBLY, END TABLE? */
j = 1;
/* !LOOK FOR OBJECT. */
L450:
if (lbuf1 == ovoc[j - 1] && lbuf2 == ovoc[j]) {
goto L600;
}
++j;
L500:
++j;
if (ovoc[j - 1] > 0 && ovoc[j - 1] < r50min) {
goto L500;
}
if (ovoc[j - 1] != -1) {
goto L450;
}
/* NOT RECOGNIZABLE */
if (vbflag) {
rspeak_(601);
}
return ret_val;
/* SPARSE, PAGE 9 */
/* OBJECT PROCESSING (CONTINUATION OF DO LOOP ON PREV PAGE) */
L600:
obj = getobj_(j, adj, 0);
/* !IDENTIFY OBJECT. */
if (obj <= 0) {
goto L6000;
}
/* !IF LE, COULDNT. */
if (obj != oindex_1.itobj) {
goto L650;
}
/* !"IT"? */
obj = getobj_(0, 0, last_1.lastit);
/* !FIND LAST. */
if (obj <= 0) {
goto L6000;
}
/* !IF LE, COULDNT. */
L650:
if (prep == 9) {
goto L8000;
}
/* !"OF" OBJ? */
if (pptr == 2) {
goto L7000;
}
/* !TOO MANY OBJS? */
++pptr;
objvec[pptr - 1] = obj;
/* !STUFF INTO VECTOR. */
prpvec[pptr - 1] = prep;
L700:
prep = 0;
adj = 0;
/* Go to end of do loop (moved "1000 CONTINUE" to end of module, to av
oid */
/* complaints about people jumping back into the doloop.) */
goto L1000;
/* SPARSE, PAGE 10 */
/* SPECIAL PARSE PROCESSORS */
/* 2000-- DIRECTION */
L2000:
prsvec_1.prsa = vindex_1.walkw;
prsvec_1.prso = dirvoc_1.dvoc[j + 1];
ret_val = 1;
return ret_val;
/* 3000-- ACTION */
L3000:
pv_1.act = j;
orphs_1.oact = 0;
goto L1000;
/* 4000-- PREPOSITION */
L4000:
if (prep != 0) {
goto L4500;
}
prep = prpvoc_1.pvoc[j + 1];
adj = 0;
goto L1000;
L4500:
if (vbflag) {
rspeak_(616);
}
return ret_val;
/* 5000-- ADJECTIVE */
L5000:
adj = j;
j = orphs_1.oname & orphs_1.oflag;
if (j != 0 && i >= llnt) {
goto L600;
}
goto L1000;
/* 6000-- UNIDENTIFIABLE OBJECT (INDEX INTO OVOC IS J) */
L6000:
if (obj < 0) {
goto L6100;
}
j = 579;
if (lit_(play_1.here)) {
j = 618;
}
if (vbflag) {
rspeak_(j);
}
return ret_val;
L6100:
if (obj != -10000) {
goto L6200;
}
if (vbflag) {
rspsub_(620, objcts_1.odesc2[advs_1.avehic[play_1.winner - 1]
- 1]);
}
return ret_val;
L6200:
if (vbflag) {
rspeak_(619);
}
if (pv_1.act == 0) {
pv_1.act = orphs_1.oflag & orphs_1.oact;
}
orphan_(- 1, pv_1.act, pv_1.o1, prep, j);
return ret_val;
/* 7000-- TOO MANY OBJECTS. */
L7000:
if (vbflag) {
rspeak_(617);
}
return ret_val;
/* 8000-- RANDOMNESS FOR "OF" WORDS */
L8000:
if (objvec[pptr - 1] == obj) {
goto L700;
}
if (vbflag) {
rspeak_(601);
}
return ret_val;
/* End of do-loop. */
L1000:
;
}
/* !AT LAST. */
/* NOW SOME MISC CLEANUP -- We fell out of the do-loop */
L1500:
if (pv_1.act == 0) {
pv_1.act = orphs_1.oflag & orphs_1.oact;
}
if (pv_1.act == 0) {
goto L9000;
}
/* !IF STILL NONE, PUNT. */
if (adj != 0) {
goto L10000;
}
/* !IF DANGLING ADJ, PUNT. */
if (orphs_1.oflag != 0 && orphs_1.oprep != 0 && prep == 0 && pv_1.o1 != 0
&& pv_1.o2 == 0 && pv_1.act == orphs_1.oact) {
goto L11000;
}
ret_val = 0;
/* !PARSE SUCCEEDS. */
if (prep == 0) {
goto L1750;
}
/* !IF DANGLING PREP, */
if (pptr == 0 || prpvec[pptr - 1] != 0) {
goto L12000;
}
prpvec[pptr - 1] = prep;
/* !CVT TO 'PICK UP FROB'. */
/* 1750-- RETURN A RESULT */
L1750:
/* !WIN. */
return ret_val;
/* !LOSE. */
/* 9000-- NO ACTION, PUNT */
L9000:
if (pv_1.o1 == 0) {
goto L10000;
}
/* !ANY DIRECT OBJECT? */
if (vbflag) {
rspsub_(621, objcts_1.odesc2[pv_1.o1 - 1]);
}
/* !WHAT TO DO? */
orphan_(- 1, 0, pv_1.o1, 0, 0);
return ret_val;
/* 10000-- TOTAL CHOMP */
L10000:
if (vbflag) {
rspeak_(622);
}
/* !HUH? */
return ret_val;
/* 11000-- ORPHAN PREPOSITION. CONDITIONS ARE */
/* O1.NE.0, O2=0, PREP=0, ACT=OACT */
L11000:
if (orphs_1.oslot != 0) {
goto L11500;
}
/* !ORPHAN OBJECT? */
pv_1.p1 = orphs_1.oprep;
/* !NO, JUST USE PREP. */
goto L1750;
L11500:
pv_1.o2 = pv_1.o1;
/* !YES, USE AS DIRECT OBJ. */
pv_1.p2 = orphs_1.oprep;
pv_1.o1 = orphs_1.oslot;
pv_1.p1 = 0;
goto L1750;
/* 12000-- TRUE HANGING PREPOSITION. */
/* ORPHAN FOR LATER. */
L12000:
orphan_(- 1, pv_1.act, 0, prep, 0);
/* !ORPHAN PREP. */
goto L1750;
} /* sparse_ */