np1.for 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. C SPARSE- START OF PARSE
  2. C
  3. C COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142
  4. C ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED
  5. C WRITTEN BY R. M. SUPNIK
  6. C
  7. C DECLARATIONS
  8. C
  9. C THIS ROUTINE DETAILS ON BIT 2 OF PRSFLG
  10. C
  11. INTEGER FUNCTION SPARSE(LBUF,LLNT,VBFLAG)
  12. IMPLICIT INTEGER(A-Z)
  13. INTEGER LBUF(40)
  14. LOGICAL LIT,OTEST,VBFLAG
  15. include 'parser.h'
  16. include 'gamestat.h'
  17. include 'debug.h'
  18. include 'objects.h'
  19. include 'oindex.h'
  20. include 'advers.h'
  21. include 'verbs.h'
  22. include 'vocab.h'
  23. C SPARSE, PAGE 2
  24. C
  25. C FUNCTIONS AND DATA
  26. C
  27. OTEST(R)=(R.GT.0).AND.(R.LT.R50MIN)
  28. C
  29. C THE FOLLOWING DATA STATEMENT ORIGINALLY WAS:
  30. C
  31. C DATA R50MIN/1RA/,R50WAL/3RWAL/
  32. C
  33. DATA R50MIN/1600/,R50WAL/36852/
  34. C SPARSE, PAGE 7
  35. C
  36. C SET UP FOR PARSING
  37. C
  38. SPARSE=-1
  39. C !ASSUME PARSE FAILS.
  40. ADJ=0
  41. C !CLEAR PARTS HOLDERS.
  42. ACT=0
  43. PREP=0
  44. PPTR=0
  45. O1=0
  46. O2=0
  47. P1=0
  48. P2=0
  49. D DFLAG=IAND(PRSFLG,4).NE.0
  50. C
  51. BUZLNT=20
  52. PRPLNT=48
  53. DIRLNT=75
  54. C SPARSE, PAGE 8
  55. C
  56. C NOW LOOP OVER INPUT BUFFER OF LEXICAL TOKENS.
  57. C
  58. DO 1000 I=1,LLNT,2
  59. C !TWO WORDS/TOKEN.
  60. LBUF1=LBUF(I)
  61. C !GET CURRENT TOKEN.
  62. LBUF2=LBUF(I+1)
  63. D if(DFLAG) write(0,*) 'lbuf1=',lbuf1,' lbuf2=',lbuf2
  64. IF(LBUF1.EQ.0) GO TO 1500
  65. C !END OF BUFFER?
  66. C
  67. C CHECK FOR BUZZ WORD
  68. C
  69. DO 50 J=1,BUZLNT,2
  70. IF((LBUF1.EQ.BVOC(J)).AND.(LBUF2.EQ.BVOC(J+1)))
  71. & GO TO 1000
  72. 50 CONTINUE
  73. C
  74. C CHECK FOR ACTION OR DIRECTION
  75. C
  76. IF(ACT.NE.0) GO TO 75
  77. C !GOT ACTION ALREADY?
  78. J=1
  79. C !CHECK FOR ACTION.
  80. 125 IF((LBUF1.EQ.VVOC(J)).AND.(LBUF2.EQ.VVOC(J+1)))
  81. & GO TO 3000
  82. 150 J=J+2
  83. C !ADV TO NEXT SYNONYM.
  84. IF(.NOT.OTEST(VVOC(J))) GO TO 125
  85. C !ANOTHER VERB?
  86. J=J+VVOC(J)+1
  87. C !NO, ADVANCE OVER SYNTAX.
  88. IF(VVOC(J).NE.-1) GO TO 125
  89. C !TABLE DONE?
  90. C
  91. 75 IF((ACT.NE.0).AND.((VVOC(ACT).NE.R50WAL).OR.
  92. & (PREP.NE.0))) GO TO 200
  93. DO 100 J=1,DIRLNT,3
  94. C !THEN CHK FOR DIR.
  95. IF((LBUF1.EQ.DVOC(J)).AND.(LBUF2.EQ.DVOC(J+1)))
  96. & GO TO 2000
  97. 100 CONTINUE
  98. C
  99. C NOT AN ACTION, CHECK FOR PREPOSITION, ADJECTIVE, OR OBJECT.
  100. C
  101. 200 DO 250 J=1,PRPLNT,3
  102. C !LOOK FOR PREPOSITION.
  103. IF((LBUF1.EQ.PVOC(J)).AND.(LBUF2.EQ.PVOC(J+1)))
  104. & GO TO 4000
  105. 250 CONTINUE
  106. C
  107. J=1
  108. C !LOOK FOR ADJECTIVE.
  109. 300 IF((LBUF1.EQ.AVOC(J)).AND.(LBUF2.EQ.AVOC(J+1)))
  110. & GO TO 5000
  111. J=J+1
  112. 325 J=J+1
  113. C !ADVANCE TO NEXT ENTRY.
  114. IF(OTEST(AVOC(J))) GO TO 325
  115. C !A RADIX 50 CONSTANT?
  116. IF(AVOC(J).NE.-1) GO TO 300
  117. C !POSSIBLY, END TABLE?
  118. C
  119. J=1
  120. C !LOOK FOR OBJECT.
  121. 450 IF((LBUF1.EQ.OVOC(J)).AND.(LBUF2.EQ.OVOC(J+1)))
  122. & GO TO 600
  123. J=J+1
  124. 500 J=J+1
  125. IF(OTEST(OVOC(J))) GO TO 500
  126. IF(OVOC(J).NE.-1) GO TO 450
  127. C
  128. C NOT RECOGNIZABLE
  129. C
  130. IF(VBFLAG) CALL RSPEAK(601)
  131. RETURN
  132. C SPARSE, PAGE 9
  133. C
  134. C OBJECT PROCESSING (CONTINUATION OF DO LOOP ON PREV PAGE)
  135. C
  136. 600 OBJ=GETOBJ(J,ADJ,0)
  137. C !IDENTIFY OBJECT.
  138. D IF(DFLAG) PRINT 60,J,OBJ
  139. D60 FORMAT(' SPARSE- OBJ AT ',I6,' OBJ= ',I6)
  140. IF(OBJ.LE.0) GO TO 6000
  141. C !IF LE, COULDNT.
  142. IF(OBJ.NE.ITOBJ) GO TO 650
  143. C !"IT"?
  144. OBJ=GETOBJ(0,0,LASTIT)
  145. C !FIND LAST.
  146. IF(OBJ.LE.0) GO TO 6000
  147. C !IF LE, COULDNT.
  148. C
  149. 650 IF(PREP.EQ.9) GO TO 8000
  150. C !"OF" OBJ?
  151. IF(PPTR.EQ.2) GO TO 7000
  152. C !TOO MANY OBJS?
  153. PPTR=PPTR+1
  154. OBJVEC(PPTR)=OBJ
  155. C !STUFF INTO VECTOR.
  156. PRPVEC(PPTR)=PREP
  157. 700 PREP=0
  158. ADJ=0
  159. C Go to end of do loop (moved "1000 CONTINUE" to end of module, to avoid
  160. C complaints about people jumping back into the doloop.)
  161. GOTO 1000
  162. C SPARSE, PAGE 10
  163. C
  164. C SPECIAL PARSE PROCESSORS
  165. C
  166. C 2000-- DIRECTION
  167. C
  168. 2000 PRSA=WALKW
  169. PRSO=DVOC(J+2)
  170. SPARSE=1
  171. D IF(DFLAG) PRINT 10,J
  172. D10 FORMAT(' SPARSE- DIR AT ',I6)
  173. RETURN
  174. C
  175. C 3000-- ACTION
  176. C
  177. 3000 ACT=J
  178. OACT=0
  179. D IF(DFLAG) PRINT 20,J
  180. D20 FORMAT(' SPARSE- ACT AT ',I6)
  181. D if(dflag) write(0,*) 'count=',vvoc(j+2),' vnr=',vvoc(j+3)
  182. GO TO 1000
  183. C
  184. C 4000-- PREPOSITION
  185. C
  186. 4000 IF(PREP.NE.0) GO TO 4500
  187. PREP=PVOC(J+2)
  188. ADJ=0
  189. D IF(DFLAG) PRINT 30,J
  190. D30 FORMAT(' SPARSE- PREP AT ',I6)
  191. GO TO 1000
  192. C
  193. 4500 IF(VBFLAG) CALL RSPEAK(616)
  194. RETURN
  195. C
  196. C 5000-- ADJECTIVE
  197. C
  198. 5000 ADJ=J
  199. J=(IAND(ONAME,OFLAG))
  200. D IF(DFLAG) PRINT 40,ADJ,J
  201. D40 FORMAT(' SPARSE- ADJ AT ',I6,' ORPHAN= ',I6)
  202. IF((J.NE.0).AND.(I.GE.LLNT)) GO TO 600
  203. GO TO 1000
  204. C
  205. C 6000-- UNIDENTIFIABLE OBJECT (INDEX INTO OVOC IS J)
  206. C
  207. 6000 IF(OBJ.LT.0) GO TO 6100
  208. J=579
  209. IF(LIT(HERE)) J=618
  210. IF(VBFLAG) CALL RSPEAK(J)
  211. RETURN
  212. C
  213. 6100 IF(OBJ.NE.-10000) GO TO 6200
  214. IF(VBFLAG) CALL RSPSUB(620,ODESC2(AVEHIC(WINNER)))
  215. RETURN
  216. C
  217. 6200 IF(VBFLAG) CALL RSPEAK(619)
  218. IF(ACT.EQ.0) ACT=(IAND(OFLAG,OACT))
  219. CALL ORPHAN(-1,ACT,O1,PREP,J)
  220. RETURN
  221. C
  222. C 7000-- TOO MANY OBJECTS.
  223. C
  224. 7000 IF(VBFLAG) CALL RSPEAK(617)
  225. RETURN
  226. C
  227. C 8000-- RANDOMNESS FOR "OF" WORDS
  228. C
  229. 8000 IF(OBJVEC(PPTR).EQ.OBJ) GO TO 700
  230. IF(VBFLAG) CALL RSPEAK(601)
  231. RETURN
  232. C
  233. C End of do-loop.
  234. C
  235. 1000 CONTINUE
  236. C !AT LAST.
  237. C
  238. C NOW SOME MISC CLEANUP -- We fell out of the do-loop
  239. C
  240. 1500 IF(ACT.EQ.0) ACT=(IAND(OFLAG,OACT))
  241. IF(ACT.EQ.0) GO TO 9000
  242. C !IF STILL NONE, PUNT.
  243. IF(ADJ.NE.0) GO TO 10000
  244. C !IF DANGLING ADJ, PUNT.
  245. C
  246. IF((OFLAG.NE.0).AND.(OPREP.NE.0).AND.(PREP.EQ.0).AND.
  247. & (O1.NE.0).AND.(O2.EQ.0).AND.(ACT.EQ.OACT))
  248. & GO TO 11000
  249. C
  250. SPARSE=0
  251. C !PARSE SUCCEEDS.
  252. IF(PREP.EQ.0) GO TO 1750
  253. C !IF DANGLING PREP,
  254. IF((PPTR.EQ.0).OR.(PRPVEC(PPTR).NE.0))
  255. & GO TO 12000
  256. PRPVEC(PPTR)=PREP
  257. C !CVT TO 'PICK UP FROB'.
  258. C
  259. C 1750-- RETURN A RESULT
  260. C
  261. 1750 CONTINUE
  262. C !WIN.
  263. D IF(DFLAG) PRINT 70,ACT,O1,O2,P1,P2
  264. D70 FORMAT(' SPARSE RESULTS- ',5I7)
  265. D if(dflag) write(0,*) 'sparse=',sparse
  266. RETURN
  267. C !LOSE.
  268. C
  269. C 9000-- NO ACTION, PUNT
  270. C
  271. 9000 IF(O1.EQ.0) GO TO 10000
  272. C !ANY DIRECT OBJECT?
  273. IF(VBFLAG) CALL RSPSUB(621,ODESC2(O1))
  274. C !WHAT TO DO?
  275. CALL ORPHAN(-1,0,O1,0,0)
  276. RETURN
  277. C
  278. C 10000-- TOTAL CHOMP
  279. C
  280. 10000 IF(VBFLAG) CALL RSPEAK(622)
  281. C !HUH?
  282. RETURN
  283. C
  284. C 11000-- ORPHAN PREPOSITION. CONDITIONS ARE
  285. C O1.NE.0, O2=0, PREP=0, ACT=OACT
  286. C
  287. 11000 IF(OSLOT.NE.0) GO TO 11500
  288. C !ORPHAN OBJECT?
  289. P1=OPREP
  290. C !NO, JUST USE PREP.
  291. GO TO 1750
  292. C
  293. 11500 O2=O1
  294. C !YES, USE AS DIRECT OBJ.
  295. P2=OPREP
  296. O1=OSLOT
  297. P1=0
  298. GO TO 1750
  299. C
  300. C 12000-- TRUE HANGING PREPOSITION.
  301. C ORPHAN FOR LATER.
  302. C
  303. 12000 CALL ORPHAN(-1,ACT,0,PREP,0)
  304. C !ORPHAN PREP.
  305. GO TO 1750
  306. C
  307. END