np1.c 7.2 KB

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