%begin   {pack PREDEF & PRIM for use by PASS3}
   %integer Predsize, Primsize
   %string(255) Predef, Prim
   %bytearray Preds, Prims(1:100000)
   %begin
      Prompt("Predefinition file: ")
      Read(Predef)
      Prompt("Primitive file:     ")
      Read(Prim)
   %end
   %routine Input(%bytearrayname A, %integername Size, %integer Sp)
      %bytearray Line(1:255)
      %integer S, P, Perc = 0, Last = 0, Lp = 0
      %on 9 %start
         Size = P
         %return
      %finish
      Select Input(1)
      P = 0
      %cycle
         Readsymbol(S)
         %if Sp # 0 %start      {minimise predef}
            %while S = '{' %cycle
               Readsymbol(S) %until S = '}' %or S = NL
               Readsymbol(S) %if S = '}'
            %repeat
            %if S = NL %start
               %continue %if Lp # 0 %and Line(Lp) = ','
               %if Lp # 0 %and Line(1) # '!' %start
                  %for S = 1, 1, Lp %cycle
                     P = P+1;  A(P) = Line(S)&127
                  %repeat
                  P = P+1;  A(P) = NL
               %finish
               Lp = 0
               %continue
            %finish
            %if S = '%' %start
               Perc = 128
               %continue %if Lp # 0 %and Line(Lp)&128 # 0
               %if Lp >= 2 %and Line(Lp) = ' ' %and Line(Lp-1)&128 # 0 %start
                  Lp = Lp-1
                  %continue
               %finish
            %else %unless 'A' <= S&95 <= 'Z'
               Perc = 0
               %if S = '-' %and Nextsymbol = NL %start
                  Skipsymbol
                  %continue
               %finish
            %finish
            %if S = ' ' %start
               %continue %if Lp = 0 %or Line(Lp)&128 = 0
               %continue %unless 'A' <= Nextsymbol&95 <= 'Z'
            %finish
            Lp = Lp+1;  Line(Lp) = S ! Perc
         %else
            P = P+1;  A(P) = S
         %finish
      %repeat
   %end
   %routine Dump(%bytearrayname A, %integer Size, %string(31) Id, File)
      %integer J, N, S
      Open Output(1, File);  Select Output(1)
      Printstring("%constinteger ".Id." Length = ")
      Write(Size, 0);  Newline
      Printstring("%constbytearray ".Id." Data(1:".Id." Length) =")
      N = 0
      %for J = 1, 1, Size %cycle
         N = N-1
         N = 17 %and Newline %if N <= 0
         S = A(J)
         %if ' ' <= S <= 126 %and S # ''''  %start
            Printsymbol('''');  Printsymbol(S);  Printsymbol('''')
         %else %if S = NL
            Printstring(" NL")
         %else
            Write(A(J), -3)
         %finish
         Printsymbol(',') %unless J = Size
      %repeat
      Newline
      Printstring("%endoffile");  Newline
      Close Output
   %end
   %routine Dump Arrays
      Dump(Preds, Predsize, "Predef", "pred.inc")
      Dump(Prims, Primsize, "Prim  ", "prim.inc")
   %end
   Open        Input(1, Predef);  Input(Preds, Predsize, 1)
   Open Binary Input(1, Prim);    Input(Prims, Primsize, 0)
   Dump Arrays
   Select Output(0)
   Printstring("pred.inc(");  Write(Predsize,0)
   Printstring(") &  prim.inc(");  Write(Primsize, 0)
   Printstring(") complete")
   Newline
%endofprogram
