-
Notifications
You must be signed in to change notification settings - Fork 7
/
Lispf41.f
2470 lines (2467 loc) · 56.6 KB
/
Lispf41.f
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
C******HEART (HEART OF INTERPRETER)
SUBROUTINE LISPF4(IREE)
INCLUDE 'F4COM.FOR'
COMMON /PROMPT/PROTXT(80),PROLEN
INTEGER PROTXT,PROLEN
INTEGER OPENF
C THIS IS A MODIFIED LISPF3 THAT USE A STACK
C AND NOT A A-LIST FOR VARIABLE BINDINGS.
C
C LOCAL DECLARATIONS
C ==================
C
INTEGER ARGS(10)
LOGICAL NLISTP,GREAT,SPECAT,APLYFL,NOEVAL,ILLENV,FORMFL
INTEGER CONS,SUBPR,EQUAL,GET,GETCHT,GETPN,RATOM,COMPPN,
* GARB,GETNUM,ROLLIN,XCALL,INDEX,IOTAB(10),IPNAME(1)
INTEGER*2 JPNAME(1),JDUMMY
REAL NARR(1),RARGS(1)
EQUIVALENCE (LUNIN,IOTAB(1)),(IRES,ARG),(N,NARR(1))
EQUIVALENCE (ARG,ARGS(1),RARGS(1)),(PNAME(1),IPNAME(1),JPNAME(1))
NLISTP(IDUMMY) = IDUMMY.LE.NATOM .OR. IDUMMY.GT.NFREET
GREAT(IDUMMY) = IDUMMY.LT.-ISMALL .OR. IDUMMY.GT.ISMALL
C SPECAT(JDUMMY) = JDUMMY.EQ.STRING .OR. JDUMMY.EQ.SUBSTR
C * .OR. JDUMMY.EQ.ARRAY
SPECAT(JDUMMY) = JDUMMY.LE.SUBSTR .AND. JDUMMY.GE.ARRAY
NUPAIR(IDUMMY,IDUMMZ) = CONS(MKNUM(IDUMMY/IDUMMZ),
* MKNUM(MOD(IDUMMY,IDUMMZ)))
ILLENV(II) = II.GT.TOPS .OR.(II.NE.0 .AND. JACK(II).GT.0)
2 GOTO (10,1 ,1 ),IREE
C INI STA REE
10 CONTINUE
CALL MESS(20)
PRTPOS = 12
CALL IPRINT(CONS(83+NUMADD, CONS(08+NUMADD, CONS(22+NUMADD,NIL))))
CALL MESS(22)
PRTPOS = 12
I = NUMBP-DPNP-2
J = NUMBP-(JBP-2)/BYTES-3
IF (J.LT.I) I = J
CALL IPRINT(CONS(MKNUM(NFREEP-NFREEB),
* CONS(NUMADD+ISMALL,
* CONS(MKNUM(I),
* CONS(MKNUM(NATOM-NATOMP), NIL)))))
C RESTART OF INTERPRETER
C -----------------------------
1 IP = 1
JP=NSTACK+1
IPP=0
JPP=0
CALL MESS(17)
C*SETC* CALL SETCAR(NIL,NIL)
CAR(NIL)=NIL
C*SETC* CALL SETCDR(NIL,NIL)
CDR(NIL)=NIL
C*SETC* CALL SETCAR(T,T)
CAR(T)=T
IFLG1 = NUMADD
CALL TERPRI
IFLG1 = NIL
IFLG2 = NIL
CHT = 1
RDPOS = 1000
LUNIN=LUNINS
FORM=NIL
HILLW=HILL - 150
MIDDL=NSTACK/10
ISPLFT=400
IBREAK=.FALSE.
ARG = LISPX
ARG2 = NIL
ENV=0
TOPS=0
CALL GETCH(1H_,PROTXT(1),1)
PROLEN=1
GOTO 1500
C
C RECURSIVE RETURN PROCEDURE
C DROP TOP BLOCK
C
997 ENV=-JACK(TOPS)
C ! RESTORE ENVIRONMENT
998 TOPS=JILL(TOPS)
C ! DROP TOP BLOCK
999 I=STACK(IP)
IP=IP-1
C
1000 GOTO (15013 ,2020 ,2620 ,2120 ,12185 ,997 ,1020 ,
* 1710 ,1830 ,18060 ,20130 ,18100 ,18170 ,
* 12260 ,18210 ,25090 ,25100 ,15010 ,998 ,12150 ,
* 12290 ,12640 ,20095 ,1795 ,1778 ,1799 ,18012),I
C
C APPLYS EVLIS EVLAS EVCON EVSTK &POPE LISPX
C EAPPL FUNAR SETQ PROG AND OR
C MAPC SELEC ?STOV ?STUN APPLA &POP EVALA
C MAPC RPT PROG EVARGN EVARG NOSP FUNCTION =27
C
GOTO 25130
C ! INTERNAL STACK PROBLEM
C
C
C RECURSIVE FUNCTION LISPX()
C-----------------------------------------------------------------------
C USE EVAL IN TOP LEVEL LOOP
C
1010 IBREAK=.FALSE.
ARG=IREAD(0)
CALL FPUSH(7)
GOTO 1600
C
C--R7 RETURN POSITION FROM EVAL
C
1020 CALL IPRINT(IRES)
CALL TERPRI
GOTO 1010
C
C
C RECURSIVE FUNCTION APPLY(ARG,ARG2)
C
1477 CALL FPUSH(19)
1500 IF (ARG.EQ.NIL) GOTO 999
L=ARG
APLYFL=.TRUE.
ARG=CONS(L,ARG2)
FORM=CONS(NIL,ARG)
GOTO 1671
C ! TO ENTRY EAPPLY(L,ARG2) IN EVAL
C
C RECURSIVE FUNCTION EVAL(ARG)
C ============================
C
1600 IF(IBREAK) GOTO 2400
IF(TOPS.GT.HILLW) GOTO 25095
IF(JP .LE. IP+MIDDL) GOTO 25090
C ! THESE ARE THE ONLY
C ! STACK-OVERFLOW TESTS NEEDED
IF(ARG .GT. NATOM) GOTO 1660
C ! LIST OR NUMBER
IF(ARG.EQ.NIL.OR.ARG.EQ.T)GOTO 999
IF (SPECAT(CAR(ARG))) GOTO 999
C
C EVAL - ATOM.
C ATOM NOT NIL, T, STRING,
C ARRAY OR NUMBER. CHECK IF BOUND ON STACK
C
LOCAL=ENV
IF (LOCAL.LE.0)GOTO 1650
GOTO 1620
1610 LOCAL=-JACK(LOCAL)
IF (LOCAL.LE.0) GOTO 1650
1620 LOCALE=JILL(LOCAL)+2
K=LOCAL
1630 K=K-1
IF (K.LT.LOCALE) GOTO 1610
IF (JACK(K).NE.ARG) GOTO 1630
IRES=JILL(K)
GOTO 999
C
C
C ATOM NOT ON STACK CHECK VALUE CELL.
C
1650 IF(CAR(ARG).EQ.UNBOUN) GOTO 2200
C ! 2200=FAULTEVAL(ARG)
IRES=CAR(ARG)
GOTO 999
C
C HERE IF ARG NUMBER OR LIST
C ==========================
C
1660 IF(ARG .GT. NFREET) GOTO 999
C ! IT'S A NUMBER
C
C EVAL - LIST
C
FORM=ARG
L=CAR(ARG)
ARG2=CDR(ARG)
C
C EAPPLY(L,ARG2) . CALLED FROM EVAL AND FROM APPLY.
C
1670 APLYFL=.FALSE.
1671 LL=L
IF(LL .GT. NATOM) GOTO 1720
C ! CAR OF FORM IS A LIST
C ! HOPEFULLY (LAMBDA ...)
C ! OR (SUBR . ...)
C
C THE FOLLOWING CODE IS FOR AVOIDING CALLS TO GET FOR TESTING IF
C THERE IS ANY FUNCTION DEFINITION STORED UNDER THE FNCELL PROPERTY
LL=CDR(L)
IF(LL.EQ.NIL)GOTO 1676
IF(CAR(LL).NE.FNCELL)GOTO 1677
LL=CAR(CDR(LL))
GOTO 1720
1677 LL=GET(L,FNCELL)
C ! IS THERE ANYTHING IN FUNC.CELL?
IF(LL .NE. NIL) GOTO 1720
C ! THERE WAS SOMETHING
1676 IF(L .GT. FSUBR) GOTO 2230
C ! 2230 = FAULTAPPLY(L)
IF(L .GT. SUBR) GOTO 18000
C ! 18000 = THE MATCH ROUTINE FOR FSUBRS.
IF(L .EQ. NIL) GOTO 2230
C
C
C SUBR CASE
C =========
C
C
C 1. PUT THE BOTOM BLOCK
C
1680 IPREV=TOPS
C ! SAVE OLD TOPS
TOPS=TOPS+1
JACK(TOPS)=L
JILL(TOPS)=ARG
C ! WE PUSH *FORM AND ARG
C
C 2. SPREAD THE ARGS
C
1690 IF (NLISTP (ARG2)) GOTO 1695
C ! ARG2 HOLDS THE ARGLIST
TOPS=TOPS+1
JACK(TOPS)=SUBARG
JILL(TOPS)=CAR(ARG2)
ARG2=CDR(ARG2)
GOTO 1690
C 3. PUT TOP BLOCK
C
1695 TOPS=TOPS+1
JACK(TOPS)=-IPREV
C ! LINK TO PREVIUS BLOCK
JILL(TOPS)= IPREV+1
C ! LINK TO FORM
IF(APLYFL)GOTO 1713
C ! DON'T EVALUATE ARGS IF
C ! SUBR CALLED BY APPLY
C CALL APUSH(L) INLINE
C JP=JP-1
C IF(IP .GE. JP) GO TO 2
C STACK(JP)=L
C ! WE SAVE L (THATS THE SUBR)
C ! ON THE STACK OTHERVISE
C ! IT IS HARD TO KNOW WHAT SUBR
C ! WE HAD WHEN WE HAVE EVALUATED
C ! THE ARGS TO THE SUBR
C EVAL ARGS TO SUBR
C =================
C WHEN WE ARRIVE HERE THE TOP BLOCK MAY LOOK LIKE THIS.
C THE GLOBAL VARIABLE TOPS POINTS TO THE TOPBLOCK.
C THE POINTER IN JILL(TOPS) POINTS TO ARGUMENT UNDER
C EVALUATION.
C
C I-- LINK,,LINK ------------- <--- TOPS
C I -*- FOO I
C I -*- BAR I
C I *FORM (CONS FOO BAR) <-I
C I
C I-> LINK,,LINK
C
1697 JILL(TOPS)=JILL(TOPS)+1
IF(JILL(TOPS).EQ.TOPS)GOTO 1712
C ! WE HAVE EVALUATED ALL ARGS
ARG=JILL(JILL(TOPS))
IP=IP+1
STACK(IP)=8
C ! CALL FPUSH(8)
GOTO 1600
C R-8
1710 IF41=JILL(TOPS)
JILL(IF41)=IRES
GOTO 1697
C
1712 CONTINUE
C OK WE ARE READY NOW WE MUST
C 1. COMPUTE INDEX TO FIRST ARG
C 2. RESTORE FORM
C 3. RESTORE FUNCTION (=L)
C 4. FIX LINK TO PREVIUS BLOCK
C 5. COMPUTE NUMBER OF ARGS
INDEX=-JACK(TOPS)
C ! THATS TO PREVIUS BLOCK SO WE MUST
C ! ADD 2 TO GET THE REAL INDEX
C ! BUT WE CAN USE THIS INDEX FIRST
IF41=INDEX+1
FORM=JILL(IF41)
L=JACK(IF41)
JACK(IF41)=SFORM
C
C CALL APOP(L) INLINE
C IF (JP .GT. NSTACK) GO TO 2
C L=STACK(JP)
C JP=JP+1
C
JILL(TOPS)=INDEX
JACK(TOPS)=0
C ! JACK = 0 SHOWS THIS BLOCK
C ! HAS NO VARIABLES
C
INDEX=INDEX+2
IARGS=TOPS-INDEX
GOTO 2800
C ! 2800 THE DISPATCH FOR SUBRS
C
C SUBR CALLED FROM APPLY
C
C WE DO THE SAME THING BUT WE DONT HAVE TO
C RESTORE FORM OR FUNCTION
C
1713 INDEX=-JACK(TOPS)
JILL(TOPS)=INDEX
JACK(TOPS)=0
INDEX=INDEX+2
IARGS=TOPS-INDEX
GOTO 2800
C ! 2800 THE DISPATCH FOR SUBRS
C
C
C APPLYFN2(LL,ARG2)
C APPLIES A LIST FORM ONTO ARG2
C LL IS (HOPFULLY) ON FORM (LAMBDA (X Y) .....)
C OR (SUBR . ...)
C ARG2 IS A LIST OF PARAMETERS
C
1720 IF (NLISTP(LL)) GOTO 2210
C ! 2210=FAULTAPPLY(LL)
L=CAR(LL)
IF(L .EQ. LAMBDA) GOTO 1730
IF(L .EQ. NLAMBD) GOTO 1722
C (SUBR . X) CASE
IF(L .EQ. EXPR ) GOTO 1810
C (FSUBR . X) CASE
IF(L .EQ. FEXPR) GOTO 1815
IF(L .EQ. FUNARG) GOTO 1818
GOTO 2210
C
1722 NOEVAL=.TRUE.
GOTO 1731
1730 NOEVAL=.FALSE.
C
C
C LAMBDA & NLAMBDA CASE
C =====================
C
C 1. BOTTOM BLOCK
C
1731 IPREV=TOPS
C ! THIS IS PREVIUS BLOCK
TOPS=TOPS+1
JACK(TOPS)=SFORM
JILL(TOPS)=ARG
C ! PUSH FORM ON STACK
C 2. FIND THE LAMBDALIST
C
C IF THE FORM IS (FOO FIE FUM (SETQ BAR 77))
C AND FOO = (DE FOO (X Y)(CONS X Y))
C THEN LL = (LAMBDA (X Y)(CONS X Y))
C AND ARG2 = (FIE FUM (SETQ BAR 77))
C
1750 ICDR=CDR(LL)
ICAR=CAR(ICDR)
C ! ICAR IS THEN (X Y)
1760 IF(NLISTP(ICAR))GOTO 1770
C ! THERE WERE NO LAMBDALIST
C ! OR IT IS EXAUSTED
TOPS=TOPS+1
JACK(TOPS)=CAR(ICAR)
JILL(TOPS)=CAR(ARG2)
ARG2=CDR(ARG2)
ICAR=CDR(ICAR)
GOTO 1760
C
1770 IF(ICAR.NE.NIL) GOTO 1789
C ! WE HAVE A LAMBDA LIST ON FORMAT
C ! (X Y . Z), HALFSPREAD OR L, NOSPREAD
C
C WE ARE ABOUT TO PUT THE TOPBLOCK
C BUT MAYBE ARE THERE EXTRA ARGUMENTS TO THE FUNCTION
C
1771 IF (NLISTP(ARG2)) GOTO 1772
C ! THERE WERE NO EXTRA ARGS
C SOMEONE HAS CALLED A LAMBDA WITH MORE ARGUMENTS
C THAN DEFINED IN LAMBDALIST.
C WE PUT THE EXTRA ARGS ABOVE THE "REAL" ONES.
C THESE ARGS ALL GET THE NAME -*-
C
TOPS=TOPS+1
JACK(TOPS)=SUBARG
JILL(TOPS)=CAR(ARG2)
ARG2=CDR(ARG2)
GOTO 1771
C
C NOW WE CAN PUT THE TOP BLOCK
C
1772 TOPS=TOPS+1
JACK(TOPS)=-IPREV
C ! TO PREVIUS BLOCK
JILL(TOPS)=IPREV+1
C ! TO FORM
IF(NOEVAL.OR.APLYFL)GOTO 1785
C ! IT WAS A NLAMBDA
C ! OR FUNCTION CALLED BY APPLY
C
C
C EVALUATE ALL ARGS
C =================
C
C WHEN WE ARRIVE HERE THE TOP BLOCK MAY LOOK LIKE THIS.
C THE GLOBAL VARIABLE TOPS POINTS TO THE TOPBLOCK
C
C I-- LINK,,LINK ------------------------- <--- TOPS
C I -*- (SETQ BAR 77) I
C I Y FUM I
C I X FIE I
C I *FORM (FOO FIE FUM (SETQ BAR 77)) <-I
C I
C I-> LINK,,LINK
C
1777 JILL(TOPS)=JILL(TOPS)+1
IF (JILL(TOPS).EQ.TOPS) GOTO 1785
IF41=JILL(TOPS)
ARG=JILL(IF41)
IP=IP+1
STACK(IP)=25
C ! CALL FPUSH(25)
GOTO 1600
C R-25
1778 IF41=JILL(TOPS)
JILL(IF41)=IRES
GOTO 1777
C
C
C WE HAVE EVALUATED ALL ARGS
C ==========================
C
C WE MUST NOW
C FIX LINK TO PREVIUS BLOCK
C SAVE THE OLD ENVIRONMENT
C MAKE THIS THE NEW ENVIRONMENT
C RESTORE FORM AND FUNCTION
C
1785 INDEX=-JACK(TOPS)
JILL(TOPS)=INDEX
JACK(TOPS)=-ENV
ENV=TOPS
FORM=JILL(INDEX+1)
L=CAR(FORM)
1776 IF(NLISTP(L)) GOTO 1786
LL=L
TEMP1=CAR(L)
IF(TEMP1.NE.FUNARG) GOTO 1788
TEMP1=CDR(L)
L=CAR(TEMP1)
GOTO 1776
C THE FOLLOWING CODE IS FOR AVOIDING CALLS TO GET
1786 LL=CDR(L)
C ASSUME THAT THERE IS ALWAYS A PROPERTY LIST
IF(CAR(LL).NE.FNCELL)GOTO 1787
LL=CAR(CDR(LL))
GOTO 1788
1787 LL=GET(L,FNCELL)
1788 ARG=CDR(LL)
ARG=CDR(ARG)
C
C NOW ITS TIME TO CALL EVLAST WITH THE FUNCTION BODY
C AND WHEN WE RETURN FROM THERE GOTO 997 TO POP ENVIRONMENT.
C THIS WE COULD HAVE DONE WITH
C CALL FPUSH(?)
C GOTO 2600
C R- ?
CXXXX GOTO 997
C
C BUT AS FPUSH(6) RETURNS TO 997 WE SAVE ONE RECURSION BY
C
CALL FPUSH(6)
GOTO 2600
C
C HALF AND NOSPREAD ARGS
C ======================
C
1789 TOPS=TOPS+1
JACK(TOPS)=ICAR
JILL(TOPS)=ARG2
C ! PUT THE LAST ARG (HALFSPREAD)
C ! OR THE ONLY ARG (NOSPREAD)
TOPS=TOPS+1
JACK(TOPS)=-IPREV
JILL(TOPS)=IPREV+1
IF(NOEVAL.OR.APLYFL) GOTO 1785
1790 JILL(TOPS)=JILL(TOPS)+1
IF (JILL(TOPS).EQ.TOPS-1) GOTO 1797
C ! LAST ARGUMENT
IF41=JILL(TOPS)
ARG=JILL(IF41)
IP=IP+1
STACK(IP)=24
C ! CALL FPUSH(24)
GOTO 1600
C --R24
1795 IF41=JILL(TOPS)
JILL(IF41)=IRES
GOTO 1790
C
1797 ARG=JILL(TOPS-1)
CALL FPUSH(26)
GOTO 2000
C ! CALL EVLIS WITH LAST OR
C ! THE ONLY ARG
C R--26
1799 JILL(TOPS-1)=IRES
GOTO 1785
C
C
C
C
C (SUBR . ATOM)
1810 L=CDR(LL)
IF(L .GT. SUBR) GOTO 2210
C ! 2210=FAULTAPPLY(LL)
IF (L.EQ.NIL) GOTO 2230
GOTO 1680
C (FSUBR . ATOM)
1815 L=CDR(LL)
IF(L .GT. FSUBR) GOTO 2210
IF(L .LE. SUBR) GOTO 2210
GOTO 18000
C ! 18000=MATCH ROUTINE FOR FSUBRS.
C
C
C FUNARG
C THIS CODE MUST BE REWRITEN IT WORKS BUT !!
1818 CONTINUE
TEMP1=CDR(LL)
IF(NLISTP(TEMP1))TEMP1=NIL
L=CAR(TEMP1)
IF(NLISTP(TEMP1))TEMP1=NIL
TEMP1=CDR(TEMP1)
TEMP2=CAR(TEMP1)
1820 CONTINUE
IPREV=TOPS
TOPS=TOPS+1
JACK(TOPS)=SFORM
c JILL(TOPS)=TEMP1 !! THIS LINE CHANGED TO BELOW LINE, 20 OCTOBER 84
JILL(TOPS)=LL
1821 TEMP3=CAR(TEMP2)
IF(NLISTP(TEMP3)) GOTO 1822
TOPS=TOPS+1
TEMP2=CDR(TEMP2)
JACK(TOPS)=CAR(TEMP3)
JILL(TOPS)=CDR(TEMP3)
GOTO 1821
1822 TOPS=TOPS+1
JACK(TOPS)=-ENV
JILL(TOPS)=IPREV
ENV=TOPS
APLYFL=.FALSE.
CALL FPUSH(9)
GOTO 1671
C
C--R9
C
1830 K=JILL(TOPS)+1
TEMP1=JILL(K)
IF(NLISTP(TEMP1))GOTO 2250
TEMP1=CDR(TEMP1)
IF(NLISTP(TEMP1))GOTO 2250
TEMP1=CDR(TEMP1)
IF(NLISTP(TEMP1))GOTO 2250
TEMP1=CAR(TEMP1)
K1=K
1832 K1=K1+1
IF(K1.GE.TOPS)GOTO 997
IF(NLISTP(TEMP1))GOTO 2250
TEMP2=CAR(TEMP1)
IF(NLISTP(TEMP2))GOTO 2250
IF(CAR(TEMP2).NE.JACK(K1)) GOTO 2250
C*SETC* CALL SETCDR(TEMP2,JILL(K1))
CDR(TEMP2)=JILL(K1)
TEMP1=CDR(TEMP1)
GOTO 1832
C
C
C
C RECURSIVE FUNCTION EVLIS(ARG)
C-----------------------------------------------------------------------
C
2000 IF (NLISTP(ARG)) GOTO 999
JP=JP-2
STACK(JP+1)=NIL
STACK(JP)=ARG
C ! CALL APUSH2(NIL,ARG)
2010 ARG=CAR(ARG)
IP=IP+1
STACK(IP)=2
C ! CALL FPUSH(2)
GOTO 1600
C
C--R2 RETURN FROM EVAL(ARG)
C
2020 TEMP1=STACK(JP+1)
STACK(JP+1)=CONS(IRES,TEMP1)
ICDR=STACK(JP)
ARG=CDR(ICDR)
IF (NLISTP(ARG)) GOTO 2030
STACK(JP)=ARG
GOTO 2010
2030 IRES=STACK(JP+1)
JP=JP+2
C DREVERSE IRES BEFORE RETURN.
TEMP1=NIL
2040 TEMP2=CDR(IRES)
C*SETC* CALL SETCDR(IRES,TEMP1)
CDR(IRES)=TEMP1
IF(TEMP2 .EQ. NIL) GOTO 999
TEMP1=IRES
IRES=TEMP2
GOTO 2040
C
C
C-----------------------------------------------------------------------
C RECURSIVE FUNCTION EVCON
C
2100 JP=JP-1
2110 STACK(JP)=ARG
IF (NLISTP(ARG)) GOTO 2140
ICAR=CAR(ARG)
IF (NLISTP(ICAR)) GOTO 25080
ARG=CAR(ICAR)
IP=IP+1
STACK(IP)=4
GOTO 1600
C
C--R4 RETURN FROM EVAL(ARG)
C
2120 IF(IRES .NE. NIL) GOTO 2130
ICDR=STACK(JP)
ARG=CDR(ICDR)
GOTO 2110
2130 ICAR=STACK(JP)
ICAR=CAR(ICAR)
ICAR=CDR(ICAR)
JP=JP+1
IF(ICAR .EQ. NIL) GOTO 999
ARG=ICAR
GOTO 2600
2140 JP=JP+1
IRES=NIL
GOTO 999
C
C
C
C FAULTEVAL AND FAULTAPPLY AS CALLED FROM EVAL-APPLY.
C ---------------------------------------------------
C
2200 L=EVAL
ERRTYP=1
FORM=ARG
GOTO 2400
C
2210 ARG=LL
ERRTYP = 2
2220 L=APPLY
GOTO 2400
C
2230 ARG=L
ERRTYP=2
GOTO 2220
C
2240 ERRTYP=26
ARG=ARG2
GOTO 2400
C
C FAULTY FUNARG BLOCK
C
2250 ERRTYP=31
FORM=JILL(JILL(TOPS)+1)
L=CAR(FORM)
ARG=NIL
GOTO 2400
C
C SYSERROR(ERRTYP,L,ARG,FORM)
C ---------------------------
C THIS ENTRY IS USED FOR ALL WEAK ERRORS IN THE SYSTEM.
C WHEN CALLED, ERRTYP=TYPE OF ERROR, L=FAILING FUNCTION,
C ARG=ERRONEOUS FORM, FORM=FORM BEING EVALUATED.
C HERE THE LISP-DEFINED FUNCTION SYSERROR IS CALLED.
2400 ARG2=CONS(FORM,NIL)
ARG2=CONS(ARG,ARG2)
ARG2=CONS(L,ARG2)
ARG2=CONS(ERRTYP+NUMADD,ARG2)
ARG=ERROR
IBREAK=.FALSE.
LMARG=1
GOTO 1500
C CALL APPLY(SYSERROR, (ERRTYP L ARG FORM))
C
C
C
C
C RECURSIVE FUNCTION EVLAST(ARG)
C-----------------------------------------------------------------------
C
C ON ENTRY HERE ARG HOLDS A LIST OF FORMS THAT SHOULD BE EVALUATED
C (SETQ FOO 77)(...) (....)
C THE LIST IS KEEPT ON TOP OF STACK AND CAR OF IT IS SENT TO EVAL
C WHEN ONLY ONE FORM IS LEFT THIS FORM IS GIVEN TO EVAL BUT BEFORE
C THE TOP OF STACK IS CLEARED AND EVAL IS CALLED NONRECURCIVLY
C
2600 IF (NLISTP(ARG)) GOTO 999
JP=JP-1
STACK(JP)=ARG
TEMP1=ARG
2610 ARG=CAR(TEMP1)
I = CDR(TEMP1)
IF (NLISTP(I)) GOTO 2630
IP=IP+1
STACK(IP)=3
GOTO 1600
C
C--R3 RETURN FROM EVAL(ARG)
C
2620 ICAR=STACK(JP)
TEMP1=CDR(ICAR)
STACK(JP)=TEMP1
GOTO 2610
2630 JP=JP+1
GOTO 1600
C
C MAIN DISPATCH
C =============
C
C AT ENTRY , L=THE FUNCTION, IARGS=NR OF ARGS IN
C JILL ,STARTING AT INDEX
C
C
2800 IF (L.LE.SUBR0) GOTO 3000
IF (L.LE.SUBR1) GOTO 3020
IF (L.LE.SUBR2) GOTO 3140
IF (L-SUBR3) 3200,3200,3290
C-----------------------------------------------------------------------
C SUBR0 ENTRY
C
3000 GOTO( 3090,10075,
* 10080,10130,10050,10060,10070, 1010,10090,10100,10000,
* 10105,1 ,10110 ,10120),L
C NIL BTV*
C CLOCK DATE EJECT EXIT GENSY LISPX RATOM READ READC
C READP RESET TERPRI TIME
C-----------------------------------------------------------------------
C SUBR1 ENTRY
C
3020 ARG=NIL
IF (IARGS.EQ.0) GOTO 3050
3040 ARG=JILL(INDEX)
C
C SUBR1 JUMP ENTRY
C
3050 IF (L.LE.SUBR11) GOTO 3070
LL=L-SUBR11
C JUMP TO SUBR1 (AND DO NOT TEST ON NUM ARG)
GOTO (10040,11190,11197,11200,
* 11210,11210,11210,11210,11210,11210,11210,11210,11210,
* 11210,11210,11210,11210,11210,11215,11220,11225,11227,11230,
* 11255,11260,11290,11205,11310,11320,11330,11340,
* 998,11355,20150,11360,11415,11420),LL
C ALIST ARRAYSIZE ARRAYP ATOM
C CAR CDR CAAR CADR CDAR CDDR CAAAR CAADR CADAR
C CADDR CDAAR CDADR CDDAR CDDDR EVAL EVLIS FIXP FLOATP GETD
C LAST,LENGTH LISTP LITAT NLISTP NULL NUMBE OBLIS
C PROG1 PROMP RETUR REVER STRINGP ZEROP
C
C SUBR1 TEST ON NUMERICAL ARG
C
3070 IF (ARG.LE.BIGNUM) GOTO 25000
N = ARG-NUMADD
LL=L-SUBR0
GOTO(11000,11010,11020,11050,11060,11070,11080),LL
C ADD1 ERRMS RECLA ROLLI ROLLO SUB1 REWIND
C
C RETURN CHANNELS (CAN BE USED BY ALL SUBR'S AND FSUBR'S EXCEPT SUBRN'S)
C
C TEMP1
C
3080 IRES = TEMP1
GOTO 998
C
C PREDICATES
C
3090 IRES=NIL
GOTO 998
3100 IRES=T
GOTO 998
C
C NUMERICAL VALUED FUNCTIONS
C
3105 CONTINUE
3110 IF(IRFLAG.NE.NIL) GOTO 3120
IF (GREAT(N)) GOTO 3130
IRES = N+NUMADD
GOTO 998
3120 IRES = MKREAL(R)
GOTO 998
3130 IRES=MKNUM(N)
GOTO 998
C-----------------------------------------------------------------------
C SUBR2 ENTRY
C
3140 ARG2=NIL
ARG=NIL
IF41=IARGS+1
GOTO (3190,3180,3170), IF41
3170 ARG2=JILL(INDEX+1)
3180 ARG=JILL(INDEX)
C
C SUBR 2 JUMP ENTRY
C
3190 LL=L-SUBR1
GOTO (12000,12040,12050,1477 ,12715,12720,12090,12100,12112,
* 12114,
* 12116,12120,12130,12140,12160,12190,12200,12730,12205,12210,
* 12350,12390,12430,12470,12500,12510,12515,12520,12540,12570,
* 12600,
* 12620,12655,12660,12690,12746,12750,12780), LL
C ADDLI ALPHO APPEN APPLY ASSOC CHTAB CONS DIFFE ELT
C ELTI
C ELTR EQ EQUAL EVALA EVSTK GETP GREAT IOTAB IQUOR LESSP
C MEMB MEMBE NCHAR NCONC NCONC1 NEQ NTH PACK QUOTI RPLACA
C RPLACD
C RPT SASSOC SET STRAL TAILP UNPAC XCALL
C-----------------------------------------------------------------------
C SUBR3 ENTRY
C
3200 ARG=NIL
ARG2=NIL
ARG3=NIL
IF41 = IARGS + 1
GOTO (3280,3209,3207,3205), IF41
3205 ARG3=JILL(INDEX+2)
3207 ARG2=JILL(INDEX+1)
3209 ARG =JILL(INDEX)
C
C SUBR3 JUMP ENTRY
C
3280 LL=L-SUBR2
GOTO (15000,15012,15015,12330,12220,12310,12340 ,12345,15020,
*15040, 15130,15142,15144,15146,15150,15160,15190), LL
C APPLYA APPLYS ARRAY MAP MAPC MAPCA MAPLI OPEN0 PRIN0
C PUT RPLST SETA SETI SETR SUBPAIR SUBSTR SYSERROR
C-----------------------------------------------------------------------
C SUBRN ENTRY
C
C IT IS HERE UP TO THE SUBRN TO TAKE CARE OF THE ARGS
C
3290 LL=L-SUBR3
GOTO (16000,16010,16040,16070,16080), LL
C CONCAT LIST PLUS SYSFLA TIMES
C
C RETURN CHANNELS (3105 ALSO)
3300 CONTINUE
IF(IFLG2-NIL) 16005,998,16005
C-----------------------------------------------------------------------
C SUBR 0
C-----------------------------------------------------------------------
C
C READC
C
10010 CALL SHIFT(2)
10000 IF (CHT.LE.0) GOTO 10010
IF (CHT.LT.13 .OR. CHT.GE.23) GOTO 10020
IRES=CHT-13+NUMADD
GOTO 10030
10020 ABUFF(1) = CHR
IRES=MATOM(1)
10030 CALL SHIFT(2)
GOTO 998
C
C ALIST
C
10040 LOCAL=ENV
FORMFL = ARG.NE.NIL
TEMP1=CONS(NIL,NIL)
TEMP2=TEMP1
IF (LOCAL.LE.0)GOTO 10044
GOTO 10042
10041 IF(.NOT.FORMFL) GOTO 10037
IF(JACK(K).NE.SFORM)GOTO 10037
C*SETC* CALL SETCDR(TEMP1,CONS(CONS(JACK(K),JILL(K)),NIL))
CDR(TEMP1)=CONS(CONS(JACK(K),JILL(K)),NIL)
TEMP1=CDR(TEMP1)
10037 LOCAL=-JACK(LOCAL)
IF(LOCAL.LE.0)GOTO 10044
10042 LOCALE=JILL(LOCAL)+2
K=LOCAL
10043 K=K-1
IF (K.LE.0) GOTO 10044
IF (K.LT.LOCALE) GOTO 10041
C*SETC* CALL SETCDR(TEMP1,CONS( CONS(JACK(K),JILL(K)),NIL))
CDR(TEMP1)=CONS( CONS(JACK(K),JILL(K)),NIL)
TEMP1=CDR(TEMP1)
GOTO 10043
10044 IRES=CDR(TEMP2)
GOTO 998
C
C EJECT
C
10050 CALL EJECT(LUNUT)
GOTO 3090
C
C EXIT
C
10060 CALL LSPEX
C
C GENSYM
C
10070 ARG=CONS(A000,CONS(MKNUM(NUMGEN),NIL))
NUMGEN=NUMGEN+1
ARG2=NIL
GOTO 12520
C TO PACK
C
C BTV*
10075 CALL SHOSTK
IRES=NIL
GOTO 998
C
C CLOCK
C
10080 IRES=MKNUM(MSLFT(I))
GOTO 998
C
C RATOM
C
10090 BRFLG = NIL
I = RATOM(IRES,0)
GOTO 998
C
C READ
C
10100 IRES=IREAD(0)
GOTO 998
C
C READP
10105 IF(CHT.GT.1) GOTO 3100
IF(RDPOS.GT.MARGR) GOTO 3090
CALL SHIFT (2)
GOTO 10105
C
C RESET = GOTO 1
C
C
C TERPRI
C
10110 CALL TERPRI
PRTPOS=LMARG
GOTO 3090
C
C TIME
10120 CALL MTIME(BUFF)
C CHANGE 5 IF YOUR TIME FORMAT IS NOT 5 LONG
DO 10125 I=1,5
CALL GETCH(BUFF,TEMP1,I)
ABUFF(I)=TEMP1
10125 CONTINUE
C THE TWO 5'S BELOW MUST ALSO BE CHANGED
ABUP1= 5
IRES=MATOM(-5)
GOTO 998
C
C DATE
10130 CALL MDATE(BUFF)
C YOU CAN CHANGE THE 10 IN THE DO STATEMENT BELOW IF YOU
C HAVE A DATE FORMAT THAT IS NOT 10 CHARACTERS LONG
DO 10135 I=1,10
CALL GETCH(BUFF,TEMP1,I)
ABUFF(I)=TEMP1
10135 CONTINUE
C THE TWO OCCURENCES OF 10 BELOW MUST ALSO BE CHANGED
ABUP1= 10
IRES=MATOM(-10)
GOTO 998
C-----------------------------------------------------------------------
C SUBR 1 (WITH NUMERICAL ARG IN N)
C-----------------------------------------------------------------------
C
C ADD1
C
11000 N=N+1
IRFLAG = NIL
GOTO 3110
C
C ERRORMESS
C
11010 IF (N.LT.1 .OR. N.GT.MAXMES) GOTO 25000
CALL MESS(N)
GOTO 998
C
C RECLAIM
C