      SUBROUTINE MAIN
      LOGICAL*1 GTOKEN
      LOGICAL*1 DEFN(200), T, TOKEN(100)
      INTEGER TBLOOK, PUSH
      INTEGER AP, ARGSTK(100), CALLST(130), NLB, PLEV(130)
      INTEGER INT
      INTEGER CP
      INTEGER EP
      LOGICAL*1 EVALST
      LOGICAL*1 BALP(3)
      LOGICAL*1 DEFNAM(7)
      LOGICAL*1 INCNAM(5)
      LOGICAL*1 SUBNAM(7)
      LOGICAL*1 IFNAM(7)
      LOGICAL*1 ARNAM(6)
      INTEGER DEFTYP(2)
      INTEGER INCTYP(2)
      INTEGER SUBTYP(2)
      INTEGER IFTYP(2)
      INTEGER ARTYP(2)
      INTEGER GETARG, I, OPEN
      LOGICAL*1 FILE(402)
      INTEGER MEM(5000)
      LOGICAL*1 CMEM(10000)
      INTEGER PBP, PBSIZE
      LOGICAL*1 PBBUF(512)
      LOGICAL*1 ST001Z(25)
      LOGICAL*1 ST002Z(20)
      LOGICAL*1 ST003Z(14)
      LOGICAL*1 ST004Z(15)
      COMMON /CMACRO/ CP, EP, EVALST(500)
      COMMON /CDSMEM/ MEM
      COMMON /CPBACK/ PBP, PBSIZE, PBBUF
      EQUIVALENCE (CMEM(1),MEM(1))
      DATA BALP(1) /40/, BALP(2) /41/, BALP(3) /0/
      DATA DEFNAM(1) /100/, DEFNAM(2) /101/, DEFNAM(3) /102/
      DATA DEFNAM(4) /105/, DEFNAM(5) /110/, DEFNAM(6) /101/
      DATA DEFNAM(7) /0/
      DATA INCNAM(1)/105/,INCNAM(2)/110/,INCNAM(3)/99/,INCNAM(4)/114/
      DATA INCNAM(5) /0/
      DATA SUBNAM(1) /115/, SUBNAM(2) /117/, SUBNAM(3) /98/
      DATA SUBNAM(4) /115/, SUBNAM(5) /116/, SUBNAM(6) /114/
      DATA SUBNAM(7) /0/
      DATA IFNAM(1) /105/, IFNAM(2) /102/, IFNAM(3) /101/
      DATA IFNAM(4) /108/, IFNAM(5) /115/, IFNAM(6) /101/
      DATA IFNAM(7) /0/
      DATA DEFTYP(1) /-4/, DEFTYP(2) /0/
      DATA INCTYP(1) /-12/, INCTYP(2) /0/
      DATA SUBTYP(1) /-13/, SUBTYP(2) /0/
      DATA IFTYP(1) /-11/, IFTYP(2) /0/
      DATA ARTYP(1) /-14/, ARTYP(2) /0/
      DATA ARNAM(1) /97/, ARNAM(2) /114/, ARNAM(3) /105/, ARNAM(4) /116/
     *, ARNAM(5) /104/, ARNAM(6) /0/
      DATA ST001Z(1)/117/,ST001Z(2)/115/,ST001Z(3)/97/,ST001Z(4)/103/,ST
     *001Z(5)/101/,ST001Z(6)/58/,ST001Z(7)/32/,ST001Z(8)/32/,ST001Z(9)/1
     *09/,ST001Z(10)/97/,ST001Z(11)/99/,ST001Z(12)/114/,ST001Z(13)/111/,
     *ST001Z(14)/32/,ST001Z(15)/91/,ST001Z(16)/102/,ST001Z(17)/105/,ST00
     *1Z(18)/108/,ST001Z(19)/101/,ST001Z(20)/93/,ST001Z(21)/32/,ST001Z(2
     *2)/46/,ST001Z(23)/46/,ST001Z(24)/46/,ST001Z(25)/0/
      DATA ST002Z(1)/99/,ST002Z(2)/97/,ST002Z(3)/108/,ST002Z(4)/108/,ST0
     *02Z(5)/32/,ST002Z(6)/115/,ST002Z(7)/116/,ST002Z(8)/97/,ST002Z(9)/9
     *9/,ST002Z(10)/107/,ST002Z(11)/32/,ST002Z(12)/111/,ST002Z(13)/118/,
     *ST002Z(14)/101/,ST002Z(15)/114/,ST002Z(16)/102/,ST002Z(17)/108/,ST
     *002Z(18)/111/,ST002Z(19)/119/,ST002Z(20)/0/
      DATA ST003Z(1)/69/,ST003Z(2)/79/,ST003Z(3)/70/,ST003Z(4)/32/,ST003
     *Z(5)/105/,ST003Z(6)/110/,ST003Z(7)/32/,ST003Z(8)/115/,ST003Z(9)/11
     *6/,ST003Z(10)/114/,ST003Z(11)/105/,ST003Z(12)/110/,ST003Z(13)/103/
     *,ST003Z(14)/0/
      DATA ST004Z(1)/117/,ST004Z(2)/110/,ST004Z(3)/101/,ST004Z(4)/120/,S
     *T004Z(5)/112/,ST004Z(6)/101/,ST004Z(7)/99/,ST004Z(8)/116/,ST004Z(9
     *)/101/,ST004Z(10)/100/,ST004Z(11)/32/,ST004Z(12)/69/,ST004Z(13)/79
     */,ST004Z(14)/70/,ST004Z(15)/0/
      CALL QUERY(ST001Z)
      CALL TBINIT(5000)
      CALL PBINIT(512)
      CALL TBINST(DEFNAM, DEFTYP)
      CALL TBINST(INCNAM, INCTYP)
      CALL TBINST(SUBNAM, SUBTYP)
      CALL TBINST(IFNAM, IFTYP)
      CALL TBINST(ARNAM, ARTYP)
      I=1
