-
Notifications
You must be signed in to change notification settings - Fork 33
/
gparser.zap
1612 lines (1527 loc) · 33.7 KB
/
gparser.zap
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
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.FUNCT PARSER,PTR=P-LEXSTART,WRD,VAL=0,VERB=0,OF-FLAG=0,OWINNER,OMERGED,LEN,DIR=0,NW=0,LW=0,CNT=-1,?TMP2,?TMP1
?PRG1: IGRTR? 'CNT,P-ITBLLEN \?ELS5
JUMP ?REP2
?ELS5: ZERO? P-OFLAG \?CND8
GET P-ITBL,CNT
PUT P-OTBL,CNT,STACK
?CND8: PUT P-ITBL,CNT,0
JUMP ?PRG1
?REP2: SET 'OWINNER,WINNER
SET 'OMERGED,P-MERGED
SET 'P-ADVERB,FALSE-VALUE
SET 'P-MERGED,FALSE-VALUE
SET 'P-END-ON-PREP,FALSE-VALUE
PUT P-PRSO,P-MATCHLEN,0
PUT P-PRSI,P-MATCHLEN,0
PUT P-BUTS,P-MATCHLEN,0
ZERO? QUOTE-FLAG \?CND11
EQUAL? WINNER,PLAYER /?CND11
SET 'WINNER,PLAYER
CALL META-LOC,PLAYER >HERE
CALL LIT?,HERE >LIT
?CND11: ZERO? RESERVE-PTR /?ELS18
SET 'PTR,RESERVE-PTR
CALL STUFF,RESERVE-LEXV,P-LEXV
ZERO? SUPER-BRIEF \?CND20
EQUAL? PLAYER,WINNER \?CND20
CRLF
?CND20: SET 'RESERVE-PTR,FALSE-VALUE
SET 'P-CONT,FALSE-VALUE
JUMP ?CND16
?ELS18: ZERO? P-CONT /?ELS26
SET 'PTR,P-CONT
ZERO? SUPER-BRIEF \?CND28
EQUAL? PLAYER,WINNER \?CND28
EQUAL? PRSA,V?SAY /?CND28
CRLF
?CND28: SET 'P-CONT,FALSE-VALUE
JUMP ?CND16
?ELS26: SET 'WINNER,PLAYER
SET 'QUOTE-FLAG,FALSE-VALUE
LOC WINNER
FSET? STACK,VEHBIT /?CND35
LOC WINNER >HERE
?CND35: CALL LIT?,HERE >LIT
ZERO? SUPER-BRIEF \?CND38
CRLF
?CND38: PRINTI ">"
READ P-INBUF,P-LEXV
?CND16: GETB P-LEXV,P-LEXWORDS >P-LEN
ZERO? P-LEN \?CND43
PRINTI "I beg your pardon?"
CRLF
RFALSE
?CND43: GET P-LEXV,PTR >WRD
EQUAL? WRD,W?OOPS \?ELS50
ADD PTR,P-LEXELEN
GET P-LEXV,STACK
EQUAL? STACK,W?PERIOD,W?COMMA \?CND51
ADD PTR,P-LEXELEN >PTR
DEC 'P-LEN
?CND51: GRTR? P-LEN,1 /?ELS56
PRINTI "I can't help your clumsiness."
CRLF
RFALSE
?ELS56: GET OOPS-TABLE,O-PTR
ZERO? STACK /?ELS60
GRTR? P-LEN,2 \?ELS63
ADD PTR,P-LEXELEN
GET P-LEXV,STACK
EQUAL? STACK,W?QUOTE \?ELS63
PRINTI "Sorry, you can't correct mistakes in quoted text."
CRLF
RFALSE
?ELS63: GRTR? P-LEN,2 \?CND61
PRINTI "Warning: only the first word after OOPS is used."
CRLF
?CND61: GET OOPS-TABLE,O-PTR >?TMP1
ADD PTR,P-LEXELEN
GET P-LEXV,STACK
PUT AGAIN-LEXV,?TMP1,STACK
SET 'WINNER,OWINNER
MUL PTR,P-LEXELEN
ADD STACK,6
GETB P-LEXV,STACK >?TMP2
MUL PTR,P-LEXELEN
ADD STACK,7
GETB P-LEXV,STACK >?TMP1
GET OOPS-TABLE,O-PTR
MUL STACK,P-LEXELEN
ADD STACK,3
CALL INBUF-ADD,?TMP2,?TMP1,STACK
CALL STUFF,AGAIN-LEXV,P-LEXV
GETB P-LEXV,P-LEXWORDS >P-LEN
GET OOPS-TABLE,O-START >PTR
CALL INBUF-STUFF,OOPS-INBUF,P-INBUF
JUMP ?CND48
?ELS60: PUT OOPS-TABLE,O-END,FALSE-VALUE
PRINTI "There was no word to replace!"
CRLF
RFALSE
?ELS50: EQUAL? WRD,W?AGAIN,W?G /?CND78
SET 'P-NUMBER,0
?CND78: PUT OOPS-TABLE,O-END,FALSE-VALUE
?CND48: GET P-LEXV,PTR
EQUAL? STACK,W?AGAIN,W?G \?ELS83
GETB OOPS-INBUF,1
ZERO? STACK \?ELS86
PRINTI "Beg pardon?"
CRLF
RFALSE
?ELS86: ZERO? P-OFLAG /?ELS90
PRINTI "It's difficult to repeat fragments."
CRLF
RFALSE
?ELS90: ZERO? P-WON \?ELS95
PRINTI "That would just repeat a mistake."
CRLF
RFALSE
?ELS95: GRTR? P-LEN,1 \?ELS99
ADD PTR,P-LEXELEN
GET P-LEXV,STACK
EQUAL? STACK,W?PERIOD,W?COMMA,W?THEN /?THN103
ADD PTR,P-LEXELEN
GET P-LEXV,STACK
EQUAL? STACK,W?AND \?ELS102
?THN103: MUL 2,P-LEXELEN
ADD PTR,STACK >PTR
GETB P-LEXV,P-LEXWORDS
SUB STACK,2
PUTB P-LEXV,P-LEXWORDS,STACK
JUMP ?CND84
?ELS102: PRINTI "I couldn't understand that sentence."
CRLF
RFALSE
?ELS99: ADD PTR,P-LEXELEN >PTR
GETB P-LEXV,P-LEXWORDS
SUB STACK,1
PUTB P-LEXV,P-LEXWORDS,STACK
?CND84: GETB P-LEXV,P-LEXWORDS
GRTR? STACK,0 \?ELS113
CALL STUFF,P-LEXV,RESERVE-LEXV
SET 'RESERVE-PTR,PTR
JUMP ?CND111
?ELS113: SET 'RESERVE-PTR,FALSE-VALUE
?CND111: SET 'WINNER,OWINNER
SET 'P-MERGED,OMERGED
CALL INBUF-STUFF,OOPS-INBUF,P-INBUF
CALL STUFF,AGAIN-LEXV,P-LEXV
SET 'CNT,-1
SET 'DIR,AGAIN-DIR
?PRG116: IGRTR? 'CNT,P-ITBLLEN \?ELS120
JUMP ?CND81
?ELS120: GET P-OTBL,CNT
PUT P-ITBL,CNT,STACK
JUMP ?PRG116
?ELS83: CALL STUFF,P-LEXV,AGAIN-LEXV
CALL INBUF-STUFF,P-INBUF,OOPS-INBUF
PUT OOPS-TABLE,O-START,PTR
MUL 4,P-LEN
PUT OOPS-TABLE,O-LENGTH,STACK
GETB P-LEXV,P-LEXWORDS
MUL P-LEXELEN,STACK
ADD PTR,STACK
MUL 2,STACK >LEN
SUB LEN,1
GETB P-LEXV,STACK >?TMP1
SUB LEN,2
GETB P-LEXV,STACK
ADD ?TMP1,STACK
PUT OOPS-TABLE,O-END,STACK
SET 'RESERVE-PTR,FALSE-VALUE
SET 'LEN,P-LEN
SET 'P-DIR,FALSE-VALUE
SET 'P-NCN,0
SET 'P-GETFLAGS,0
?PRG125: DLESS? 'P-LEN,0 \?ELS129
SET 'QUOTE-FLAG,FALSE-VALUE
JUMP ?CND81
?ELS129: GET P-LEXV,PTR >WRD
ZERO? WRD \?THN132
CALL NUMBER?,PTR >WRD
ZERO? WRD /?ELS131
?THN132: ZERO? P-LEN \?ELS136
SET 'NW,0
JUMP ?CND134
?ELS136: ADD PTR,P-LEXELEN
GET P-LEXV,STACK >NW
?CND134: EQUAL? WRD,W?TO \?ELS141
EQUAL? VERB,ACT?TELL \?ELS141
SET 'WRD,W?QUOTE
JUMP ?CND139
?ELS141: EQUAL? WRD,W?THEN \?CND139
GRTR? P-LEN,0 \?CND139
ZERO? VERB \?CND139
ZERO? QUOTE-FLAG \?CND139
EQUAL? LW,0,W?PERIOD \?ELS150
SET 'WRD,W?THE
JUMP ?CND139
?ELS150: PUT P-ITBL,P-VERB,ACT?TELL
PUT P-ITBL,P-VERBN,0
SET 'WRD,W?QUOTE
?CND139: EQUAL? WRD,W?THEN,W?PERIOD,W?QUOTE \?ELS155
EQUAL? WRD,W?QUOTE \?CND156
ZERO? QUOTE-FLAG /?ELS161
SET 'QUOTE-FLAG,FALSE-VALUE
JUMP ?CND156
?ELS161: SET 'QUOTE-FLAG,TRUE-VALUE
?CND156: ZERO? P-LEN /?THN165
ADD PTR,P-LEXELEN >P-CONT
?THN165: PUTB P-LEXV,P-LEXWORDS,P-LEN
JUMP ?CND81
?ELS155: CALL WT?,WRD,PS?DIRECTION,P1?DIRECTION >VAL
ZERO? VAL /?ELS168
EQUAL? VERB,FALSE-VALUE,ACT?WALK \?ELS168
EQUAL? LEN,1 /?THN171
EQUAL? LEN,2 \?ELS174
EQUAL? VERB,ACT?WALK /?THN171
?ELS174: EQUAL? NW,W?THEN,W?PERIOD,W?QUOTE \?ELS176
LESS? LEN,2 \?THN171
?ELS176: ZERO? QUOTE-FLAG /?ELS178
EQUAL? LEN,2 \?ELS178
EQUAL? NW,W?QUOTE /?THN171
?ELS178: GRTR? LEN,2 \?ELS168
EQUAL? NW,W?COMMA,W?AND \?ELS168
?THN171: SET 'DIR,VAL
EQUAL? NW,W?COMMA,W?AND \?CND181
ADD PTR,P-LEXELEN
PUT P-LEXV,STACK,W?THEN
?CND181: GRTR? LEN,2 /?CND127
SET 'QUOTE-FLAG,FALSE-VALUE
JUMP ?CND81
?ELS168: CALL WT?,WRD,PS?VERB,P1?VERB >VAL
ZERO? VAL /?ELS188
ZERO? VERB \?ELS188
SET 'VERB,VAL
PUT P-ITBL,P-VERB,VAL
PUT P-ITBL,P-VERBN,P-VTBL
PUT P-VTBL,0,WRD
MUL PTR,2
ADD STACK,2 >CNT
GETB P-LEXV,CNT
PUTB P-VTBL,2,STACK
ADD CNT,1
GETB P-LEXV,STACK
PUTB P-VTBL,3,STACK
JUMP ?CND127
?ELS188: CALL WT?,WRD,PS?PREPOSITION,0 >VAL
ZERO? VAL \?THN193
EQUAL? WRD,W?ALL,W?ONE /?THN197
CALL WT?,WRD,PS?ADJECTIVE
ZERO? STACK \?THN197
CALL WT?,WRD,PS?OBJECT
ZERO? STACK /?ELS192
?THN197: SET 'VAL,0 \?ELS192
?THN193: GRTR? P-LEN,1 \?ELS201
EQUAL? NW,W?OF \?ELS201
ZERO? VAL \?ELS201
EQUAL? WRD,W?ALL,W?ONE,W?A /?ELS201
SET 'OF-FLAG,TRUE-VALUE
JUMP ?CND127
?ELS201: ZERO? VAL /?ELS205
ZERO? P-LEN /?THN208
EQUAL? NW,W?THEN,W?PERIOD \?ELS205
?THN208: SET 'P-END-ON-PREP,TRUE-VALUE
LESS? P-NCN,2 \?CND127
PUT P-ITBL,P-PREP1,VAL
PUT P-ITBL,P-PREP1N,WRD
JUMP ?CND127
?ELS205: EQUAL? P-NCN,2 \?ELS214
PRINTI "There were too many nouns in that sentence."
CRLF
RFALSE
?ELS214: INC 'P-NCN
SET 'P-ACT,VERB
CALL CLAUSE,PTR,VAL,WRD >PTR
ZERO? PTR /FALSE
LESS? PTR,0 \?CND127
SET 'QUOTE-FLAG,FALSE-VALUE
JUMP ?CND81
?ELS192: EQUAL? WRD,W?OF \?ELS225
ZERO? OF-FLAG /?THN229
EQUAL? NW,W?PERIOD,W?THEN \?ELS228
?THN229: CALL CANT-USE,PTR
RFALSE
?ELS228: SET 'OF-FLAG,FALSE-VALUE
JUMP ?CND127
?ELS225: CALL WT?,WRD,PS?BUZZ-WORD
ZERO? STACK /?ELS234
JUMP ?CND127
?ELS234: EQUAL? VERB,ACT?TELL \?ELS236
CALL WT?,WRD,PS?VERB,P1?VERB
ZERO? STACK /?ELS236
EQUAL? WINNER,PLAYER \?ELS236
PRINTI "Please consult your manual for the correct way to talk to other people or creatures."
CRLF
RFALSE
?ELS236: CALL CANT-USE,PTR
RFALSE
?ELS131: CALL UNKNOWN-WORD,PTR
RFALSE
?CND127: SET 'LW,WRD
ADD PTR,P-LEXELEN >PTR
JUMP ?PRG125
?CND81: PUT OOPS-TABLE,O-PTR,FALSE-VALUE
ZERO? DIR /?ELS249
SET 'PRSA,V?WALK
SET 'PRSO,DIR
SET 'P-OFLAG,FALSE-VALUE
SET 'P-WALK-DIR,DIR
SET 'AGAIN-DIR,DIR
RETURN AGAIN-DIR
?ELS249: ZERO? P-OFLAG /?CND253
CALL ORPHAN-MERGE
?CND253: SET 'P-WALK-DIR,FALSE-VALUE
SET 'AGAIN-DIR,FALSE-VALUE
CALL SYNTAX-CHECK
ZERO? STACK /FALSE
CALL SNARF-OBJECTS
ZERO? STACK /FALSE
CALL MANY-CHECK
ZERO? STACK /FALSE
CALL TAKE-CHECK
ZERO? STACK /FALSE
RTRUE
.FUNCT STUFF,SRC,DEST,MAX=29,PTR=P-LEXSTART,CTR=1,BPTR
GETB SRC,0
PUTB DEST,0,STACK
GETB SRC,1
PUTB DEST,1,STACK
?PRG1: GET SRC,PTR
PUT DEST,PTR,STACK
MUL PTR,2
ADD STACK,2 >BPTR
GETB SRC,BPTR
PUTB DEST,BPTR,STACK
MUL PTR,2
ADD STACK,3 >BPTR
GETB SRC,BPTR
PUTB DEST,BPTR,STACK
ADD PTR,P-LEXELEN >PTR
IGRTR? 'CTR,MAX \?PRG1
RTRUE
.FUNCT INBUF-STUFF,SRC,DEST,CNT
GETB SRC,0
SUB STACK,1 >CNT
?PRG1: GETB SRC,CNT
PUTB DEST,CNT,STACK
DLESS? 'CNT,0 \?PRG1
RTRUE
.FUNCT INBUF-ADD,LEN,BEG,SLOT,DBEG,CTR=0,TMP,?TMP1
GET OOPS-TABLE,O-END >TMP
ZERO? TMP /?ELS3
SET 'DBEG,TMP
JUMP ?CND1
?ELS3: GET OOPS-TABLE,O-LENGTH >TMP
GETB AGAIN-LEXV,TMP >?TMP1
ADD TMP,1
GETB AGAIN-LEXV,STACK
ADD ?TMP1,STACK >DBEG
?CND1: ADD DBEG,LEN
PUT OOPS-TABLE,O-END,STACK
?PRG6: ADD DBEG,CTR >?TMP1
ADD BEG,CTR
GETB P-INBUF,STACK
PUTB OOPS-INBUF,?TMP1,STACK
INC 'CTR
EQUAL? CTR,LEN \?PRG6
PUTB AGAIN-LEXV,SLOT,DBEG
SUB SLOT,1
PUTB AGAIN-LEXV,STACK,LEN
RTRUE
.FUNCT WT?,PTR,BIT,B1=5,OFFS=P-P1OFF,TYP
GETB PTR,P-PSOFF >TYP
BTST TYP,BIT \FALSE
GRTR? B1,4 /TRUE
BAND TYP,P-P1BITS >TYP
EQUAL? TYP,B1 /?CND13
INC 'OFFS
?CND13: GETB PTR,OFFS
RSTACK
.FUNCT CLAUSE,PTR,VAL,WRD,OFF,NUM,ANDFLG=0,FIRST??=1,NW,LW=0,?TMP1
SUB P-NCN,1
MUL STACK,2 >OFF
ZERO? VAL /?ELS3
ADD P-PREP1,OFF >NUM
PUT P-ITBL,NUM,VAL
ADD NUM,1
PUT P-ITBL,STACK,WRD
ADD PTR,P-LEXELEN >PTR
JUMP ?CND1
?ELS3: INC 'P-LEN
?CND1: ZERO? P-LEN \?CND6
DEC 'P-NCN
RETURN -1
?CND6: ADD P-NC1,OFF >NUM
MUL PTR,2
ADD P-LEXV,STACK
PUT P-ITBL,NUM,STACK
GET P-LEXV,PTR
EQUAL? STACK,W?THE,W?A,W?AN \?CND9
GET P-ITBL,NUM
ADD STACK,4
PUT P-ITBL,NUM,STACK
?CND9:
?PRG12: DLESS? 'P-LEN,0 \?CND14
ADD NUM,1 >?TMP1
MUL PTR,2
ADD P-LEXV,STACK
PUT P-ITBL,?TMP1,STACK
RETURN -1
?CND14: GET P-LEXV,PTR >WRD
ZERO? WRD \?THN20
CALL NUMBER?,PTR >WRD
ZERO? WRD /?ELS19
?THN20: ZERO? P-LEN \?ELS24
SET 'NW,0
JUMP ?CND22
?ELS24: ADD PTR,P-LEXELEN
GET P-LEXV,STACK >NW
?CND22: EQUAL? WRD,W?AND,W?COMMA \?ELS29
SET 'ANDFLG,TRUE-VALUE
JUMP ?CND17
?ELS29: EQUAL? WRD,W?ALL,W?ONE \?ELS31
EQUAL? NW,W?OF \?CND17
DEC 'P-LEN
ADD PTR,P-LEXELEN >PTR
JUMP ?CND17
?ELS31: EQUAL? WRD,W?THEN,W?PERIOD /?THN37
CALL WT?,WRD,PS?PREPOSITION
ZERO? STACK /?ELS36
GET P-ITBL,P-VERB
ZERO? STACK /?ELS36
ZERO? FIRST?? \?ELS36
?THN37: INC 'P-LEN
ADD NUM,1 >?TMP1
MUL PTR,2
ADD P-LEXV,STACK
PUT P-ITBL,?TMP1,STACK
SUB PTR,P-LEXELEN
RSTACK
?ELS36: CALL WT?,WRD,PS?OBJECT
ZERO? STACK /?ELS42
GRTR? P-LEN,0 \?ELS45
EQUAL? NW,W?OF \?ELS45
EQUAL? WRD,W?ALL,W?ONE /?ELS45
JUMP ?CND17
?ELS45: CALL WT?,WRD,PS?ADJECTIVE,P1?ADJECTIVE
ZERO? STACK /?ELS49
ZERO? NW /?ELS49
CALL WT?,NW,PS?OBJECT
ZERO? STACK /?ELS49
JUMP ?CND17
?ELS49: ZERO? ANDFLG \?ELS53
EQUAL? NW,W?BUT,W?EXCEPT /?ELS53
EQUAL? NW,W?AND,W?COMMA /?ELS53
ADD NUM,1 >?TMP1
ADD PTR,2
MUL STACK,2
ADD P-LEXV,STACK
PUT P-ITBL,?TMP1,STACK
RETURN PTR
?ELS53: SET 'ANDFLG,FALSE-VALUE
JUMP ?CND17
?ELS42: ZERO? P-MERGED \?THN62
ZERO? P-OFLAG \?THN62
GET P-ITBL,P-VERB
ZERO? STACK /?ELS59
?THN62: CALL WT?,WRD,PS?ADJECTIVE
ZERO? STACK \?CND17
CALL WT?,WRD,PS?BUZZ-WORD
ZERO? STACK /?ELS59
JUMP ?CND17
?ELS59: ZERO? ANDFLG /?ELS67
CALL WT?,WRD,PS?DIRECTION
ZERO? STACK \?THN70
CALL WT?,WRD,PS?VERB
ZERO? STACK /?ELS67
?THN70: SUB PTR,4 >PTR
ADD PTR,2
PUT P-LEXV,STACK,W?THEN
ADD P-LEN,2 >P-LEN
JUMP ?CND17
?ELS67: CALL WT?,WRD,PS?PREPOSITION
ZERO? STACK /?ELS73
JUMP ?CND17
?ELS73: CALL CANT-USE,PTR
RFALSE
?ELS19: CALL UNKNOWN-WORD,PTR
RFALSE
?CND17: SET 'LW,WRD
SET 'FIRST??,FALSE-VALUE
ADD PTR,P-LEXELEN >PTR
JUMP ?PRG12
.FUNCT NUMBER?,PTR,CNT,BPTR,CHR,SUM=0,TIM=0,?TMP1
MUL PTR,2
ADD P-LEXV,STACK
GETB STACK,2 >CNT
MUL PTR,2
ADD P-LEXV,STACK
GETB STACK,3 >BPTR
?PRG1: DLESS? 'CNT,0 \?ELS5
JUMP ?REP2
?ELS5: GETB P-INBUF,BPTR >CHR
EQUAL? CHR,58 \?ELS10
SET 'TIM,SUM
SET 'SUM,0
JUMP ?CND8
?ELS10: GRTR? SUM,10000 /FALSE
LESS? CHR,58 \FALSE
GRTR? CHR,47 \FALSE
MUL SUM,10 >?TMP1
SUB CHR,48
ADD ?TMP1,STACK >SUM
?CND8: INC 'BPTR
JUMP ?PRG1
?REP2: PUT P-LEXV,PTR,W?INTNUM
GRTR? SUM,1000 /FALSE
ZERO? TIM /?CND19
LESS? TIM,8 \?ELS27
ADD TIM,12 >TIM
JUMP ?CND25
?ELS27: GRTR? TIM,23 /FALSE
?CND25: MUL TIM,60
ADD SUM,STACK >SUM
?CND19: SET 'P-NUMBER,SUM
RETURN W?INTNUM
.FUNCT ORPHAN-MERGE,CNT=-1,TEMP,VERB,BEG,END,ADJ=0,WRD,?TMP1
SET 'P-OFLAG,FALSE-VALUE
GET P-ITBL,P-VERBN
GET STACK,0 >WRD
CALL WT?,WRD,PS?VERB,P1?VERB >?TMP1
GET P-OTBL,P-VERB
EQUAL? ?TMP1,STACK /?THN4
CALL WT?,WRD,PS?ADJECTIVE
ZERO? STACK /?ELS3
?THN4: SET 'ADJ,TRUE-VALUE
JUMP ?CND1
?ELS3: CALL WT?,WRD,PS?OBJECT,P1?OBJECT
ZERO? STACK /?CND1
ZERO? P-NCN \?CND1
PUT P-ITBL,P-VERB,0
PUT P-ITBL,P-VERBN,0
ADD P-LEXV,2
PUT P-ITBL,P-NC1,STACK
ADD P-LEXV,6
PUT P-ITBL,P-NC1L,STACK
SET 'P-NCN,1
?CND1: GET P-ITBL,P-VERB >VERB
ZERO? VERB /?ELS12
ZERO? ADJ \?ELS12
GET P-OTBL,P-VERB
EQUAL? VERB,STACK \FALSE
?ELS12: EQUAL? P-NCN,2 /FALSE
GET P-OTBL,P-NC1
EQUAL? STACK,1 \?ELS18
GET P-ITBL,P-PREP1 >TEMP
GET P-OTBL,P-PREP1
EQUAL? TEMP,STACK /?THN22
ZERO? TEMP \FALSE
?THN22: ZERO? ADJ /?ELS26
ADD P-LEXV,2
PUT P-OTBL,P-NC1,STACK
GET P-ITBL,P-NC1L
ZERO? STACK \?CND28
ADD P-LEXV,6
PUT P-ITBL,P-NC1L,STACK
?CND28: ZERO? P-NCN \?CND24
SET 'P-NCN,1
JUMP ?CND24
?ELS26: GET P-ITBL,P-NC1
PUT P-OTBL,P-NC1,STACK
?CND24: GET P-ITBL,P-NC1L
PUT P-OTBL,P-NC1L,STACK
JUMP ?CND10
?ELS18: GET P-OTBL,P-NC2
EQUAL? STACK,1 \?ELS39
GET P-ITBL,P-PREP1 >TEMP
GET P-OTBL,P-PREP2
EQUAL? TEMP,STACK /?THN43
ZERO? TEMP \FALSE
?THN43: ZERO? ADJ /?CND45
ADD P-LEXV,2
PUT P-ITBL,P-NC1,STACK
GET P-ITBL,P-NC1L
ZERO? STACK \?CND45
ADD P-LEXV,6
PUT P-ITBL,P-NC1L,STACK
?CND45: GET P-ITBL,P-NC1
PUT P-OTBL,P-NC2,STACK
GET P-ITBL,P-NC1L
PUT P-OTBL,P-NC2L,STACK
SET 'P-NCN,2
JUMP ?CND10
?ELS39: ZERO? P-ACLAUSE /?CND10
EQUAL? P-NCN,1 /?ELS58
ZERO? ADJ \?ELS58
SET 'P-ACLAUSE,FALSE-VALUE
RFALSE
?ELS58: GET P-ITBL,P-NC1 >BEG
ZERO? ADJ /?CND63
ADD P-LEXV,2 >BEG
SET 'ADJ,FALSE-VALUE
?CND63: GET P-ITBL,P-NC1L >END
?PRG67: GET BEG,0 >WRD
EQUAL? BEG,END \?ELS71
ZERO? ADJ /?ELS74
CALL ACLAUSE-WIN,ADJ
JUMP ?CND56
?ELS74: SET 'P-ACLAUSE,FALSE-VALUE
RFALSE
?ELS71: ZERO? ADJ \?ELS79
GETB WRD,P-PSOFF
BTST STACK,PS?ADJECTIVE /?THN82
EQUAL? WRD,W?ALL,W?ONE \?ELS79
?THN82: SET 'ADJ,WRD
JUMP ?CND69
?ELS79: EQUAL? WRD,W?ONE \?ELS85
CALL ACLAUSE-WIN,ADJ
JUMP ?CND56
?ELS85: GETB WRD,P-PSOFF
BTST STACK,PS?OBJECT \?CND69
EQUAL? WRD,P-ANAM \?ELS90
CALL ACLAUSE-WIN,ADJ
JUMP ?CND10
?ELS90: CALL NCLAUSE-WIN
JUMP ?CND10
?CND69: ADD BEG,P-WORDLEN >BEG
ZERO? END \?PRG67
SET 'END,BEG
SET 'P-NCN,1
SUB BEG,4
PUT P-ITBL,P-NC1,STACK
PUT P-ITBL,P-NC1L,BEG
JUMP ?PRG67
?CND56:
?CND10: GET P-OVTBL,0
PUT P-VTBL,0,STACK
GETB P-OVTBL,2
PUTB P-VTBL,2,STACK
GETB P-OVTBL,3
PUTB P-VTBL,3,STACK
PUT P-OTBL,P-VERBN,P-VTBL
PUTB P-VTBL,2,0
?PRG96: IGRTR? 'CNT,P-ITBLLEN \?ELS100
SET 'P-MERGED,TRUE-VALUE
RTRUE
?ELS100: GET P-OTBL,CNT
PUT P-ITBL,CNT,STACK
JUMP ?PRG96
.FUNCT ACLAUSE-WIN,ADJ
GET P-OTBL,P-VERB
PUT P-ITBL,P-VERB,STACK
PUT P-CCTBL,CC-SBPTR,P-ACLAUSE
ADD P-ACLAUSE,1
PUT P-CCTBL,CC-SEPTR,STACK
PUT P-CCTBL,CC-DBPTR,P-ACLAUSE
ADD P-ACLAUSE,1
PUT P-CCTBL,CC-DEPTR,STACK
CALL CLAUSE-COPY,P-OTBL,P-OTBL,ADJ
GET P-OTBL,P-NC2
ZERO? STACK /?ELS2
SET 'P-NCN,2
?ELS2: SET 'P-ACLAUSE,FALSE-VALUE
RTRUE
.FUNCT NCLAUSE-WIN
PUT P-CCTBL,CC-SBPTR,P-NC1
PUT P-CCTBL,CC-SEPTR,P-NC1L
PUT P-CCTBL,CC-DBPTR,P-ACLAUSE
ADD P-ACLAUSE,1
PUT P-CCTBL,CC-DEPTR,STACK
CALL CLAUSE-COPY,P-ITBL,P-OTBL
GET P-OTBL,P-NC2
ZERO? STACK /?ELS2
SET 'P-NCN,2
?ELS2: SET 'P-ACLAUSE,FALSE-VALUE
RTRUE
.FUNCT WORD-PRINT,CNT,BUF
?PRG1: DLESS? 'CNT,0 /TRUE
GETB P-INBUF,BUF
PRINTC STACK
INC 'BUF
JUMP ?PRG1
.FUNCT UNKNOWN-WORD,PTR,BUF,?TMP1
PUT OOPS-TABLE,O-PTR,PTR
EQUAL? PRSA,V?SAY \?CND1
PRINTI "Nothing happens."
CRLF
RFALSE
?CND1: PRINTI "I don't know the word """
MUL PTR,2 >BUF
ADD P-LEXV,BUF
GETB STACK,2 >?TMP1
ADD P-LEXV,BUF
GETB STACK,3
CALL WORD-PRINT,?TMP1,STACK
PRINTI """."
CRLF
SET 'QUOTE-FLAG,FALSE-VALUE
SET 'P-OFLAG,FALSE-VALUE
RETURN P-OFLAG
.FUNCT CANT-USE,PTR,BUF,?TMP1
EQUAL? PRSA,V?SAY \?CND1
PRINTI "Nothing happens."
CRLF
RFALSE
?CND1: PRINTI "You used the word """
MUL PTR,2 >BUF
ADD P-LEXV,BUF
GETB STACK,2 >?TMP1
ADD P-LEXV,BUF
GETB STACK,3
CALL WORD-PRINT,?TMP1,STACK
PRINTI """ in a way that I don't understand."
CRLF
SET 'QUOTE-FLAG,FALSE-VALUE
SET 'P-OFLAG,FALSE-VALUE
RETURN P-OFLAG
.FUNCT SYNTAX-CHECK,SYN,LEN,NUM,OBJ,DRIVE1=0,DRIVE2=0,PREP,VERB,TMP,?TMP2,?TMP1
GET P-ITBL,P-VERB >VERB
ZERO? VERB \?CND1
PRINTI "There was no verb in that sentence!"
CRLF
RFALSE
?CND1: SUB 255,VERB
GET VERBS,STACK >SYN
GETB SYN,0 >LEN
INC 'SYN
?PRG6: GETB SYN,P-SBITS
BAND STACK,P-SONUMS >NUM
GRTR? P-NCN,NUM \?ELS10
JUMP ?CND8
?ELS10: LESS? NUM,1 /?ELS12
ZERO? P-NCN \?ELS12
GET P-ITBL,P-PREP1 >PREP
ZERO? PREP /?THN15
GETB SYN,P-SPREP1
EQUAL? PREP,STACK \?ELS12
?THN15: SET 'DRIVE1,SYN
JUMP ?CND8
?ELS12: GETB SYN,P-SPREP1 >?TMP1
GET P-ITBL,P-PREP1
EQUAL? ?TMP1,STACK \?CND8
EQUAL? NUM,2 \?ELS21
EQUAL? P-NCN,1 \?ELS21
SET 'DRIVE2,SYN
JUMP ?CND8
?ELS21: GETB SYN,P-SPREP2 >?TMP1
GET P-ITBL,P-PREP2
EQUAL? ?TMP1,STACK \?CND8
CALL SYNTAX-FOUND,SYN
RTRUE
?CND8: DLESS? 'LEN,1 \?ELS28
ZERO? DRIVE1 \?REP7
ZERO? DRIVE2 /?ELS31
JUMP ?REP7
?ELS31: PRINTI "That sentence isn't one I recognize."
CRLF
RFALSE
?ELS28: ADD SYN,P-SYNLEN >SYN
JUMP ?PRG6
?REP7: ZERO? DRIVE1 /?ELS44
GETB DRIVE1,P-SFWIM1 >?TMP2
GETB DRIVE1,P-SLOC1 >?TMP1
GETB DRIVE1,P-SPREP1
CALL GWIM,?TMP2,?TMP1,STACK >OBJ
ZERO? OBJ /?ELS44
PUT P-PRSO,P-MATCHLEN,1
PUT P-PRSO,1,OBJ
CALL SYNTAX-FOUND,DRIVE1
RSTACK
?ELS44: ZERO? DRIVE2 /?ELS48
GETB DRIVE2,P-SFWIM2 >?TMP2
GETB DRIVE2,P-SLOC2 >?TMP1
GETB DRIVE2,P-SPREP2
CALL GWIM,?TMP2,?TMP1,STACK >OBJ
ZERO? OBJ /?ELS48
PUT P-PRSI,P-MATCHLEN,1
PUT P-PRSI,1,OBJ
CALL SYNTAX-FOUND,DRIVE2
RSTACK
?ELS48: EQUAL? VERB,ACT?FIND \?ELS52
PRINTI "That question can't be answered."
CRLF
RFALSE
?ELS52: EQUAL? WINNER,PLAYER /?ELS56
CALL CANT-ORPHAN
RSTACK
?ELS56: CALL ORPHAN,DRIVE1,DRIVE2
PRINTI "What do you want to "
GET P-OTBL,P-VERBN >TMP
ZERO? TMP \?ELS63
PRINTI "tell"
JUMP ?CND61
?ELS63: GETB P-VTBL,2
ZERO? STACK \?ELS67
GET TMP,0
PRINTB STACK
JUMP ?CND61
?ELS67: GETB TMP,2 >?TMP1
GETB TMP,3
CALL WORD-PRINT,?TMP1,STACK
PUTB P-VTBL,2,0
?CND61: ZERO? DRIVE2 /?CND70
PRINTI " "
CALL THING-PRINT,TRUE-VALUE,TRUE-VALUE
?CND70: SET 'P-OFLAG,TRUE-VALUE
ZERO? DRIVE1 /?ELS80
GETB DRIVE1,P-SPREP1
JUMP ?CND76
?ELS80: GETB DRIVE2,P-SPREP2
?CND76: CALL PREP-PRINT,STACK
PRINTI "?"
CRLF
RFALSE
.FUNCT CANT-ORPHAN
PRINTI """I don't understand! What are you referring to?"""
CRLF
RFALSE
.FUNCT ORPHAN,D1,D2,CNT=-1
ZERO? P-MERGED \?CND1
PUT P-OCLAUSE,P-MATCHLEN,0
?CND1: GET P-VTBL,0
PUT P-OVTBL,0,STACK
GETB P-VTBL,2
PUTB P-OVTBL,2,STACK
GETB P-VTBL,3
PUTB P-OVTBL,3,STACK
?PRG4: IGRTR? 'CNT,P-ITBLLEN \?ELS8
JUMP ?REP5
?ELS8: GET P-ITBL,CNT
PUT P-OTBL,CNT,STACK
JUMP ?PRG4
?REP5: EQUAL? P-NCN,2 \?CND11
PUT P-CCTBL,CC-SBPTR,P-NC2
PUT P-CCTBL,CC-SEPTR,P-NC2L
PUT P-CCTBL,CC-DBPTR,P-NC2
PUT P-CCTBL,CC-DEPTR,P-NC2L
CALL CLAUSE-COPY,P-ITBL,P-OTBL
?CND11: LESS? P-NCN,1 /?CND14
PUT P-CCTBL,CC-SBPTR,P-NC1
PUT P-CCTBL,CC-SEPTR,P-NC1L
PUT P-CCTBL,CC-DBPTR,P-NC1
PUT P-CCTBL,CC-DEPTR,P-NC1L
CALL CLAUSE-COPY,P-ITBL,P-OTBL
?CND14: ZERO? D1 /?ELS21
GETB D1,P-SPREP1
PUT P-OTBL,P-PREP1,STACK
PUT P-OTBL,P-NC1,1
RTRUE
?ELS21: ZERO? D2 /FALSE
GETB D2,P-SPREP2
PUT P-OTBL,P-PREP2,STACK
PUT P-OTBL,P-NC2,1
RTRUE
.FUNCT THING-PRINT,PRSO?,THE?=0,BEG,END
ZERO? PRSO? /?ELS3
GET P-ITBL,P-NC1 >BEG
GET P-ITBL,P-NC1L >END
JUMP ?CND1
?ELS3: GET P-ITBL,P-NC2 >BEG
GET P-ITBL,P-NC2L >END
?CND1: CALL BUFFER-PRINT,BEG,END,THE?
RSTACK
.FUNCT BUFFER-PRINT,BEG,END,CP,NOSP=1,WRD,FIRST??=1,PN=0,Q?=0,?TMP1
?PRG1: EQUAL? BEG,END /TRUE
GET BEG,0 >WRD
EQUAL? WRD,W?COMMA \?ELS10
PRINTI ", "
JUMP ?CND8
?ELS10: ZERO? NOSP /?ELS14
SET 'NOSP,FALSE-VALUE
JUMP ?CND8
?ELS14: PRINTI " "
?CND8: EQUAL? WRD,W?PERIOD,W?COMMA \?ELS22
SET 'NOSP,TRUE-VALUE
JUMP ?CND3
?ELS22: EQUAL? WRD,W?ME \?ELS24
PRINTD ME
SET 'PN,TRUE-VALUE
JUMP ?CND3
?ELS24: EQUAL? WRD,W?INTNUM \?ELS26
PRINTN P-NUMBER
SET 'PN,TRUE-VALUE
JUMP ?CND3
?ELS26: ZERO? FIRST?? /?CND29
ZERO? PN \?CND29
ZERO? CP /?CND29
PRINTI "the "
?CND29: ZERO? P-OFLAG \?THN39
ZERO? P-MERGED /?ELS38
?THN39: PRINTB WRD
JUMP ?CND36
?ELS38: EQUAL? WRD,W?IT \?ELS42
CALL ACCESSIBLE?,P-IT-OBJECT
ZERO? STACK /?ELS42
PRINTD P-IT-OBJECT
JUMP ?CND36
?ELS42: GETB BEG,2 >?TMP1
GETB BEG,3
CALL WORD-PRINT,?TMP1,STACK
?CND36: SET 'FIRST??,FALSE-VALUE
?CND3: ADD BEG,P-WORDLEN >BEG
JUMP ?PRG1
.FUNCT PREP-PRINT,PREP,WRD
ZERO? PREP /FALSE
PRINTI " "
CALL PREP-FIND,PREP >WRD
PRINTB WRD
RTRUE
.FUNCT CLAUSE-COPY,SRC,DEST,INSRT=0,BEG,END,?TMP1
GET P-CCTBL,CC-SBPTR
GET SRC,STACK >BEG
GET P-CCTBL,CC-SEPTR
GET SRC,STACK >END
GET P-CCTBL,CC-DBPTR >?TMP1
GET P-OCLAUSE,P-MATCHLEN
MUL STACK,P-LEXELEN
ADD STACK,2
ADD P-OCLAUSE,STACK
PUT DEST,?TMP1,STACK
?PRG1: EQUAL? BEG,END \?ELS5
GET P-CCTBL,CC-DEPTR >?TMP1
GET P-OCLAUSE,P-MATCHLEN
MUL STACK,P-LEXELEN
ADD STACK,2
ADD P-OCLAUSE,STACK
PUT DEST,?TMP1,STACK
RTRUE
?ELS5: ZERO? INSRT /?CND8
GET BEG,0
EQUAL? P-ANAM,STACK \?CND8
CALL CLAUSE-ADD,INSRT
?CND8: GET BEG,0
CALL CLAUSE-ADD,STACK
?CND3: ADD BEG,P-WORDLEN >BEG
JUMP ?PRG1
.FUNCT CLAUSE-ADD,WRD,PTR
GET P-OCLAUSE,P-MATCHLEN
ADD STACK,2 >PTR
SUB PTR,1
PUT P-OCLAUSE,STACK,WRD
PUT P-OCLAUSE,PTR,0
PUT P-OCLAUSE,P-MATCHLEN,PTR
RTRUE
.FUNCT PREP-FIND,PREP,CNT=0,SIZE
GET PREPOSITIONS,0
MUL STACK,2 >SIZE
?PRG1: IGRTR? 'CNT,SIZE /FALSE
GET PREPOSITIONS,CNT
EQUAL? STACK,PREP \?PRG1
SUB CNT,1
GET PREPOSITIONS,STACK
RSTACK
.FUNCT SYNTAX-FOUND,SYN