-
Notifications
You must be signed in to change notification settings - Fork 15
/
breds.zap
572 lines (535 loc) · 11 KB
/
breds.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
.SEGMENT "0"
.FUNCT RED-BE-FORM:ANY:0:2,N,TYP
PUT PARSE-RESULT,2,TLEXV
POP DATA-STACK
PUT PARSE-RESULT,1,STACK
RTRUE
.FUNCT EXCH-4-5-Q:ANY:3:3,RED,N,TYP,X1,X2,X3,X4,X5
POP DATA-STACK >X1
POP DATA-STACK >X2
POP DATA-STACK >X3
POP DATA-STACK >X4
POP DATA-STACK >X5
EQUAL? N,6 \?CCL3
DEC 'N
POP DATA-STACK
PUT PARSE-RESULT,10,STACK
JUMP ?CND1
?CCL3: PUT PARSE-RESULT,10,0
?CND1: CALL2 PMEM?,X3
ZERO? STACK /?CCL6
XPUSH X3,DATA-STACK /?CND4
JUMP ?CND4
?CCL6: XPUSH X4,DATA-STACK /?CND4
?CND4: XPUSH X5,DATA-STACK /?BOGUS9
?BOGUS9: CALL2 PMEM?,X3
ZERO? STACK /?CCL12
XPUSH X4,DATA-STACK /?CND10
JUMP ?CND10
?CCL12: XPUSH X3,DATA-STACK /?CND10
?CND10: XPUSH X2,DATA-STACK /?BOGUS15
?BOGUS15: XPUSH X1,DATA-STACK /?BOGUS16
?BOGUS16: GET PARSE-RESULT,16
BOR PARSE-QUESTION,STACK
PUT PARSE-RESULT,16,STACK
CALL RED,N,TYP
RSTACK
.FUNCT RED-SBNN:ANY:0:2,N,TYP
CALL EXCH-4-5-Q,RED-SNBN,N,TYP
RSTACK
.FUNCT RED-SNBN:ANY:0:2,N,TYP,OK,NPP,OBJ,VERB,X,?TMP1
GET PARSE-RESULT,1 >VERB
POP DATA-STACK >NPP
ADD WORD-FLAG-TABLE,2 >?TMP1
GET WORD-FLAG-TABLE,0
INTBL? VERB,?TMP1,STACK,132 >X \?CCL6
GET X,1
JUMP ?CND4
?CCL6: PUSH FALSE-VALUE
?CND4: BTST STACK,1024 \?CCL3
POP DATA-STACK
EQUAL? TRUE-VALUE,STACK /?CND1
SET 'OK,TRUE-VALUE
JUMP ?CND1
?CCL3: POP DATA-STACK
EQUAL? TRUE-VALUE,STACK \?CND1
SET 'OK,TRUE-VALUE
?CND1: ZERO? OK /FALSE
CALL2 DETERMINE-SUBJ,VERB
ZERO? STACK /FALSE
CALL DETERMINE-OBJ,NPP,2 >OBJ
ZERO? OBJ \?CCL19
CALL PARSER-ERROR,0,PARSER-ERROR-NOOBJ,NPP
RSTACK
?CCL19: GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD26
PUSH ?TMP1
JUMP ?PEN24
?PRD26: GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,3
GET STACK,4
?PEN24: BTST STACK,32768 /?CCL21
GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD29
PUSH ?TMP1
JUMP ?PEN27
?PRD29: GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,3
GET STACK,4
?PEN27: BAND STACK,256
BAND STACK,32767
ZERO? STACK \FALSE
?CCL21: PUT PARSE-RESULT,6,OBJ
RETURN PARSE-RESULT
.FUNCT DETERMINE-SUBJ:ANY:1:3,VERB,SHORT,N1,DATA,TMP,OBJ1,?TMP1
ZERO? SHORT \?CND1
POP DATA-STACK
EQUAL? TRUE-VALUE,STACK /?CND1
GET PARSE-RESULT,16
BOR PARSE-NOT,STACK
PUT PARSE-RESULT,16,STACK
?CND1: POP DATA-STACK
ZERO? SHORT /?CCL7
POP DATA-STACK >TMP
PUT PARSE-RESULT,10,TMP
JUMP ?CND5
?CCL7: GET PARSE-RESULT,10 >TMP
?CND5: EQUAL? TMP,0,1 /?CCL9
GET TMP,4 >?TMP1
ZERO? ?TMP1 /?PRD16
PUSH ?TMP1
JUMP ?PEN14
?PRD16: GET TMP,3
GET STACK,4
?PEN14: BTST STACK,32768 /?CCL9
GET TMP,4 >?TMP1
ZERO? ?TMP1 /?PRD19
PUSH ?TMP1
JUMP ?PEN17
?PRD19: GET TMP,3
GET STACK,4
?PEN17: BAND STACK,256
BAND STACK,32767
ZERO? STACK \?CND8
?CCL9: GET PARSE-RESULT,16
BTST STACK,2 \?CCL22
SET 'TMP,W?BE?
JUMP ?CND8
?CCL22: SET 'TMP,W?BE
?CND8: GET TMP,3 >DATA
ZERO? SHORT /?CCL28
GET DATA,2 >TMP
JUMP ?CND26
?CCL28: GET DATA,3 >TMP
?CND26: ZERO? TMP \?CCL25
CALL PARSER-ERROR,0,PARSER-ERROR-TMNOUN
RSTACK
?CCL25: CALL GET-SYNTAX,TMP,1,1 >TMP
ZERO? TMP \?CCL30
CALL PARSER-ERROR,0,PARSER-ERROR-NOUND
RSTACK
?CCL30: ZERO? N1 /?PRD35
PUSH N1
JUMP ?PEN33
?PRD35: POP DATA-STACK >N1
PUSH N1
?PEN33: CALL DETERMINE-OBJ,STACK,1 >OBJ1
ZERO? OBJ1 \?CCL32
CALL PARSER-ERROR,0,PARSER-ERROR-NOOBJ,N1
RSTACK
?CCL32: PUT PARSE-RESULT,5,OBJ1
GET TMP,0
PUT PARSE-RESULT,4,STACK
RTRUE
.FUNCT RED-SBNA:ANY:0:2,N,TYP
CALL EXCH-4-5-Q,RED-SNBA,N,TYP
RSTACK
.FUNCT RED-SNBA:ANY:0:2,N,TYP,OK,ADJ,VERB,X,?TMP1
GET PARSE-RESULT,1 >VERB
POP DATA-STACK >ADJ
ADD WORD-FLAG-TABLE,2 >?TMP1
GET WORD-FLAG-TABLE,0
INTBL? VERB,?TMP1,STACK,132 >X \?CCL6
GET X,1
JUMP ?CND4
?CCL6: PUSH FALSE-VALUE
?CND4: BTST STACK,1024 \?CCL3
POP DATA-STACK
EQUAL? TRUE-VALUE,STACK /?CND1
SET 'OK,TRUE-VALUE
JUMP ?CND1
?CCL3: POP DATA-STACK
EQUAL? TRUE-VALUE,STACK \?CND1
SET 'OK,TRUE-VALUE
?CND1: ZERO? OK /FALSE
CALL2 DETERMINE-SUBJ,VERB
ZERO? STACK /FALSE
GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD24
PUSH ?TMP1
JUMP ?PEN22
?PRD24: GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,3
GET STACK,4
?PEN22: BTST STACK,32768 /?CCL19
GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD27
PUSH ?TMP1
JUMP ?PEN25
?PRD27: GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,3
GET STACK,4
?PEN25: BAND STACK,256
BAND STACK,32767
ZERO? STACK \FALSE
?CCL19: CALL DO-PMEM-ALLOC,4,NOUN-PHRASE-MIN-LENGTH >X
PUT X,1,1
PUT X,3,INTADJ
PUT PARSE-RESULT,6,X
PUT PARSE-RESULT,11,ADJ
RETURN PARSE-RESULT
.FUNCT RED-SBNP:ANY:0:2,N,TYP
CALL EXCH-4-5-Q,RED-SNBP,N,TYP
RSTACK
.FUNCT RED-SNBP:ANY:0:2,N,TYP,OK,PP,VERB,X,?TMP1
GET PARSE-RESULT,1 >VERB
POP DATA-STACK >PP
ADD WORD-FLAG-TABLE,2 >?TMP1
GET WORD-FLAG-TABLE,0
INTBL? VERB,?TMP1,STACK,132 >X \?CCL6
GET X,1
JUMP ?CND4
?CCL6: PUSH FALSE-VALUE
?CND4: BTST STACK,1024 \?CCL3
POP DATA-STACK
EQUAL? TRUE-VALUE,STACK /?CND1
SET 'OK,TRUE-VALUE
JUMP ?CND1
?CCL3: POP DATA-STACK
EQUAL? TRUE-VALUE,STACK \?CND1
SET 'OK,TRUE-VALUE
?CND1: ZERO? OK /FALSE
CALL2 DETERMINE-SUBJ,VERB
ZERO? STACK /FALSE
GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD25
PUSH ?TMP1
JUMP ?PEN23
?PRD25: GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,3
GET STACK,4
?PEN23: BTST STACK,32768 /?CCL20
GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD28
PUSH ?TMP1
JUMP ?PEN26
?PRD28: GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,3
GET STACK,4
?PEN26: BAND STACK,256
BAND STACK,32767
ZERO? STACK \FALSE
?CCL20: CALL DO-PMEM-ALLOC,4,NOUN-PHRASE-MIN-LENGTH >X
PUT X,1,1
PUT X,3,INTPP
PUT PARSE-RESULT,6,X
GET PARSE-RESULT,3
CALL REDUCE-LOCATION,PP,STACK,2 >OK
ZERO? OK /?CCL31
PUT PARSE-RESULT,9,OK
RETURN PARSE-RESULT
?CCL31: PUT PARSE-RESULT,9,PP
RETURN PARSE-RESULT
.FUNCT RED-SNBAP:ANY:0:2,N,TYP,OK,ADJ,PP,VERB,X,?TMP1
GET PARSE-RESULT,1 >VERB
POP DATA-STACK >PP
POP DATA-STACK >ADJ
ADD WORD-FLAG-TABLE,2 >?TMP1
GET WORD-FLAG-TABLE,0
INTBL? VERB,?TMP1,STACK,132 >X \?CCL6
GET X,1
JUMP ?CND4
?CCL6: PUSH FALSE-VALUE
?CND4: BTST STACK,1024 \?CCL3
POP DATA-STACK
EQUAL? TRUE-VALUE,STACK /?CND1
SET 'OK,TRUE-VALUE
JUMP ?CND1
?CCL3: POP DATA-STACK
EQUAL? TRUE-VALUE,STACK \?CND1
SET 'OK,TRUE-VALUE
?CND1: ZERO? OK /FALSE
CALL2 DETERMINE-SUBJ,VERB
ZERO? STACK /FALSE
GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD25
PUSH ?TMP1
JUMP ?PEN23
?PRD25: GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,3
GET STACK,4
?PEN23: BTST STACK,32768 /?CCL20
GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD28
PUSH ?TMP1
JUMP ?PEN26
?PRD28: GET PARSE-RESULT,5
GET STACK,4
GET STACK,2
GET STACK,3
GET STACK,4
?PEN26: BAND STACK,256
BAND STACK,32767
ZERO? STACK \FALSE
?CCL20: CALL DO-PMEM-ALLOC,4,4 >X
PUT X,1,1
PUT X,3,INTPP
SET 'OK,X
PUT PARSE-RESULT,6,OK
GET PARSE-RESULT,3
CALL REDUCE-LOCATION,PP,STACK,2 >OK
ZERO? OK /?CCL31
PUT PARSE-RESULT,9,OK
JUMP ?CND29
?CCL31: GET PP,2
CALL2 DETERMINE-OBJ,STACK >OK
ZERO? OK /?CND32
PUT PP,2,OK
PUTB PP,1,PMEM-TYPE-LOCATION
?CND32: PUT PARSE-RESULT,9,PP
?CND29: PUT PARSE-RESULT,11,ADJ
RETURN PARSE-RESULT
.FUNCT P-PP-OBJ:ANY:0:0,TMP
GET PARSE-RESULT,9 >TMP
ZERO? TMP /FALSE
GETB TMP,1
EQUAL? STACK,6 \FALSE
GET TMP,2 >TMP
ZERO? TMP /FALSE
GET TMP,3
RSTACK
.FUNCT P-PP-PREP:ANY:0:0,TMP
GET PARSE-RESULT,9 >TMP
ZERO? TMP /FALSE
GET TMP,1
RSTACK
.FUNCT RED-SQBN:ANY:0:2,N,TYP,?TMP1
GET PARSE-RESULT,1 >?TMP1
POP DATA-STACK
CALL DETERMINE-SUBJ,?TMP1,TRUE-VALUE,STACK
ZERO? STACK /FALSE
RETURN PARSE-RESULT
.FUNCT RED-BE:ANY:0:2,N,TYP,E
EQUAL? N,1 \TRUE
POP DATA-STACK >E
EQUAL? W?BE,E \FALSE
RETURN E
.FUNCT RED-NOT:ANY:0:2,N,TYP,E
EQUAL? N,1 \TRUE
POP DATA-STACK >E
EQUAL? W?NOT,E \FALSE
RETURN E
.FUNCT RED-CANDO:ANY:0:2,N,TYP,TMP,OBJ,SUBJ,WD,END,?TMP1
ZERO? N /TRUE
EQUAL? N,1 \?CCL5
POP DATA-STACK >SUBJ
GET SUBJ,2
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD13
PUSH ?TMP1
JUMP ?PEN11
?PRD13: GET SUBJ,2
GET STACK,3
GET STACK,4
?PEN11: BTST STACK,32768 /?CCL8
GET SUBJ,2
GET STACK,4 >?TMP1
ZERO? ?TMP1 /?PRD16
PUSH ?TMP1
JUMP ?PEN14
?PRD16: GET SUBJ,2
GET STACK,3
GET STACK,4
?PEN14: BAND STACK,256
BAND STACK,32767
ZERO? STACK \FALSE
?CCL8: CALL2 DETERMINE-OBJ,SUBJ >OBJ
ZERO? OBJ \?CCL19
CALL PARSER-ERROR,0,PARSER-ERROR-NOOBJ,SUBJ
RSTACK
?CCL19: GET OBJ,1
EQUAL? STACK,1 \FALSE
GET OBJ,3
FSET? STACK,PERSONBIT \FALSE
PUT PARSE-RESULT,13,OBJ
RTRUE
?CCL5: POP DATA-STACK >SUBJ
CALL2 PMEM?,SUBJ
ZERO? STACK /?CCL26
POP DATA-STACK
GET PARSE-RESULT,16
BOR PARSE-NOT,STACK
PUT PARSE-RESULT,16,STACK
JUMP ?CND24
?CCL26: EQUAL? TRUE-VALUE,SUBJ /?CND27
GET PARSE-RESULT,16
BOR PARSE-NOT,STACK
PUT PARSE-RESULT,16,STACK
?CND27: POP DATA-STACK >SUBJ
EQUAL? N,3 \?CND24
PUT PARSE-RESULT,14,SUBJ
?CND24: POP DATA-STACK >TMP
EQUAL? N,3 \?CCL33
SET 'SUBJ,TMP
GET PARSE-RESULT,14 >TMP
JUMP ?CND31
?CCL33: GET PARSE-RESULT,16
BOR PARSE-QUESTION,STACK
PUT PARSE-RESULT,16,STACK
PUT PARSE-RESULT,14,TMP
?CND31: GET TMP,4 >?TMP1
ZERO? ?TMP1 /?PRD42
PUSH ?TMP1
JUMP ?PEN40
?PRD42: GET TMP,3
GET STACK,4
?PEN40: BTST STACK,32768 /?PRD37
GET TMP,4 >?TMP1
ZERO? ?TMP1 /?PRD45
PUSH ?TMP1
JUMP ?PEN43
?PRD45: GET TMP,3
GET STACK,4
?PEN43: BAND STACK,1
BAND STACK,32767
ZERO? STACK \?CND34
?PRD37: GET TMP,3 >OBJ
ZERO? OBJ /?CND34
SET 'TMP,OBJ
?CND34: GET TMP,3
GET STACK,2 >TMP
ZERO? TMP \?CCL48
CALL PARSER-ERROR,0,PARSER-ERROR-TMNOUN
RSTACK
?CCL48: CALL GET-SYNTAX,TMP,1,1 >TMP
ZERO? TMP \?CCL50
CALL PARSER-ERROR,0,PARSER-ERROR-NOUND
RSTACK
?CCL50: CALL DETERMINE-OBJ,SUBJ,1 >OBJ
ZERO? OBJ \?CCL52
CALL PARSER-ERROR,0,PARSER-ERROR-NOOBJ,SUBJ
RSTACK
?CCL52: PUT PARSE-RESULT,13,OBJ
PUT PARSE-RESULT,15,TMP
EQUAL? N,3 /TRUE
POP DATA-STACK >TMP
EQUAL? TRUE-VALUE,TMP \?CCL57
PUSH 0
JUMP ?CND55
?CCL57: PUSH TMP
?CND55: PUT PARSE-RESULT,10,STACK
EQUAL? TMP,W?WHAT,W?WHO \TRUE
INTBL? W?PERIOD,TLEXV,P-LEN,132 >SUBJ /?BOGUS60
?BOGUS60: ZERO? SUBJ \?CND61
INTBL? W?THEN,TLEXV,P-LEN,132 >SUBJ /?CND61
?CND61: ZERO? SUBJ \?CND64
INTBL? W??,TLEXV,P-LEN,132 >SUBJ /?CND64
?CND64: ZERO? SUBJ \?CND67
SUB P-LEN,1
MUL STACK,4
ADD TLEXV,STACK >SUBJ
?CND67: SET 'END,4
?PRG69: GET SUBJ,0 >WD
EQUAL? TMP,WD /TRUE
GET WD,4 >?TMP1
ZERO? ?TMP1 /?PRD80
PUSH ?TMP1
JUMP ?PEN78
?PRD80: GET WD,3
GET STACK,4
?PEN78: BTST STACK,32768 /?CCL75
GET WD,4 >?TMP1
ZERO? ?TMP1 /?PRD83
PUSH ?TMP1
JUMP ?PEN81
?PRD83: GET WD,3
GET STACK,4
?PEN81: BAND STACK,1
BAND STACK,32767
ZERO? STACK /?CCL75
ADD SUBJ,4
ICALL INSERT-WHAT,TMP,STACK
RTRUE
?CCL75: GET WD,4 >?TMP1
ZERO? ?TMP1 /?PRD90
PUSH ?TMP1
JUMP ?PEN88
?PRD90: GET WD,3
GET STACK,4
?PEN88: BTST STACK,32768 /?CCL85
GET WD,4 >?TMP1
ZERO? ?TMP1 /?PRD93
PUSH ?TMP1
JUMP ?PEN91
?PRD93: GET WD,3
GET STACK,4
?PEN91: BAND STACK,2048
BAND STACK,32767
ZERO? STACK /?CCL85
ADD SUBJ,END
ICALL INSERT-WHAT,TMP,STACK
RTRUE
?CCL85: SUB SUBJ,4 >SUBJ
GRTR? TLEXV,SUBJ \?PRG69
SET 'END,0
RTRUE
.FUNCT INSERT-WHAT:ANY:2:2,TMP,SUBJ
SUB SUBJ,4
GET STACK,0
EQUAL? TMP,STACK /FALSE
SUB SUBJ,P-LEXV
DIV STACK,2
ICALL INSERT-ADJS-WD,STACK,TMP
INC 'P-OLEN
CALL2 COPY-INPUT,1
RSTACK
.ENDSEG
.ENDI