23000 CONTINUE
      IF (.NOT.(GETARG(I, FILE, 402) .EQ. -1))GOTO 23003
      IF (.NOT.(I .NE. 1))GOTO 23005
      GOTO 23002
23005 CONTINUE
      INT = 1
      GOTO 23004
23003 CONTINUE
      IF (.NOT.(FILE(1) .EQ. 45 .AND. FILE(2) .EQ. 0))GOTO 23007
      INT = 1
      GOTO 23008
23007 CONTINUE
      INT = OPEN(FILE, 1)
      IF (.NOT.(INT .EQ. -3))GOTO 23009
      CALL CANT (FILE)
23009 CONTINUE
23008 CONTINUE
23004 CONTINUE
      BP = 0
      CP = 0
      AP = 1
      EP = 1
      T=GTOKEN(TOKEN, 100, INT)
23011 IF (.NOT.(T.NE. -1))GOTO 23013
      IF (.NOT.(T .EQ. -9))GOTO 23014
      IF (.NOT.(TBLOOK(TOKEN, DEFN) .EQ. 0))GOTO 23016
      CALL PUTTOK(TOKEN)
      GOTO 23017
23016 CONTINUE
      CP = CP + 1
      IF (.NOT.(CP .GT. 130))GOTO 23018
      CALL ERROR(ST002Z)
23018 CONTINUE
      CALLST(CP) = AP
      AP = PUSH(EP, ARGSTK, AP)
      CALL PUTTOK(DEFN)
      CALL PUTCHR(0)
      AP = PUSH(EP, ARGSTK, AP)
      CALL PUTTOK(TOKEN)
      CALL PUTCHR(0)
      AP = PUSH(EP, ARGSTK, AP)
      T = GTOKEN(TOKEN, 100, INT)
      CALL PBSTR(TOKEN)
      IF (.NOT.(T .NE. 40))GOTO 23020
      CALL PBSTR(BALP)
23020 CONTINUE
      PLEV(CP) = 0
23017 CONTINUE
      GOTO 23015
