1 /* SPARSE- START OF PARSE */
2
3 /*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
4 /* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
5 /* WRITTEN BY R. M. SUPNIK */
6
7 #include "funcs.h"
8 #include "vars.h"
9
10 #undef EXTERN
11 #define EXTERN
12 #define INIT
13
14 #include "parse.h"
15
16 /* THIS ROUTINE DETAILS ON BIT 2 OF PRSFLG */
17
sparse_(lbuf,llnt,vbflag)18 integer sparse_(lbuf, llnt, vbflag)
19 const integer *lbuf;
20 integer llnt;
21 logical vbflag;
22 {
23 /* Initialized data */
24
25 /* DATA R50MIN/1RA/,R50WAL/3RWAL/ */
26 const integer r50min = 1600;
27 const integer r50wal = 36852;
28
29 /* System generated locals */
30 integer ret_val, i__1, i__2;
31
32 /* Local variables */
33 integer i, j, adj;
34 integer obj;
35 integer prep, pptr, lbuf1, lbuf2;
36 integer buzlnt, prplnt, dirlnt;
37
38 /* Parameter adjustments */
39 --lbuf;
40
41 /* Function Body */
42
43 /* SET UP FOR PARSING */
44
45 ret_val = -1;
46 /* !ASSUME PARSE FAILS. */
47 adj = 0;
48 /* !CLEAR PARTS HOLDERS. */
49 pv_1.act = 0;
50 prep = 0;
51 pptr = 0;
52 pv_1.o1 = 0;
53 pv_1.o2 = 0;
54 pv_1.p1 = 0;
55 pv_1.p2 = 0;
56
57 buzlnt = 20;
58 prplnt = 48;
59 dirlnt = 75;
60 /* SPARSE, PAGE 8 */
61
62 /* NOW LOOP OVER INPUT BUFFER OF LEXICAL TOKENS. */
63
64 i__1 = llnt;
65 for (i = 1; i <= i__1; i += 2) {
66 /* !TWO WORDS/TOKEN. */
67 lbuf1 = lbuf[i];
68 /* !GET CURRENT TOKEN. */
69 lbuf2 = lbuf[i + 1];
70 if (lbuf1 == 0) {
71 goto L1500;
72 }
73 /* !END OF BUFFER? */
74
75 /* CHECK FOR BUZZ WORD */
76
77 i__2 = buzlnt;
78 for (j = 1; j <= i__2; j += 2) {
79 if (lbuf1 == buzvoc_1.bvoc[j - 1] && lbuf2 == buzvoc_1.bvoc[j]) {
80 goto L1000;
81 }
82 /* L50: */
83 }
84
85 /* CHECK FOR ACTION OR DIRECTION */
86
87 if (pv_1.act != 0) {
88 goto L75;
89 }
90 /* !GOT ACTION ALREADY? */
91 j = 1;
92 /* !CHECK FOR ACTION. */
93 L125:
94 if (lbuf1 == vvoc[j - 1] && lbuf2 == vvoc[j]) {
95 goto L3000;
96 }
97 /* L150: */
98 j += 2;
99 /* !ADV TO NEXT SYNONYM. */
100 if (! (vvoc[j - 1] > 0 && vvoc[j - 1] < r50min)) {
101 goto L125;
102 }
103 /* !ANOTHER VERB? */
104 j = j + vvoc[j - 1] + 1;
105 /* !NO, ADVANCE OVER SYNTAX. */
106 if (vvoc[j - 1] != -1) {
107 goto L125;
108 }
109 /* !TABLE DONE? */
110
111 L75:
112 if (pv_1.act != 0 && (vvoc[pv_1.act - 1] != r50wal || prep != 0)) {
113 goto L200;
114 }
115 i__2 = dirlnt;
116 for (j = 1; j <= i__2; j += 3) {
117 /* !THEN CHK FOR DIR. */
118 if (lbuf1 == dirvoc_1.dvoc[j - 1] && lbuf2 == dirvoc_1.dvoc[j]) {
119 goto L2000;
120 }
121 /* L100: */
122 }
123
124 /* NOT AN ACTION, CHECK FOR PREPOSITION, ADJECTIVE, OR OBJECT. */
125
126 L200:
127 i__2 = prplnt;
128 for (j = 1; j <= i__2; j += 3) {
129 /* !LOOK FOR PREPOSITION. */
130 if (lbuf1 == prpvoc_1.pvoc[j - 1] && lbuf2 == prpvoc_1.pvoc[j]) {
131 goto L4000;
132 }
133 /* L250: */
134 }
135
136 j = 1;
137 /* !LOOK FOR ADJECTIVE. */
138 L300:
139 if (lbuf1 == avoc[j - 1] && lbuf2 == avoc[j]) {
140 goto L5000;
141 }
142 ++j;
143 L325:
144 ++j;
145 /* !ADVANCE TO NEXT ENTRY. */
146 if (avoc[j - 1] > 0 && avoc[j - 1] < r50min) {
147 goto L325;
148 }
149 /* !A RADIX 50 CONSTANT? */
150 if (avoc[j - 1] != -1) {
151 goto L300;
152 }
153 /* !POSSIBLY, END TABLE? */
154
155 j = 1;
156 /* !LOOK FOR OBJECT. */
157 L450:
158 if (lbuf1 == ovoc[j - 1] && lbuf2 == ovoc[j]) {
159 goto L600;
160 }
161 ++j;
162 L500:
163 ++j;
164 if (ovoc[j - 1] > 0 && ovoc[j - 1] < r50min) {
165 goto L500;
166 }
167 if (ovoc[j - 1] != -1) {
168 goto L450;
169 }
170
171 /* NOT RECOGNIZABLE */
172
173 if (vbflag) {
174 rspeak_(601);
175 }
176 return ret_val;
177 /* SPARSE, PAGE 9 */
178
179 /* OBJECT PROCESSING (CONTINUATION OF DO LOOP ON PREV PAGE) */
180
181 L600:
182 obj = getobj_(j, adj, 0);
183 /* !IDENTIFY OBJECT. */
184 if (obj <= 0) {
185 goto L6000;
186 }
187 /* !IF LE, COULDNT. */
188 if (obj != oindex_1.itobj) {
189 goto L650;
190 }
191 /* !"IT"? */
192 obj = getobj_(0, 0, last_1.lastit);
193 /* !FIND LAST. */
194 if (obj <= 0) {
195 goto L6000;
196 }
197 /* !IF LE, COULDNT. */
198
199 L650:
200 if (prep == 9) {
201 goto L8000;
202 }
203 /* !"OF" OBJ? */
204 if (pptr == 2) {
205 goto L7000;
206 }
207 /* !TOO MANY OBJS? */
208 ++pptr;
209 objvec[pptr - 1] = obj;
210 /* !STUFF INTO VECTOR. */
211 prpvec[pptr - 1] = prep;
212 L700:
213 prep = 0;
214 adj = 0;
215 /* Go to end of do loop (moved "1000 CONTINUE" to end of module, to av
216 oid */
217 /* complaints about people jumping back into the doloop.) */
218 goto L1000;
219 /* SPARSE, PAGE 10 */
220
221 /* SPECIAL PARSE PROCESSORS */
222
223 /* 2000-- DIRECTION */
224
225 L2000:
226 prsvec_1.prsa = vindex_1.walkw;
227 prsvec_1.prso = dirvoc_1.dvoc[j + 1];
228 ret_val = 1;
229 return ret_val;
230
231 /* 3000-- ACTION */
232
233 L3000:
234 pv_1.act = j;
235 orphs_1.oact = 0;
236 goto L1000;
237
238 /* 4000-- PREPOSITION */
239
240 L4000:
241 if (prep != 0) {
242 goto L4500;
243 }
244 prep = prpvoc_1.pvoc[j + 1];
245 adj = 0;
246 goto L1000;
247
248 L4500:
249 if (vbflag) {
250 rspeak_(616);
251 }
252 return ret_val;
253
254 /* 5000-- ADJECTIVE */
255
256 L5000:
257 adj = j;
258 j = orphs_1.oname & orphs_1.oflag;
259 if (j != 0 && i >= llnt) {
260 goto L600;
261 }
262 goto L1000;
263
264 /* 6000-- UNIDENTIFIABLE OBJECT (INDEX INTO OVOC IS J) */
265
266 L6000:
267 if (obj < 0) {
268 goto L6100;
269 }
270 j = 579;
271 if (lit_(play_1.here)) {
272 j = 618;
273 }
274 if (vbflag) {
275 rspeak_(j);
276 }
277 return ret_val;
278
279 L6100:
280 if (obj != -10000) {
281 goto L6200;
282 }
283 if (vbflag) {
284 rspsub_(620, objcts_1.odesc2[advs_1.avehic[play_1.winner - 1]
285 - 1]);
286 }
287 return ret_val;
288
289 L6200:
290 if (vbflag) {
291 rspeak_(619);
292 }
293 if (pv_1.act == 0) {
294 pv_1.act = orphs_1.oflag & orphs_1.oact;
295 }
296 orphan_(- 1, pv_1.act, pv_1.o1, prep, j);
297 return ret_val;
298
299 /* 7000-- TOO MANY OBJECTS. */
300
301 L7000:
302 if (vbflag) {
303 rspeak_(617);
304 }
305 return ret_val;
306
307 /* 8000-- RANDOMNESS FOR "OF" WORDS */
308
309 L8000:
310 if (objvec[pptr - 1] == obj) {
311 goto L700;
312 }
313 if (vbflag) {
314 rspeak_(601);
315 }
316 return ret_val;
317
318 /* End of do-loop. */
319
320 L1000:
321 ;
322 }
323 /* !AT LAST. */
324
325 /* NOW SOME MISC CLEANUP -- We fell out of the do-loop */
326
327 L1500:
328 if (pv_1.act == 0) {
329 pv_1.act = orphs_1.oflag & orphs_1.oact;
330 }
331 if (pv_1.act == 0) {
332 goto L9000;
333 }
334 /* !IF STILL NONE, PUNT. */
335 if (adj != 0) {
336 goto L10000;
337 }
338 /* !IF DANGLING ADJ, PUNT. */
339
340 if (orphs_1.oflag != 0 && orphs_1.oprep != 0 && prep == 0 && pv_1.o1 != 0
341 && pv_1.o2 == 0 && pv_1.act == orphs_1.oact) {
342 goto L11000;
343 }
344
345 ret_val = 0;
346 /* !PARSE SUCCEEDS. */
347 if (prep == 0) {
348 goto L1750;
349 }
350 /* !IF DANGLING PREP, */
351 if (pptr == 0 || prpvec[pptr - 1] != 0) {
352 goto L12000;
353 }
354 prpvec[pptr - 1] = prep;
355 /* !CVT TO 'PICK UP FROB'. */
356
357 /* 1750-- RETURN A RESULT */
358
359 L1750:
360 /* !WIN. */
361 return ret_val;
362 /* !LOSE. */
363
364 /* 9000-- NO ACTION, PUNT */
365
366 L9000:
367 if (pv_1.o1 == 0) {
368 goto L10000;
369 }
370 /* !ANY DIRECT OBJECT? */
371 if (vbflag) {
372 rspsub_(621, objcts_1.odesc2[pv_1.o1 - 1]);
373 }
374 /* !WHAT TO DO? */
375 orphan_(- 1, 0, pv_1.o1, 0, 0);
376 return ret_val;
377
378 /* 10000-- TOTAL CHOMP */
379
380 L10000:
381 if (vbflag) {
382 rspeak_(622);
383 }
384 /* !HUH? */
385 return ret_val;
386
387 /* 11000-- ORPHAN PREPOSITION. CONDITIONS ARE */
388 /* O1.NE.0, O2=0, PREP=0, ACT=OACT */
389
390 L11000:
391 if (orphs_1.oslot != 0) {
392 goto L11500;
393 }
394 /* !ORPHAN OBJECT? */
395 pv_1.p1 = orphs_1.oprep;
396 /* !NO, JUST USE PREP. */
397 goto L1750;
398
399 L11500:
400 pv_1.o2 = pv_1.o1;
401 /* !YES, USE AS DIRECT OBJ. */
402 pv_1.p2 = orphs_1.oprep;
403 pv_1.o1 = orphs_1.oslot;
404 pv_1.p1 = 0;
405 goto L1750;
406
407 /* 12000-- TRUE HANGING PREPOSITION. */
408 /* ORPHAN FOR LATER. */
409
410 L12000:
411 orphan_(- 1, pv_1.act, 0, prep, 0);
412 /* !ORPHAN PREP. */
413 goto L1750;
414
415 } /* sparse_ */
416