//    TRN0


GET "TRNHDR"

LET NEXTPARAM() = VALOF
    $( PARAMNUMBER := PARAMNUMBER + 1
       RESULTIS PARAMNUMBER  $)

AND TRANSREPORT(N, X) BE
    $( SELECTOUTPUT(SYSPRINT)
       REPORTCOUNT := REPORTCOUNT + 1
       IF REPORTCOUNT GE REPORTMAX DO
                $( WRITES("*NCOMPILATION ABORTED*N")
                   STOP(8)  $)
       WRITES("*NREPORT:   "); TRNMESSAGE(N)
       WRITEF("*NCOMMANDS COMPILED %N*N", COMCOUNT)
       PLIST(X, 0, 4); NEWLINE()
       SELECTOUTPUT(OCODE)  $)

AND TRNMESSAGE(N) BE
$( LET S = VALOF
    SWITCHON N INTO

    $( DEFAULT: WRITEF("COMPILER ERROR  %N", N); RETURN

       CASE 141: RESULTIS "TOO MANY CASES"
       CASE 104: RESULTIS "ILLEGAL USE OF BREAK, LOOP OR RESULTIS"
       CASE 101:
       CASE 105: RESULTIS "ILLEGAL USE OF CASE OR DEFAULT"
       CASE 106: RESULTIS "TWO CASES WITH SAME CONSTANT"
       CASE 144: RESULTIS "TOO MANY GLOBALS"
       CASE 142: RESULTIS "NAME DECLARED TWICE"
       CASE 143: RESULTIS "TOO MANY NAMES DECLARED"
       CASE 115: RESULTIS "NAME NOT DECLARED"
       CASE 116: RESULTIS "DYNAMIC FREE VARIABLE USED"
       CASE 117:CASE 118:CASE 119:
                 RESULTIS "ERROR IN CONSTANT EXPRESSION"
       CASE 110:CASE 112:
                 RESULTIS "LHS AND RHS DO NOT MATCH"
       CASE 109:CASE 113:
                 RESULTIS "LTYPE EXPRESSION EXPECTED"
                   $)

   WRITES(S)   $)


LET COMPILEAE(X) BE
   $(1 LET A = VEC 5000
       LET D = VEC 100
       LET K = VEC 150
       LET L = VEC 150

       DVEC, DVECS, DVECE, DVECP, DVECT := A, 3, 3, 3, 5000
       DVEC!0, DVEC!1, DVEC!2 := 0, 0, 0

       GLOBDECL, GLOBDECLS, GLOBDECLT := D, 0, 100

       CASEK, CASEL, CASEP, CASET, CASEB := K, L, 0, 150, -1
       ENDCASELABEL, DEFAULTLABEL := 0, 0

       RESULTLABEL, BREAKLABEL, LOOPLABEL := -1, -1, -1

       COMCOUNT, CURRENTBRANCH := 0, X

       OCOUNT := 0

       PARAMNUMBER := 0

       WHILE X~=0 LOGAND
             (H1!X=S.SECTION LOGOR H1!X=S.NEEDS) DO
       $( LET X1 = H2!X + 1
          LET L  = GETBYTE(X1, 0)

          OUT1(H1!X)
          OUTN1(L)
          FOR I = 1 TO L DO OUTN1(GETBYTE(X1, I))
          X := H3!X
       $)

       SSP := SAVESPACESIZE

       OUT2(S.STACK, SSP)
       DECLLABELS(X)
       TRANS(X)
       OUT2(S.GLOBAL, GLOBDECLS/2)

    $( LET I = 0
       UNTIL I=GLOBDECLS DO
          $( OUTN(GLOBDECL!I)
             OUTL(GLOBDECL!(I+1))
             I := I + 2  $)

       ENDOCODE()  $)1

.