23014 CONTINUE
      IF (.NOT.(T .EQ. 91))GOTO 23022
      NLB = 1
23024 CONTINUE
      T = GTOKEN(TOKEN, 100, INT)
      IF (.NOT.(T .EQ. 91))GOTO 23027
      NLB = NLB + 1
      GOTO 23028
23027 CONTINUE
      IF (.NOT.(T .EQ. 93))GOTO 23029
      NLB = NLB - 1
      IF (.NOT.(NLB .EQ. 0))GOTO 23031
      GOTO 23026
23031 CONTINUE
      GOTO 23030
23029 CONTINUE
      IF (.NOT.(T .EQ. -1))GOTO 23033
      CALL ERROR(ST003Z)
23033 CONTINUE
23030 CONTINUE
23028 CONTINUE
      CALL PUTTOK(TOKEN)
23025 GOTO 23024
23026 CONTINUE
      GOTO 23023
23022 CONTINUE
      IF (.NOT.(CP .EQ. 0))GOTO 23035
      CALL PUTTOK(TOKEN)
      GOTO 23036
23035 CONTINUE
      IF (.NOT.(T .EQ. 40))GOTO 23037
      IF (.NOT.(PLEV(CP) .GT. 0))GOTO 23039
      CALL PUTTOK(TOKEN)
23039 CONTINUE
      PLEV(CP) = PLEV(CP) + 1
      GOTO 23038
23037 CONTINUE
      IF (.NOT.(T .EQ. 41))GOTO 23041
      PLEV(CP) = PLEV(CP) - 1
      IF (.NOT.(PLEV(CP) .GT. 0))GOTO 23043
      CALL PUTTOK(TOKEN)
      GOTO 23044
23043 CONTINUE
      CALL PUTCHR(0)
      CALL EVAL(ARGSTK, CALLST(CP), AP-1)
      AP = CALLST(CP)
      EP = ARGSTK(AP)
      CP = CP - 1
23044 CONTINUE
      GOTO 23042
23041 CONTINUE
      IF (.NOT.(T .EQ. 44 .AND. PLEV(CP) .EQ. 1))GOTO 23045
      CALL PUTCHR(0)
      AP = PUSH(EP, ARGSTK, AP)
      GOTO 23046
23045 CONTINUE
      CALL PUTTOK(TOKEN)
23046 CONTINUE
23042 CONTINUE
23038 CONTINUE
23036 CONTINUE
23023 CONTINUE
23015 CONTINUE
23012 T=GTOKEN(TOKEN, 100, INT)
      GOTO 23011
23013 CONTINUE
      IF (.NOT.(CP .NE. 0))GOTO 23047
      CALL ERROR(ST004Z)
23047 CONTINUE
      IF (.NOT.(INT .NE. 1))GOTO 23049
      CALL CLOSE(INT)
23049 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      RETURN
      END
      SUBROUTINE DOARTH(ARGSTK,I,J)
      INTEGER CTOI
      INTEGER ARGSTK(100), I, J, K, L
      LOGICAL*1 OP
      INTEGER CP
      INTEGER EP
      LOGICAL*1 EVALST
      LOGICAL*1 ST005Z(12)
      COMMON /CMACRO/ CP, EP, EVALST(500)
      DATA ST005Z(1)/97/,ST005Z(2)/114/,ST005Z(3)/105/,ST005Z(4)/116/,ST
     *005Z(5)/104/,ST005Z(6)/32/,ST005Z(7)/101/,ST005Z(8)/114/,ST005Z(9)
     */114/,ST005Z(10)/111/,ST005Z(11)/114/,ST005Z(12)/0/
      K = ARGSTK(I+2)
      L = ARGSTK(I+4)
      OP = EVALST(ARGSTK(I+3))
      IF (.NOT.(OP .EQ. 43))GOTO 23051
      CALL PBNUM(CTOI(EVALST,K)+CTOI(EVALST,L))
      GOTO 23052
23051 CONTINUE
      IF (.NOT.(OP .EQ. 45))GOTO 23053
      CALL PBNUM(CTOI(EVALST,K)-CTOI(EVALST,L))
      GOTO 23054
23053 CONTINUE
      IF (.NOT.(OP .EQ. 42 ))GOTO 23055
      CALL PBNUM(CTOI(EVALST,K)*CTOI(EVALST,L))
      GOTO 23056
23055 CONTINUE
      IF (.NOT.(OP .EQ. 47 ))GOTO 23057
      CALL PBNUM(CTOI(EVALST,K)/CTOI(EVALST,L))
      GOTO 23058
23057 CONTINUE
      CALL REMARK(ST005Z)
23058 CONTINUE
23056 CONTINUE
23054 CONTINUE
23052 CONTINUE
      RETURN
      END
      SUBROUTINE DODEF(ARGSTK, I, J)
      INTEGER A2, A3, ARGSTK(100), I, J
      INTEGER CP
      INTEGER EP
      LOGICAL*1 EVALST
      COMMON /CMACRO/ CP, EP, EVALST(500)
      IF (.NOT.(J - I .GT. 2))GOTO 23059
      A2 = ARGSTK(I+2)
      A3 = ARGSTK(I+3)
      CALL TBINST(EVALST(A2), EVALST(A3))
23059 CONTINUE
      RETURN
      END
      SUBROUTINE DOIF(ARGSTK, I, J)
      INTEGER EQUAL
      INTEGER A2, A3, A4, A5, ARGSTK(100), I, J
      INTEGER CP
      INTEGER EP
      LOGICAL*1 EVALST
      COMMON /CMACRO/ CP, EP, EVALST(500)
      IF (.NOT.(J - I .LT. 5))GOTO 23061
      RETURN
23061 CONTINUE
      A2 = ARGSTK(I+2)
      A3 = ARGSTK(I+3)
      A4 = ARGSTK(I+4)
      A5 = ARGSTK(I+5)
      IF (.NOT.(EQUAL(EVALST(A2), EVALST(A3)) .EQ. 1))GOTO 23063
      CALL PBSTR(EVALST(A4))
      GOTO 23064
23063 CONTINUE
      CALL PBSTR(EVALST(A5))
23064 CONTINUE
      RETURN
      END
      SUBROUTINE DOINCR(ARGSTK, I, J)
      INTEGER CTOI
      INTEGER ARGSTK(100), I, J, K
      INTEGER CP
      INTEGER EP
      LOGICAL*1 EVALST
      COMMON /CMACRO/ CP, EP, EVALST(500)
      K = ARGSTK(I+2)
      CALL PBNUM(CTOI(EVALST, K)+1)
      RETURN
      END
      SUBROUTINE DOSUB(ARGSTK, I, J)
      INTEGER CTOI, LENGTH
      INTEGER AP, ARGSTK(100), FC, I, J, K, NC
      INTEGER CP
      INTEGER EP
      LOGICAL*1 EVALST
      COMMON /CMACRO/ CP, EP, EVALST(500)
      IF (.NOT.(J - I .LT. 3))GOTO 23065
      RETURN
23065 CONTINUE
      IF (.NOT.(J - I .LT. 4))GOTO 23067
      NC = 100
      GOTO 23068
23067 CONTINUE
      K = ARGSTK(I+4)
      NC = CTOI(EVALST, K)
23068 CONTINUE
      K = ARGSTK(I+3)
      AP = ARGSTK(I+2)
      FC = AP + CTOI(EVALST, K) - 1
      IF (.NOT.(FC .GE. AP .AND. FC .LT. AP + LENGTH(EVALST(AP))))GOTO 2
     *3069
      K = FC + MIN0(NC, LENGTH(EVALST(FC))) - 1
23071 IF (.NOT.(K .GE. FC))GOTO 23073
      CALL PUTBAK(EVALST(K))
23072 K = K - 1
      GOTO 23071
23073 CONTINUE
23069 CONTINUE
      RETURN
      END
      SUBROUTINE EVAL(ARGSTK, I, J)
      INTEGER INDEXC, LENGTH
      INTEGER ARGNO, ARGSTK(100), I, J, K, M, N, T, TD
      INTEGER CP
      INTEGER EP
      LOGICAL*1 EVALST
      LOGICAL*1 DIGITS(11)
      COMMON /CMACRO/ CP, EP, EVALST(500)
      DATA DIGITS(1) /48/
      DATA DIGITS(2) /49/
      DATA DIGITS(3) /50/
      DATA DIGITS(4) /51/
      DATA DIGITS(5) /52/
      DATA DIGITS(6) /53/
      DATA DIGITS(7) /54/
      DATA DIGITS(8) /55/
      DATA DIGITS(9) /56/
      DATA DIGITS(10) /57/
      DATA DIGITS(11) /0/
      T = ARGSTK(I)
      TD = EVALST(T)
      IF (.NOT.(TD .EQ. -4))GOTO 23074
      CALL DODEF(ARGSTK, I, J)
      GOTO 23075
23074 CONTINUE
      IF (.NOT.(TD .EQ. -12))GOTO 23076
      CALL DOINCR(ARGSTK, I, J)
      GOTO 23077
23076 CONTINUE
      IF (.NOT.(TD .EQ. -13))GOTO 23078
      CALL DOSUB(ARGSTK, I, J)
      GOTO 23079
23078 CONTINUE
      IF (.NOT.(TD .EQ. -11))GOTO 23080
      CALL DOIF(ARGSTK, I, J)
      GOTO 23081
23080 CONTINUE
      IF (.NOT.(TD .EQ. -14))GOTO 23082
      CALL DOARTH(ARGSTK, I, J)
      GOTO 23083
23082 CONTINUE
      K = T+LENGTH(EVALST(T))-1
23084 IF (.NOT.(K .GT. T))GOTO 23086
      IF (.NOT.(EVALST(K-1) .NE. 36))GOTO 23087
      CALL PUTBAK(EVALST(K))
      GOTO 23088
23087 CONTINUE
      ARGNO = INDEXC(DIGITS, EVALST(K)) - 1
      IF (.NOT.(ARGNO .GE. 0 .AND. ARGNO .LT. J-I))GOTO 23089
      N = I + ARGNO + 1
      M = ARGSTK(N)
      CALL PBSTR(EVALST(M))
23089 CONTINUE
      K = K - 1
23088 CONTINUE
23085 K = K - 1
      GOTO 23084
23086 CONTINUE
      IF (.NOT.(K .EQ. T))GOTO 23091
      CALL PUTBAK(EVALST(K))
23091 CONTINUE
23083 CONTINUE
23081 CONTINUE
23079 CONTINUE
23077 CONTINUE
23075 CONTINUE
      RETURN
      END
      LOGICAL*1 FUNCTION GTOKEN(TOKEN, TOKSIZ, INT)
      LOGICAL*1 NGETC, TYPE
      INTEGER I, TOKSIZ, INT
      LOGICAL*1 TOKEN (TOKSIZ)
      LOGICAL*1 ST006Z(15)
      DATA ST006Z(1)/116/,ST006Z(2)/111/,ST006Z(3)/107/,ST006Z(4)/101/,S
     *T006Z(5)/110/,ST006Z(6)/32/,ST006Z(7)/116/,ST006Z(8)/111/,ST006Z(9
     *)/111/,ST006Z(10)/32/,ST006Z(11)/108/,ST006Z(12)/111/,ST006Z(13)/1
     *10/,ST006Z(14)/103/,ST006Z(15)/0/
      I=1
23093 IF (.NOT.(I.LT.TOKSIZ))GOTO 23095
      GTOKEN = TYPE( NGETCH(TOKEN(I), INT))
      IF (.NOT.(GTOKEN .NE. 1 .AND. GTOKEN .NE. 2))GOTO 23096
      GOTO 23095
23096 CONTINUE
23094 I=I+1
      GOTO 23093
23095 CONTINUE
      IF (.NOT.(I .GE. TOKSIZ))GOTO 23098
      CALL ERROR (ST006Z)
23098 CONTINUE
      IF (.NOT.(I .GT. 1))GOTO 23100
      CALL PUTBAK (TOKEN(I))
      I = I - 1
      GTOKEN = -9
23100 CONTINUE
      TOKEN(I+1) = 0
      RETURN
      END
      SUBROUTINE PBNUM(N)
      INTEGER MOD
      INTEGER M, N, NUM
      LOGICAL*1 DIGITS(11)
      DATA DIGITS(1) /48/
      DATA DIGITS(2) /49/
      DATA DIGITS(3) /50/
      DATA DIGITS(4) /51/
      DATA DIGITS(5) /52/
      DATA DIGITS(6) /53/
      DATA DIGITS(7) /54/
      DATA DIGITS(8) /55/
      DATA DIGITS(9) /56/
      DATA DIGITS(10) /57/
      DATA DIGITS(11) /0/
      NUM = N
23102 CONTINUE
      M = MOD(NUM, 10)
      CALL PUTBAK(DIGITS(M+1))
      NUM = NUM / 10
23103 IF (.NOT.(NUM .EQ. 0))GOTO 23102
23104 CONTINUE
      RETURN
      END
      INTEGER FUNCTION PUSH(EP, ARGSTK, AP)
      INTEGER AP, ARGSTK(100), EP
      LOGICAL*1 ST007Z(19)
      DATA ST007Z(1)/97/,ST007Z(2)/114/,ST007Z(3)/103/,ST007Z(4)/32/,ST0
     *07Z(5)/115/,ST007Z(6)/116/,ST007Z(7)/97/,ST007Z(8)/99/,ST007Z(9)/1
     *07/,ST007Z(10)/32/,ST007Z(11)/111/,ST007Z(12)/118/,ST007Z(13)/101/
     *,ST007Z(14)/114/,ST007Z(15)/102/,ST007Z(16)/108/,ST007Z(17)/111/,S
     *T007Z(18)/119/,ST007Z(19)/0/
      IF (.NOT.(AP .GT. 100))GOTO 23105
      CALL ERROR(ST007Z)
23105 CONTINUE
      ARGSTK(AP) = EP
      PUSH = AP + 1
      RETURN
      END
      SUBROUTINE PUTCHR(C)
      LOGICAL*1 C
      INTEGER CP
      INTEGER EP
      LOGICAL*1 EVALST
      LOGICAL*1 ST008Z(26)
      COMMON /CMACRO/ CP, EP, EVALST(500)
      DATA ST008Z(1)/101/,ST008Z(2)/118/,ST008Z(3)/97/,ST008Z(4)/108/,ST
     *008Z(5)/117/,ST008Z(6)/97/,ST008Z(7)/116/,ST008Z(8)/105/,ST008Z(9)
     */111/,ST008Z(10)/110/,ST008Z(11)/32/,ST008Z(12)/115/,ST008Z(13)/11
     *6/,ST008Z(14)/97/,ST008Z(15)/99/,ST008Z(16)/107/,ST008Z(17)/32/,ST
     *008Z(18)/111/,ST008Z(19)/118/,ST008Z(20)/101/,ST008Z(21)/114/,ST00
     *8Z(22)/102/,ST008Z(23)/108/,ST008Z(24)/111/,ST008Z(25)/119/,ST008Z
     *(26)/0/
      IF (.NOT.(CP .EQ. 0))GOTO 23107
      CALL PUTCH(C,2)
      GOTO 23108
23107 CONTINUE
      IF (.NOT.(EP .GT. 500))GOTO 23109
      CALL ERROR(ST008Z)
23109 CONTINUE
      EVALST(EP) = C
      EP = EP + 1
23108 CONTINUE
      RETURN
      END
      SUBROUTINE PUTTOK(STR)
      LOGICAL*1 STR(100)
      INTEGER I
      I = 1
23111 IF (.NOT.(STR(I) .NE. 0))GOTO 23113
      CALL PUTCHR(STR(I))
23112 I = I + 1
      GOTO 23111
23113 CONTINUE
      RETURN
      END
