uses  Crt;
 Const
  Number : Set of Char = ['0'..'9'];
  Letter : Set of Char = ['a'..'z'];
  Symbol : Set of Char = ['(',')','[',']','{','}',':',';',','
                         ,'+','-','=','*','/','<','>','"',#39
                         ,'\','^','&'];
  KolCom = 30;
  KolSymT= 200;
  KolRuS = 50;
  KolB   = 20;
  Com    : Array [1..KolCom] of String[15]=('var','byte','integer','char',
           'word','array','begin','end','for','if','then','else','write',
           'endfor','endif','to','do','and','or','xor','read','writeln',
           'beginc','case','endc','endcase','endelse','of','endvar',
           'equal');
 Type
  Ident  = Record
            NameI  : String[25];
            ArrT   : 0..1;
            KolArr : 1..100;
            Tip    : 1..4;
           End;

 Var
  FName, FNameSk, FNameCom : String;
  PrFile, SkFile           : Text;
  ComFile                  : File of Byte;
  StrF, Str1               : String;
  SymStrF                  : Char;
  TabRuS                   : Array [1..KolRuS] of String;
  NRuS                     : 0..KolRuS;
  TabN                     : Array [1..KolSymT] of LongInt;
  TabTN                    : Array [1..KolSymT] of 1..4;
  TabI                     : Array [1..KolSymT] of Ident;
  TabB                     : Array [1..KolB] of Word;
  NBB                      : 0..KolB;
  NN, NI, N                : 0..KolSymT;
  N2Byte                   : Integer;
  N2Str                    : Integer;
  j                        : Byte;
  Ch1, Ch2                 : Char;
  Ch                       : Char;
  C1, C2                   : Char;
  FObjav, FTelo            : Boolean;
  FEndVar                  : Boolean;
  FIf                      : Boolean;
  Min                      : Boolean;
  TVyr, T                  : 1..4;
  AddrI                    : Array [1..KolSymT] of Word;
  AddrK                    : Array [1..KolRuS] of Word;
  AddrB                    : Array [1..KolB] of Word;
  Flag, FElse              : Boolean;
  TEl                      : 0..4;
  Adr1, Adr2, Adr3, Adr4,
  Adr11, Adr22, Adr33,
  Adr111, Adr222, Adr333,
  Adr1111, Adr2222, Adr3333: Word;
{-------------------- Skaner ------------------}
 Procedure PreobrN;
  Var
   StrN  : String[15];
   i     : Byte;
   NCh   : 1..KolSymT;
   Ch    : Integer;
   Code  : Integer;
   FlTab : Boolean;
  Begin
   FlTab:=False;
   i:=1;
   StrN:='';
   While (StrF[1] in Number) and (StrF<>'') do
    Begin
     StrN:=StrN+StrF[1];
     i:=i+1;
     Delete(StrF,1,1);
    End;
   Val(StrN,Ch,Code);
   For i:=1 to NN do
    If TabN[i]=Ch
     then begin
           FlTab:=True;
           NCh:=i;
          end;
   If FlTab=False
    then begin
          NN:=NN+1;
          NCh:=NN;
          TabN[NCh]:=Ch;
         end;
   StrN:='';
   Write(SkFile, 'n',Chr(NCh));
  End;
 Procedure Error(kk : Integer); Forward;
 Procedure PreobrL;
  Var
   StrL    : String[15];
   Ss, Sss : String[25];
   i, j    : Byte;
   NCh     : 1..KolSymT;
   FlTab   : Boolean;
   FlArr   : Boolean;
  Begin
   FlArr:=False;
   FlTab:=False;
   i:=1;
   StrL:='';
   Ss:='.........................';
   Sss:='.........................';
   While ((StrF[1] in Letter) or (StrF[1] in Number))
         and (StrF<>'') do
    Begin
     StrL:=StrL+StrF[1];
     i:=i+1;
     Delete(StrF,1,1);
    End;
   For i:=1 to NI do
    If TabI[i].NameI=StrL
     then begin
           FlTab:=True;
           NCh:=i;
           Write(SkFile, 'i',Chr(NCh));
          end;
   If FlTab=False
    then begin
          For i:=1 to KolCom do
           If StrL=Com[i]
            then begin
                  FlTab:=True;
                  NCh:=i;
                  Write(SkFile, 'c',Chr(NCh));
                  i:=KolCom;
                  If StrL=Com[29] then FEndVar:=True;
                 end;
         end;
   If FlTab=False
    then begin
          NI:=NI+1;
          NCh:=NI;
          TabI[NCh].NameI:=StrL;
          Write(SkFile, 'i',Chr(NCh));
          If not FEndVar then
           begin
            Ss:=StrF;
            While Length(Ss)>0 do
             If Ss[1]=':'
              then begin
               While not (Ss[1] in Letter) do
                Delete(Ss,1,1);
               j:=1;
               While (Length(Ss)>0) and (Ss[1]<>';') do
                If Ss[1]<>' '
                 then begin
                  Sss[j]:=Ss[1];
                  Delete(Ss,1,1);
                  j:=j+1;
                 end
                 else If Ss[2]='['
                       then begin
                        TabI[NCh].ArrT:=1;
                        Sss[j]:=Ss[1];
                        Delete(Ss,1,1);
                        j:=j+1;
                        FlArr:=True;
                       end
                       else If Ss[2] in Letter
                             then If FlArr
                                   then begin
                                    Sss[j]:=Ss[1];
                                    Delete(Ss,1,1);
                                    j:=j+1;
                                   end
                                   else Error(0);
               Delete(Sss,j,Length(Sss)-j+1);
              end
              else Delete(Ss,1,1);
           end;
         end;
   StrL:='';
  End;
 Procedure PreobrS;
  Var
   StrRuS : String;
   i      : Byte;
   FlS    : Boolean;
  Begin
   i:=1;
   StrRuS:='';
   While (StrF[1] in Symbol) and (StrF<>'') do
    Begin
     If StrF[1]=#39
      then begin
       Delete(StrF,1,1);
       Write(SkFile, 'b');
       NBB:=NBB+1;
       TabB[NBB]:=Ord(StrF[1]);
       Write(SkFile, Chr(NBB));
       Delete(StrF,1,1);
       If StrF[1]<>#39
        then Error(0);
       Delete(StrF,1,1);
      end;
     If StrF[1]='"'
      then begin
       Write(SkFile, 's',StrF[1]);
       Delete(StrF,1,1);
       While (StrF[1]<>'"') and (StrF<>'') do
        begin
         StrRuS:=StrRuS+StrF[1];
         Delete(StrF,1,1);
        end;
       NRuS:=NRuS+1;
       TabRuS[NRuS]:=StrRuS;
       N2Str:=N2Str+Length(StrRuS)+1;
       StrRuS:='';
       i:=1;
       Write(SkFile, 'k',Chr(NRuS))
      end;
     If StrF[1]=';'
      then Delete(StrF,2,Length(StrF)-1);
     Write(SkFile, 's',StrF[1]);
     Delete(StrF,1,1);
    End;
  End;
{-------------------- Errors ------------------}
 Procedure Error(kk : Integer);
  Var
   j : Byte;
  Begin
   TextColor(LightGray);
   Write('Ошибка ',kk,' : ');
   Case kk of
    0 : Begin
         WriteLn('Неизвестный символ');
         For j:=1 to Length(Str1) do
          If Str1[j]<>StrF[1]
           then Write(Str1[j])
           else begin
            TextColor(Yellow);
            Write(Str1[j]);
            TextColor(LightGray);
           end;
        End;
    1 : WriteLn('Где var ?');
    2 : WriteLn('Где begin ?');
    3 : WriteLn('Где Ваши переменные ?');
    4 : WriteLn('Объявление переменных !');
    5 : WriteLn('Где тип данных ?');
    6 : WriteLn('Поставьте ; !');
    7 : WriteLn('Поставьте [ !');
    8 : WriteLn('Укажите размер массива !');
    9 : WriteLn('Поставьте ] !');
    10: WriteLn('Поставьте of !');
    11: WriteLn('Где операторы ?');
    12: WriteLn('Где переменная ?');
    13: WriteLn('Поставьте = !');
    14: WriteLn('Поставьте { !');
    15: WriteLn('Поставьте to !');
    16: WriteLn('Поставьте do !');
    17: WriteLn('Поставьте ( !');
    18: WriteLn('Поставьте { (выражение) или " (строка) !');
    19: WriteLn('Поставьте " !');
    20: WriteLn('Поставьте ) !');
    21: WriteLn('Поставьте : !');
    22: WriteLn('Поставьте , !');
    23: WriteLn('Где знак сравнения ?');
    24: WriteLn('Где логическая функция или then ?');
    25: WriteLn('Где if ?');
    26: WriteLn('Несоответствие типов !');
    27: WriteLn('Это не выражение !');
    28: WriteLn('Поставьте число !');
    29: WriteLn('Поставьте ) !');
    30: WriteLn('Поставьте + или - !');
    31: WriteLn('Поставьте * или / !');
    32: WriteLn('Структура слишком большая !');
   End;
   j:=0;
   TextColor(Yellow);
   While (not EOF(SkFile)) and (j<10) do
    begin
     Case Ch1 of
      'c' : Write(Com[Ord(Ch2)],' ');
      's' : Write(Ch2);
      'i' : Write(TabI[Ord(Ch2)].NameI);
      'n' : Write(TabN[Ord(Ch2)]);
      'k' : Write(TabRuS[Ord(Ch2)]);
     End;
     Read(SkFile, Ch1, Ch2);
     j:=j+1;
    end;
   GoToXY(1,2);
   TextColor(LightGray);
   Halt;
  End;
{------------------- Analiz -------------------}
Procedure Type1;
 Begin
 If (Ch1='c') and
    ((Ch2=Chr(2)) or (Ch2=Chr(3)) or (Ch2=Chr(4)) or (Ch2=Chr(5)))
   then begin
    Case Ord(Ch2) of
     2 : TabI[N].Tip:=1;
     3 : TabI[N].Tip:=2;
     4 : TabI[N].Tip:=4;
     5 : TabI[N].Tip:=3;
    End;
    Read(SkFile, Ch1, Ch2);
    If (Ch2<>';')
     then Error(6)
     else begin
      Read(SkFile, Ch1, Ch2);
      If Ch1<>'c'
       then If Ch1='i'
             then N:=Ord(Ch2)
             else Error(3);
     end;
   end
   else Error(5);
 End;
Procedure Type0;
 Begin
  If Ch2=Chr(6)
   then begin
    TabI[N].ArrT:=1;
    Read(SkFile, Ch1, Ch2);
    If (Ch2<>'[')
     then Error(7)
     else Read(SkFile, Ch1, Ch2);
    If Ch1<>'n'
     then Error(8)
     else begin
      TabI[N].KolArr:=TabN[Ord(Ch2)];
      AddrI[N]:=N2Byte+$100+12;
      N2Byte:=N2Byte+TabN[Ord(Ch2)]*2;
      Read(SkFile, Ch1, Ch2);
     end;
    If (Ch2<>']')
     then Error(9)
     else Read(SkFile, Ch1, Ch2);
    If (Ch1<>'c') or (Ch2<>Chr(28))
     then Error(10)
     else Read(SkFile, Ch1, Ch2);
    Type1;
   end
   else begin
    AddrI[N]:=N2Byte+$100+12;
    N2Byte:=N2Byte+2;
    Type1;
   end;
 End;
Procedure Perem;
 Begin
  While (Ch1<>'c') and (Ch2<>Chr(29)) do
   begin
    Read(SkFile, Ch1, Ch2);
    If (Ch2<>':')
     then Error(4);
    Read(SkFile, Ch1, Ch2);
    If Ch1<>'c'
     then Error(5)
     else Type0;
   end;
 End;
Procedure Objavlenie;
 Begin
  Read(SkFile, Ch1, Ch2);
  If Ch1<>'i'
   then Error(3)
   else begin
    N:=Ord(Ch2);
    Perem;
   end;
 End;
Procedure OpredTyp;
 Begin
  If Ch1='n'
   then begin
    If (TabN[Ord(Ch2)]>=0) and (TabN[Ord(Ch2)]<=255)
     then TabTN[Ord(Ch2)]:=1
     else If (TabN[Ord(Ch2)]>=0) and (TabN[Ord(Ch2)]<=65535)
           then TabTN[Ord(Ch2)]:=3
           else If (TabN[Ord(Ch2)]>=-32768) and (TabN[Ord(Ch2)]<=32767)
                 then TabTN[Ord(Ch2)]:=2
                 else Error(32);
    If (TabTN[Ord(Ch2)]=3) and (TabN[Ord(Ch2)]<32767)
     then Min:=True;
   end;
 End;
Procedure Vyrazhenie; ForWard;
Procedure ImYach;
 Var
  B : Byte;
 Begin
  OpredTyp;
 End;
Procedure PrZU(Var ZnU : Char);
 Begin
  If (Ch2='*') or (Ch2='/')
   then begin
         ZnU:=Ch2;
         Read(SkFile, Ch1, Ch2);
        end
   else Error(31);
 End;
Procedure PrZS(Var ZnS : Char);
 Begin
  If (Ch2='+') or (Ch2='-')
   then begin
         ZnS:=Ch2;
         Read(SkFile, Ch1, Ch2);
        end
   else Error(30);
 End;
Procedure PrE; Forward;
Procedure PrF;
 Var
  B      : Byte;
  LR, HR : Byte;
  Ch0    : Char;
 Begin
  If Ch2='('
   then begin
    Read(SkFile, Ch1, Ch2);
    PrE;
    If Ch2=')'
     then Read(SkFile, Ch1, Ch2)
     else Error(28);
   end
   else If (Ch1='i') or (Ch1='n')
         then begin
          If (Ch1='i')
           then begin
            If not Flag
             then begin
              Flag:=True;
              TVyr:=TabI[Ord(Ch2)].Tip;
             end;
            TEl:=TabI[Ord(Ch2)].Tip;
            If TabI[Ord(Ch2)].ArrT=1
             then begin
              Ch0:=Ch2;
              Read(SkFile, Ch1, Ch2);
              If Ch2<>'['
               then Error(7);
              Read(SkFile, Ch1, Ch2);
              If Ch2<>'{'
               then Error(14);
              Vyrazhenie;
              Read(SkFile, Ch1, Ch2);
              If Ch2<>']'
               then Error(9);
              B:=$48;        {Dec   Ax}
              Write(ComFile, B);
              B:=$BB;          {Mov   Bx, [i]}
              Write(ComFile, B);
              LR:=Lo(AddrI[Ord(Ch0)]);
              HR:=Hi(AddrI[Ord(Ch0)]);
              Write(ComFile, LR, HR);
              B:=$03;          {Add   Bx, Ax}
              Write(ComFile, B);
              B:=$D8;
              Write(ComFile, B);
              B:=$03;          {Add   Bx, Ax}
              Write(ComFile, B);
              B:=$D8;
              Write(ComFile, B);
             end
             else begin
              B:=$BB;          {Mov   Ax, [i]}
              Write(ComFile, B);
              LR:=Lo(AddrI[Ord(Ch2)]);
              HR:=Hi(AddrI[Ord(Ch2)]);
              Write(ComFile, LR, HR);
             end;
            B:=$8B;
            Write(ComFile, B);
            B:=$07;
            Write(ComFile, B);
           end
           else If Ch1='n' then begin
            OpredTyp;
            If not Flag
             then begin
              Flag:=True;
              TVyr:=TabTN[Ord(Ch2)];
             end;
            TEl:=TabTN[Ord(Ch2)];
            B:=$B8;          {Mov   Ax, i}
            Write(ComFile, B);
            LR:=Lo(TabN[Ord(Ch2)]);
            HR:=Hi(TabN[Ord(Ch2)]);
            Write(ComFile, LR, HR);
           end;
          Read(SkFile, Ch1, Ch2);
         end
         else If Ch2='-'
               then begin
                If not Flag
                 then begin
                  Flag:=True;
                  TVyr:=2;
                 end;
                If TVyr<>2
                 then Error(26)
                 else begin
                  Read(SkFile, Ch1, Ch2);
                  If Ch1='i'
                   then begin
                    If TabI[Ord(Ch2)].Tip<>2
                     then Error(26);
                   end
                   else
                    If Ch1='n'
                     then If TabN[Ord(Ch2)]>32768
                           then Error(26);
                  PrF;
                  LR:=$F7;              {инверсия}
                  HR:=$D8;
                  Write(ComFile, LR, HR);
                 end;
               end
               else If Ch1='b'
                     then begin
                      If not Flag
                       then begin
                        Flag:=True;
                        TVyr:=4;
                       end;
                      TEl:=4;
                      B:=$B8;          {Mov   Ax, 'b'}
                      LR:=Lo(TabB[Ord(Ch2)]);
                      HR:=Hi(TabB[Ord(Ch2)]);
                      Write(ComFile, B,LR,HR);
                      Read(SkFile, Ch1, Ch2);
                     end
                     else Error(29);
  If (TEl<>0) and (TEl>TVyr) then Error(26);
 End;
Procedure PrT;
 Var
  B, B1 : Byte;
  Zn    : Char;
 Begin
  PrF;
  B:=$50;         {Push  AX}
  Write(ComFile, B);
  While (Ch2<>'+') and (Ch2<>'-') and (Ch2<>'}')
        and (Ch2<>')') do
   begin
    PrZU(Zn);
    PrF;
    B:=$5B;       {Pop   BX}
    Write(ComFile, B);
    Case Zn of
     '*' : begin
            Case TVyr of
             1 : begin
                  B:=$F6;
                  B1:=$E3;
                 end;
             2 : begin
                  B:=$F7;
                  B1:=$E3;
                 end;
             3 : begin
                  B:=$F7;
                  B1:=$EB;
                 end;
            End;
            Write(ComFile, B, B1);
           end;
     '/' : begin
            B:=$53;
            Write(ComFile, B);
            B:=$8B;
            Write(ComFile, B);
            B:=$D8;
            Write(ComFile, B);
            B:=$58;
            Write(ComFile, B);
            Case TVyr of
             1 : begin
                  B:=$F6;
                  B1:=$F3;
                  Write(ComFile, B, B1);
                  B:=$B4;
                  Write(ComFile, B);
                  B:=$00;
                  Write(ComFile, B);
                 end;
             3 : begin
                  B:=$BA;
                  B1:=$00;
                  Write(ComFile, B, B1, B1);
                  B:=$F7;
                  B1:=$F3;
                  Write(ComFile, B, B1);
                 end;
             2 : begin
                  B:=$3D;
                  Write(ComFile, B);
                  B:=$00;
                  B1:=$80;
                  Write(ComFile, B, B1);
                  B:=$77;  {72}
                  B1:=$05;
                  Write(ComFile, B, B1);
                  B:=$BA;
                  B1:=$00;
                  Write(ComFile, B, B1, B1);
                  B:=$EB;
                  B1:=$03;
                  Write(ComFile, B, B1);
                  B:=$BA;
                  B1:=$FF;
                  Write(ComFile, B, B1, B1);
                  B:=$F7;
                  B1:=$FB;
                  Write(ComFile, B, B1);
                 end;
            End;
           end;
    End;
    B:=$50;       {Push  AX}
    Write(ComFile, B);
   end;
    B:=$58;       {Pop   AX}
    Write(ComFile, B);
 End;
Procedure PrE;
 Var
  B, B1 : Byte;
  Zn    : Char;
 Begin
  PrT;
  B:=$50;         {Push  AX}
  Write(ComFile, B);
  While (Ch2<>'}') and (Ch2<>')') do
   begin
    PrZS(Zn);
    PrT;
    B:=$5B;       {Pop   BX}
    Write(ComFile, B);
    Case Zn of
     '+' : B:=$03;       {Add   AX, BX}
     '-' : begin
            B:=$93;       {XChg  BX, AX}
            Write(ComFile, B);
            B:=$2B;       {Sub   AX, BX}
           end;
    End;
    Write(ComFile, B);
    B:=$C3;
    Write(ComFile, B);
    B:=$50;     {Push  AX}
    Write(ComFile, B);
   end;
    B:=$58;       {Pop   AX}
    Write(ComFile, B);
 End;
Procedure Vyrazhenie;
 Var
  B : Byte;
 Begin
  B:=$B8;           {Mov   AX, 0000}
  Write(ComFile, B);
  B:=$00;
  Write(ComFile, B,B);
  TEl:=0;
  Flag:=False;
  Read(SkFile, Ch1, Ch2);
  PrE;
 End;
Function CheckT:Boolean;
 Begin
  CheckT:=False;
  Case TVyr of
   1 : If (T=1) or (T=2) or (T=3) then CheckT:=True;
   2 : If T=2 then CheckT:=True;
   3 : If (T=3) or ((T=2) and (Min)) then CheckT:=True;
   4 : If T=4 then CheckT:=True;
  End;
  Min:=False;
 End;
Procedure PWriteLn;
 Var
  FlK    : Boolean;
  B      : Byte;
  LR, HR : Byte;
 Begin
            B:=$B2;
            Write(ComFile, B);
            B:=$0D;
            Write(ComFile, B);
            B:=$B4;
            Write(ComFile, B);
            B:=$02;
            Write(ComFile, B);
            B:=$CD;
            Write(ComFile, B);
            B:=$21;
            Write(ComFile, B);
            B:=$B2;
            Write(ComFile, B);
            B:=$0A;
            Write(ComFile, B);
            B:=$B4;
            Write(ComFile, B);
            B:=$02;
            Write(ComFile, B);
            B:=$CD;
            Write(ComFile, B);
            B:=$21;
            Write(ComFile, B);
 End;
Procedure PWrite;
 Var
  FlK    : Boolean;
  B      : Byte;
  LR, HR : Byte;
 Begin
  FlK:=False;
  Read(SkFile, Ch1, Ch2);
  If Ch2<>'('
   then Error(17);
  Read(SkFile, Ch1, Ch2);
  If Ch2='{'
   then Vyrazhenie
   else If Ch2='"'
         then begin
          Read(SkFile, Ch1, Ch2);
          Ch:=Ch2;
          FlK:=True;
          Read(SkFile, Ch1, Ch2);
          If Ch2<>'"'
           then Error(19);
          end
          else Error(18);
  Read(SkFile, Ch1, Ch2);
  If Ch2<>')'
   then Error(20);
  If FlK
   then begin
    B:=$B4;
    Write(ComFile, B);
    B:=$09;
    Write(ComFile, B);
    B:=$BA;
    Write(ComFile, B);
    LR:=Lo(AddrK[Ord(Ch)]);
    HR:=Hi(AddrK[Ord(Ch)]);
    Write(ComFile, LR, HR);
    B:=$CD;
    Write(ComFile, B);
    B:=$21;
    Write(ComFile, B);
   end
   else If TVyr<>4
         then begin
          B:=$B9;
          Write(ComFile, B);
          LR:=$05;
          HR:=$00;
          Write(ComFile, LR,HR);
          B:=$BA;
          Write(ComFile, B);
          B:=$00;
          Write(ComFile, B, B);
          B:=$BB;
          Write(ComFile, B);
          LR:=$0A;
          HR:=$00;
          Write(ComFile, LR,HR);
          LR:=$F7;
          HR:=$F3;
          Write(ComFile, LR,HR);
          LR:=$83;
          HR:=$C2;
          Write(ComFile, LR,HR);
          B:=$30;
          Write(ComFile, B);
          B:=$52;
          Write(ComFile, B);
          LR:=$E2;
          HR:=$F2;
          Write(ComFile, LR,HR);
          B:=$B9;
          Write(ComFile, B);
          LR:=$05;
          HR:=$00;
          Write(ComFile, LR,HR);
          B:=$5A;
          Write(ComFile, B);
          B:=$B4;
          Write(ComFile, B);
          B:=$02;
          Write(ComFile, B);
          B:=$CD;
          Write(ComFile, B);
          B:=$21;
          Write(ComFile, B);
          LR:=$E2;
          HR:=$F9;
          Write(ComFile, LR,HR);
         end
         else begin
          B:=$8B;
          Write(ComFile, B);
          B:=$D0;
          Write(ComFile, B);
          B:=$B4;
          Write(ComFile, B);
          B:=$02;
          Write(ComFile, B);
          B:=$CD;
          Write(ComFile, B);
          B:=$21;
          Write(ComFile, B);
         end;
 End;
Procedure LogPrE; Forward;
Function ZnSravn : Byte;
 Var
  B        : Byte;
 Begin
  Read(SkFile, Ch1, Ch2);
  Case Ch2 of
   '>': begin
         Read(SkFile, Ch1, Ch2);
         ZnSravn:=5;
         If (Ch2='=')
          then begin
           ZnSravn:=3;
           Read(SkFile, Ch1, Ch2);
          end
          else If (Ch2='<')
                then begin
                 ZnSravn:=2;
                 Read(SkFile, Ch1, Ch2);
                end;
         If Ch2<>'{'
          then Error(14);
        end;
   '<': begin
         Read(SkFile, Ch1, Ch2);
         ZnSravn:=6;
         If (Ch2='=')
          then begin
           ZnSravn:=4;
           Read(SkFile, Ch1, Ch2);
          end
          else If (Ch2='>')
                then begin
                 ZnSravn:=2;
                 Read(SkFile, Ch1, Ch2);
                end;
         If Ch2<>'{'
          then Error(14);
        end;
   '=': begin
         ZnSravn:=1;
         Read(SkFile, Ch1, Ch2);
         If Ch2<>'{'
          then Error(14);
        end;
  End;
 End;
Procedure LogPrZU(Var ZnU : Char);
 Begin
  If (Ch2='&') or (Ch2='^')
   then begin
         ZnU:=Ch2;
         Read(SkFile, Ch1, Ch2);
        end
   else Error(31);
 End;
Procedure LogPrF;
 Var
  B      : Byte;
  LR, HR : Byte;
  Ch0    : Char;
  ZnS    : Byte;
 Begin
  If Ch2='{'
   then begin
    Vyrazhenie;
    B:=$50;             {Push   Ax}
    Write(ComFile, B);
    T:=TVyr;
    ZnS:=ZnSravn;
    Vyrazhenie;
    Read(SkFile, Ch1, Ch2);
    If not CheckT
     then Error(26);
    B:=$5B;              {Pop    Bx}
    Write(ComFile, B);
    B:=$3B;         {Cmp    Ax, Bx}
    Write(ComFile, B);
    B:=$C3;
    Write(ComFile, B);
    Case ZnS of
     1 : B:=$74;                {Je      }
     2 : B:=$75;                {Jne     }
     3 : B:=$73;                {Jnb     }
     4 : B:=$76;                {Jna     }
     5 : B:=$77;                {Ja      }
     6 : B:=$72;                {Jb      }
    End;
    Write(ComFile, B);
    B:=$05;
    Write(ComFile, B);
    B:=$B9;        {mov  cx, 0000}
    Write(ComFile, B);
    B:=$00;
    Write(ComFile, B, B);
    B:=$EB;        {jmp       }
    Write(ComFile, B);
    B:=$03;
    Write(ComFile, B);
    B:=$B9;
    Write(ComFile, B);
    B:=$FF;        {mov  cx, FFFFh}
    Write(ComFile, B, B);
   end;
 End;
Procedure LogPrT;
 Var
  B, B1 : Byte;
  Zn    : Char;
 Begin
  LogPrF;
  B:=$51;         {Push  CX}
  Write(ComFile, B);
  While (Ch2<>'\') and (Ch2<>'}') and (Ch2<>')') and (Ch2<>Chr(11)) do
   begin
    LogPrZU(Zn);
    LogPrF;
    B:=$5A;       {Pop   DX}
    Write(ComFile, B);
    Case Zn of
     '&' : B:=$23; {and CX, DX}
     '^' : B:=$33; {xor CX, DX}
    End;
    Write(ComFile, B);
    B:=$CA;
    Write(ComFile, B);
    B:=$51;       {Push  CX}
    Write(ComFile, B);
   end;
    B:=$59;       {Pop   CX}
    Write(ComFile, B);
 End;
Procedure LogPrE;
 Var
  B, B1 : Byte;
  Zn    : Char;
 Begin
  LogPrT;
  B:=$51;         {Push  CX}
  Write(ComFile, B);
  While (Ch2<>'}') and (Ch2<>')') and (Ch2<>Chr(11)) do
   begin
    If Ch2='\'
     then begin
      Read(SkFile, Ch1, Ch2);
      LogPrT;
      B:=$5A;       {Pop   DX}
      Write(ComFile, B);
      B:=$0B;           {or CX, DX}
      Write(ComFile, B);
      B:=$CA;
      Write(ComFile, B);
      B:=$51;     {Push  CX}
      Write(ComFile, B);
     end;
   end;
    B:=$59;       {Pop   CX}
    Write(ComFile, B);
 End;
Procedure LogVyr;
 Var
  B       : Byte;
 Begin
  B:=$B9;        {mov  cx, 0000}
  Write(ComFile, B);
  B:=$00;
  Write(ComFile, B, B);
  LogPrE;
 End;
Procedure Operator;
 Var
  g                     : 1..3;
  B                     : Byte;
  LR, HR                : Byte;
  L, H                  : Byte;
  Metka                 : Word;
  ChF, ChC, ChE, ChRd   : Char;
 Begin
  Case Ch2 of
   Chr(9) :{for}
           Begin
            Read(SkFile, Ch1, Ch2);
            If Ch1<>'i'
             then Error(12);
            ChF:=Ch2;
            OpredTyp;
            T:=TabI[Ord(Ch2)].Tip;
            Read(SkFile, Ch1, Ch2);
            If (Ch2<>'=')
             then Error(13);
            Read(SkFile, Ch1, Ch2);
            If (Ch2<>'{')
             then Error(14);
            Vyrazhenie;
            If not CheckT
             then Error(26);
            B:=$BB;
            LR:=Lo(AddrI[Ord(ChF)]);
            HR:=Hi(AddrI[Ord(ChF)]);
            Write(ComFile, B, LR, HR);
            B:=$89;
            Write(ComFile, B);
            B:=$07;
            Write(ComFile, B);
            Read(SkFile, Ch1, Ch2);
            If (Ch1<>'c') or (Ch2<>Chr(16))
             then Error(15);
            Read(SkFile, Ch1, Ch2);
            If (Ch2<>'{')
             then Error(14);
            Vyrazhenie;
            If not CheckT
             then Error(26);
            B:=$50;              {Push   Ax}
            Write(ComFile ,B);
            Read(SkFile, Ch1, Ch2);
            If (Ch1<>'c') or (Ch2<>Chr(17))
             then Error(16);
            Adr1:=FilePos(ComFile);
            B:=$5B;              {Pop    Bx}
            Write(ComFile, B);
            B:=$3B;              {Cmp    Ax, Bx}
            Write(ComFile, B);
            B:=$C3;
            Write(ComFile, B);
            B:=$76;              {Jna    }
            Write(ComFile, B);
            B:=$03;
            Write(ComFile, B);
            B:=$E9;
            Write(ComFile, B);
            B:=$00;
            Write(ComFile, B,B);
            Adr3:=FilePos(ComFile)-2;
            B:=$53;              {Push    Bx}
            Write(ComFile, B);
            Read(SkFile, Ch1, Ch2);
            If Ch1<>'c'
             then Error(11);
            Repeat
             Operator;
             If FElse
              then begin
               Ch1:=C1;
               Ch2:=C2;
              end
              else Read(SkFile, Ch1, Ch2);
             FElse:=False;
            Until (Ch1='c') and (Ch2=Chr(14));
            B:=$BB;
            LR:=Lo(AddrI[Ord(ChF)]);
            HR:=Hi(AddrI[Ord(ChF)]);
            Write(ComFile, B, LR, HR);
            B:=$8B;
            Write(ComFile, B);
            B:=$07;
            Write(ComFile, B);
            B:=$40;        {Inc    Ax}
            Write(ComFile, B);
            B:=$BB;
            LR:=Lo(AddrI[Ord(ChF)]);
            HR:=Hi(AddrI[Ord(ChF)]);
            Write(ComFile, B, LR, HR);
            B:=$89;
            Write(ComFile, B);
            B:=$07;
            Write(ComFile, B);
            Adr2:=FilePos(ComFile);
            LR:=Lo(Adr1-Adr2-3);
            HR:=Hi(Adr1-Adr2-3);
            B:=$E9;
            Write(ComFile, B,LR,HR);
            Adr2:=FilePos(ComFile);
            Seek(ComFile,Adr3);
            LR:=Lo(Adr2-Adr3-2);
            HR:=Hi(Adr2-Adr3-2);
            Write(ComFile, LR,HR);
            Seek(ComFile,Adr2);
            B:=$5B;              {Pop    Bx}
            Write(ComFile, B);
           End;
   Chr(10):{if}
           Begin
            Read(SkFile, Ch1, Ch2);
            If Ch2<>'{'
             then Error(14);
            LogVyr;
            B:=$83;         {Cmp   Cx, 0000}
            Write(ComFile, B);
            B:=$F9;
            Write(ComFile, B);
            B:=$00;
            Write(ComFile, B);
            B:=$75;         {Jne    }
            Write(ComFile, B);
            B:=$03;
            Write(ComFile, B);
            B:=$E9;         {Jmp   else}
            Write(ComFile, B);
            B:=$00;
            Write(ComFile, B,B);
            Adr11:=FilePos(ComFile)-2;
            If not ((Ch1='c') and (Ch2=Chr(11)))
             then Error(24);
            Read(SkFile, Ch1, Ch2);
            Repeat
             Operator;
             If FElse
              then begin
               Ch1:=C1;
               Ch2:=C2;
              end
              else Read(SkFile, Ch1, Ch2);
             FElse:=False;
            Until (Ch1='c') and (Ch2=Chr(15));
            FIf:=True;
            Read(SkFile, Ch1, Ch2);
            If (Ch2<>';')
             then Error(6);
            Read(SkFile, C1, C2);
            If (C1='c') and (C2=Chr(12))
             then begin
              B:=$E9;         {Jmp   endelse}
              Write(ComFile, B);
              B:=$00;
              Write(ComFile, B,B);
              Adr4:=FilePos(ComFile)-2;
             end;
            FElse:=True;
            Adr33:=FilePos(ComFile);
            Seek(ComFile, Adr11);
            LR:=Lo(Adr33-Adr11-2);
            HR:=Hi(Adr33-Adr11-2);
            Write(ComFile, LR, HR);
            Seek(ComFile, Adr33);
           End;
   Chr(12):{else}
           Begin
            If not FIf
             then Error(25);
            Read(SkFile, Ch1, Ch2);
            Repeat
             Operator;
             If FElse
              then begin
               Ch1:=C1;
               Ch2:=C2;
              end
              else Read(SkFile, Ch1, Ch2);
             FElse:=False;
            Until (Ch1='c') and (Ch2=Chr(27));
            FIf:=False;
            Adr333:=FilePos(ComFile);
            Seek(ComFile, Adr4);
            LR:=Lo(Adr333-Adr4-2);
            HR:=Hi(Adr333-Adr4-2);
            Write(ComFile, LR, HR);
            Seek(ComFile, Adr333);
           End;
   Chr(13):{write}
            PWrite;
   Chr(21):{read}
           Begin
            Read(SkFile, Ch1, Ch2);
            If Ch2<>'('
             then Error(17);
            Read(SkFile, Ch1, Ch2);
            If Ch1<>'i'
             then Error(14);
            ChRd:=Ch2;
            T:=TabI[Ord(ChRd)].Tip;
            If TabI[Ord(ChRd)].ArrT<>1
             then begin
              L:=Lo(AddrI[Ord(ChRd)]);
              H:=Hi(AddrI[Ord(ChRd)]);
             end;
            Read(SkFile, Ch1, Ch2);
            If Ch2<>')'
             then Error(20);
            If T<>4
             then begin
              B:=$B9;     {Mov    Cx, 0000}
              Write(ComFile, B);
              B:=$00;
              Write(ComFile, B, B);
              B:=$51;    {Push   CX}
              Write(ComFile, B);
              B:=$BB;    {Mov    Bx, 000A}
              LR:=$0A;
              HR:=$00;
              Write(ComFile, B, LR, HR);
              LR:=$B4;    {mov AH,08}
              HR:=$08;
              Write(ComFile, LR, HR);
              LR:=$CD;    {int 21h}
              HR:=$21;
              Write(ComFile, LR, HR);
              LR:=$3C;    {cmp Al,2F}
              HR:=$2F;
              Write(ComFile, LR, HR);
              Case T of
               1,3 : begin
                  LR:=$76;    {jna upr}
                  HR:=$1F;
                  Write(ComFile, LR, HR);
                  LR:=$3C;    {cmp Al,3A}
                  HR:=$3A;
                  Write(ComFile, LR, HR);
                  LR:=$73;    {jnb upr}
                  HR:=$1B;
                  Write(ComFile, LR, HR);
                 end;
               2 : begin
                  LR:=$76;    {jna upr}
                  HR:=$26;
                  Write(ComFile, LR, HR);
                  LR:=$3C;    {cmp Al,3A}
                  HR:=$3A;
                  Write(ComFile, LR, HR);
                  LR:=$73;    {jnb upr}
                  HR:=$22;
                  Write(ComFile, LR, HR);
                 end;
              End;
              Case T of
               1 : begin
                  B:=$83;    {cmp CX,03}
                  LR:=$F9;
                  HR:=$03;
                  Write(ComFile, B, LR, HR);
                 end;
               2,3 : begin
                  B:=$83;    {Cmp CX, 05}
                  LR:=$F9;
                  HR:=$05;
                  Write(ComFile, B, LR, HR);
                end;
              End;
              LR:=$74;    {je beg}
              HR:=$EF;
              Write(ComFile, LR, HR);
              LR:=$8A;    {mov dl,al}
              HR:=$D0;
              Write(ComFile, LR, HR);
              LR:=$B4;    {mov AH,02}
              HR:=$02;
              Write(ComFile, LR, HR);
              LR:=$CD;    {int 21h}
              HR:=$21;
              Write(ComFile, LR, HR);
              LR:=$B6;    {mov DH,00}
              HR:=$00;
              Write(ComFile, LR, HR);
              B:=$83;    {sub DX,30h}
              LR:=$EA;
              HR:=$30;
              Write(ComFile, B, LR, HR);
              B:=$58;    {pop AX}
              Write(ComFile, B);
              B:=$52;    {push DX}
              Write(ComFile, B);
              Case T of
               1 : begin
                  LR:=$F7;    {mul BX}
                  HR:=$E3;
                  Write(ComFile, LR, HR);
                  B:=$5A;    {pop DX}
                  Write(ComFile, B);
                  LR:=$03;    {add AX,DX}
                  HR:=$C2;
                  Write(ComFile, LR, HR);
                  B:=$41;    {inc CX}
                  Write(ComFile, B);
                  B:=$50;    {push AX}
                  Write(ComFile, B);
                  LR:=$EB;    {jmp beg}
                  HR:=$D9;
                  Write(ComFile, LR, HR);
                end;
               3 : begin
                  LR:=$F7;    {mul BX}
                  HR:=$E3;
                  Write(ComFile, LR, HR);
                  B:=$5A;    {pop DX}
                  Write(ComFile, B);
                  LR:=$03;    {add AX,DX}
                  HR:=$C2;
                  Write(ComFile, LR, HR);
                  B:=$41;    {inc CX}
                  Write(ComFile, B);
                  B:=$50;    {push AX}
                  Write(ComFile, B);
                  LR:=$EB;    {jmp beg}
                  HR:=$D9;
                  Write(ComFile, LR, HR);
                end;
               2 : begin
                  LR:=$F7;    {imul BX}
                  HR:=$EB;
                  Write(ComFile, LR, HR);
                  B:=$5A;    {pop DX}
                  Write(ComFile, B);
                  B:=$3D;    {cmp AX,8000}
                  LR:=$00;
                  HR:=$80;
                  Write(ComFile, B, LR, HR);
                  LR:=$72;    {jb NN}
                  HR:=$02;
                  Write(ComFile, LR, HR);
                  LR:=$F7;    {neg DX}
                  HR:=$DA;
                  Write(ComFile, LR, HR);
                  LR:=$03;    {add AX,DX}
                  HR:=$C2;
                  Write(ComFile, LR, HR);
                  B:=$41;    {inc CX}
                  Write(ComFile, B);
                  B:=$50;    {push AX}
                  Write(ComFile, B);
                  LR:=$EB;    {jmp beg}
                  HR:=$D2;
                  Write(ComFile, LR, HR);
                end;
              End;
              LR:=$3C;    {cmp Al,08}
              HR:=$08;
              Write(ComFile, LR, HR);
              LR:=$75;    {jne nxt}
              HR:=$10;
              Write(ComFile, LR, HR);
              LR:=$8A;    {mov dl,al}
              HR:=$D0;
              Write(ComFile, LR, HR);
              LR:=$B4;    {mov AH,02}
              HR:=$02;
              Write(ComFile, LR, HR);
              LR:=$CD;    {int 21h}
              HR:=$21;
              Write(ComFile, LR, HR);
              B:=$58;    {pop AX}
              Write(ComFile, B);
              LR:=$BA;    {mov DX,0}
              HR:=$00;
              Write(ComFile, B, LR, HR);
              Case T of
               1,3 : begin
                  LR:=$F7;    {div BX}
                  HR:=$F3;
                  Write(ComFile, LR, HR);
                  B:=$50;    {push AX}
                  Write(ComFile, B);
                  B:=$49;    {dec CX}
                  Write(ComFile, B);
                  LR:=$EB;    {jmp beg}
                  HR:=$C5;
                  Write(ComFile, LR, HR);
                  LR:=$3C;    {cmp Al,0D}
                  HR:=$0D;
                  Write(ComFile, LR, HR);
                  LR:=$75;    {jne beg}
                  HR:=$C1;
                  Write(ComFile, LR, HR);
                  B:=$58;    {pop AX}
                  Write(ComFile, B);
                 end;
               2 : begin
                  LR:=$F7;    {idiv BX}
                  HR:=$FB;
                  Write(ComFile, LR, HR);
                  B:=$50;    {push AX}
                  Write(ComFile, B);
                  B:=$49;    {dec CX}
                  Write(ComFile, B);
                  LR:=$EB;    {jmp beg}
                  HR:=$BE;
                  Write(ComFile, LR, HR);
                  LR:=$3C;    {cmp AL,2D}
                  HR:=$2D;
                  Write(ComFile, LR, HR);
                  LR:=$75;    {jne NXT1}
                  HR:=$06;
                  Write(ComFile, LR, HR);
                  B:=$58;    {pop AX}
                  Write(ComFile, B);
                  LR:=$F7;    {neg AX}
                  HR:=$D8;
                  Write(ComFile, LR, HR);
                  B:=$50;    {push AX}
                  Write(ComFile, B);
                  LR:=$EB;    {jmp beg}
                  HR:=$B4;
                  Write(ComFile, LR, HR);
                  LR:=$3C;    {cmp Al,0D}
                  HR:=$0D;
                  Write(ComFile, LR, HR);
                  LR:=$75;    {jne beg}
                  HR:=$B0;
                  Write(ComFile, LR, HR);
                  B:=$58;    {pop AX}
                  Write(ComFile, B);
                 end;
             End;
            end
            else begin
             LR:=$B4;    {mov AH,01}
             HR:=$01;
             Write(ComFile, LR, HR);
             LR:=$CD;    {int 21h}
             HR:=$21;
             Write(ComFile, LR, HR);
            end;
            Case T of
             1,4 : B:=$A2;
             2,3 : B:=$A3;
            End;
            Write(ComFile, B, L, H);
            PWriteLn;
           End;
   Chr(22):{writeln}
           Begin
            PWrite;
            PWriteLn;
           End;
   Chr(24):{case}
           Begin
            Read(SkFile, Ch1, Ch2);
            If Ch1<>'i'
             then Error(12);
            ChC:=Ch2;
            If TabI[Ord(ChC)].ArrT=1
             then begin
              Read(SkFile, Ch1, Ch2);
              If Ch2<>'['
               then Error(7);
              Read(SkFile, Ch1, Ch2);
              If Ch2<>'{'
               then Error(14);
              Vyrazhenie;
              Read(SkFile, Ch1, Ch2);
              If Ch2<>']'
               then Error(9);
              B:=$48;        {Dec   Ax}
              Write(ComFile, B);
              B:=$BB;          {Mov   Bx, [i]}
              Write(ComFile, B);
              LR:=Lo(AddrI[Ord(ChC)]);
              HR:=Hi(AddrI[Ord(ChC)]);
              Write(ComFile, LR, HR);
              B:=$03;          {Add   Bx, Ax}
              Write(ComFile, B);
              B:=$D8;
              Write(ComFile, B);
              B:=$03;          {Add   Bx, Ax}
              Write(ComFile, B);
              B:=$D8;
              Write(ComFile, B);
              B:=$53;          {Push   Bx}
              Write(ComFile, B);
             end;
            T:=TabI[Ord(ChC)].Tip;
            Read(SkFile, Ch1, Ch2);
            If (Ch1<>'c') or ((Ch1='c') and (Ch2<>Chr(28)))
             then Error(10);
            Read(SkFile, Ch1, Ch2);
            Repeat
             If Ch2<>'{'
              then Error(14);
             Vyrazhenie;
             If TVyr<>T
              then Error(26);
             Read(SkFile, Ch1, Ch2);
             If Ch2<>':'
              then Error(21);
             B:=$50;         {Push   Ax}
             Write(ComFile, B);
             If TabI[Ord(ChC)].ArrT=1
              then begin
               B:=$58;         {Pop    Ax}
               Write(ComFile, B);
               B:=$5B;         {Pop    Bx}
               Write(ComFile, B);
               B:=$53;         {Push   Bx}
               Write(ComFile, B);
               B:=$50;         {Push   Ax}
               Write(ComFile, B);
              end
              else begin
               B:=$BB;          {Mov   Bx, LoHi}
               Write(ComFile, B);
               LR:=Lo(AddrI[Ord(ChC)]);
               HR:=Hi(AddrI[Ord(ChC)]);
               Write(ComFile, LR, HR);
              end;
             B:=$8B;            {Mov   Ax, [Bx]}
             Write(ComFile, B);
             B:=$07;
             Write(ComFile, B);
             B:=$5B;        {Pop    Bx}
             Write(ComFile, B);
             B:=$3B;        {Cmp    Ax, Bx}
             Write(ComFile, B);
             B:=$C3;
             Write(ComFile, B);
             B:=$0F;        {Jne    0000}
             Write(ComFile, B);
             B:=$85;
             Write(ComFile, B);
             B:=$00;
             Write(ComFile, B, B);
             Adr1111:=FilePos(ComFile)-2;
             Read(SkFile, Ch1, Ch2);
             If Ch1<>'c'
              then Error(11);
             Repeat
              Operator;
              If FElse
               then begin
                Ch1:=C1;
                Ch2:=C2;
               end
               else Read(SkFile, Ch1, Ch2);
              FElse:=False;
             Until (Ch1='c') and (Ch2=Chr(25));
             Adr2222:=FilePos(ComFile);
             Seek(ComFile, Adr1111);
             LR:=Lo(Adr2222-Adr1111-2);
             HR:=Hi(Adr2222-Adr1111-2);
             Write(ComFile, LR, HR);
             Seek(ComFile, Adr2222);
             Read(SkFile, Ch1, Ch2);
            Until (Ch1='c') and (Ch2=Chr(26));
            B:=$5B;         {Pop    Bx}
            Write(ComFile, B);
           End;
   Chr(30):{equal}
           Begin
            Read(SkFile, Ch1, Ch2);
            If Ch2<>':'
             then Error(21);
            Read(SkFile, Ch1, Ch2);
            If Ch1<>'i'
             then Error(12);
            ChE:=Ch2;
            T:=TabI[Ord(ChE)].Tip;
            If TabI[Ord(ChE)].ArrT=1
             then begin
              Read(SkFile, Ch1, Ch2);
              If Ch2<>'['
               then Error(7);
              Read(SkFile, Ch1, Ch2);
              If Ch2<>'{'
               then Error(14);
              Vyrazhenie;
              Read(SkFile, Ch1, Ch2);
              If Ch2<>']'
               then Error(9);
              B:=$50;        {Push   Ax}
              Write(ComFile, B);
             end;
            Read(SkFile, Ch1, Ch2);
            If Ch2<>','
             then Error(22);
            Read(SkFile, Ch1, Ch2);
            If Ch2<>'{'
             then Error(14);
            Vyrazhenie;
            If not CheckT
             then Error(26);
            If TabI[Ord(ChE)].ArrT=1
             then begin
              B:=$5B;        {Pop    Bx}
              Write(ComFile, B);
              B:=$50;        {Push   Ax}
              Write(ComFile, B);
              B:=$8B;        {Mov   Ax, Bx}
              Write(ComFile, B);
              B:=$C3;
              Write(ComFile, B);
              B:=$48;        {Dec   Ax}
              Write(ComFile, B);
              B:=$BB;          {Mov   Bx, [i]}
              Write(ComFile, B);
              LR:=Lo(AddrI[Ord(ChE)]);
              HR:=Hi(AddrI[Ord(ChE)]);
              Write(ComFile, LR, HR);
              B:=$03;          {Add   Bx, Ax}
              Write(ComFile, B);
              B:=$D8;
              Write(ComFile, B);
              B:=$03;          {Add   Bx, Ax}
              Write(ComFile, B);
              B:=$D8;
              Write(ComFile, B);
              B:=$58;        {Pop    Ax}
              Write(ComFile, B);
             end
             else begin
              B:=$BB;
              LR:=Lo(AddrI[Ord(ChE)]);
              HR:=Hi(AddrI[Ord(ChE)]);
              Write(ComFile, B, LR, HR);
             end;
            B:=$89;
            Write(ComFile, B);
            B:=$07;
            Write(ComFile, B);
           End;
  End;
  If FElse
   then begin
    Ch1:=C1;
    Ch2:=C2;
   end
   else begin
    Read(SkFile, Ch1, Ch2);
    If (Ch2<>';')
     then Error(6);
   end;
 End;
Procedure ClosePr; Forward;
Procedure Telo;
 Begin
  Read(SkFile, Ch1, Ch2);
  If Ch1<>'c'
   then Error(11);
  Repeat
   Operator;
   If FElse
    then begin
     Ch1:=C1;
     Ch2:=C2;
    end
    else Read(SkFile, Ch1, Ch2);
   FElse:=False;
  Until (Ch1='c') and (Ch2=Chr(8));
  ClosePr;
 End;
 {------------------Code-------------------}
Procedure ClosePr;
 Var
  B     : Byte;
 Begin
  B:=$CD;           {Int   20h}
  Write(ComFile, B);
  B:=$20;
  Write(ComFile, B);
  B:=$C3;           {Ret      }
  Write(ComFile, B);
 End;
Procedure InitPr;
 Var
  B         : Byte;
  LR, HR    : Byte;
  i, h      : Byte;
  NB        : Integer;
 Begin
  B:=$1E;           {Push  DS}
  Write(ComFile, B);
  B:=$B8;           {Mov   AX, 0000}
  Write(ComFile, B);
  B:=$00;
  Write(ComFile, B);
  Write(ComFile, B);
  B:=$50;           {Push  AX}
  Write(ComFile, B);
  B:=$8C;           {Mov   AX, CS}
  Write(ComFile, B);
  B:=$C8;
  Write(ComFile, B);
  B:=$8E;           {Mov   DS, AX}
  Write(ComFile, B);
  B:=$D8;
  Write(ComFile, B);
  B:=$E9;           {Jmp     }
  Write(ComFile, B);
  LR:=Lo(N2Byte+N2Str+1);
  HR:=Hi(N2Byte+N2Str+1);
  Write(ComFile, LR, HR);
  B:=$00;
  For i:=1 to N2Byte do
   Write(ComFile, B);
  NB:=0;
  If NRus<>0 then
   For i:=1 to NRuS do
    begin
     AddrK[i]:=N2Byte+$100+12+NB;
     For h:=1 to Length(TabRuS[i]) do
      begin
       B:=Ord(TabRuS[i,h]);
       Write(ComFile, B);
      end;
     B:=Ord('$');
     Write(ComFile, B);
     NB:=NB+Length(TabRuS[i])+1;
    end;
  Write(ComFile, B);
 End;

 Begin
  ClrScr;
  FEndVar:=False;
  FIf:=False;
  NRuS:=0;
  Min:=False;
  NN:=0;
  NI:=0;
  Write('Введите имя файла : ');
  Read(FName);
  FNameSk:=FName;
  Delete(FNameSk,Length(FNameSk)-3,4);
  FNameCom:=FNameSk;
  FNameSk:=FNameSk+'.skn';
  FNameCom:=FNameCom+'.com';
  Assign(PrFile, FName);
  Assign(SkFile, FNameSk);
  Assign(ComFile, FNameCom);
  Reset(PrFile);
  ReWrite(SkFile);
  ReWrite(ComFile);
  While not EOF(PrFile) do
   Begin
    j:=1;
    ReadLn(PrFile, StrF);
    Str1:=StrF;
    While StrF<>'' do
     Begin
      If StrF[1] in Number
       then PreobrN
       else If StrF[1] in Letter
             then PreobrL
             else If StrF[1] in Symbol
                   then PreobrS
                   else If StrF[1]=' '
                         then Delete(StrF,1,1)
                         else Error(0);
     End;
   End;
  Close(PrFile);
  Close(SkFile);
  FObjav:=False;
  FTelo:=False;
  Reset(SkFile);
  Read(SkFile, Ch1, Ch2);
  If Ch1='c'
   then Begin
         If not FObjav
          then If Ch2=Chr(1)
                then begin
                      Objavlenie;
                      FObjav:=True;
                     end
                else Error(1);
          If not FTelo
           then begin
            Read(SkFile, Ch1, Ch2);
            If Ch2=Chr(7)
             then begin
                   InitPr;
                   Telo;
                   FTelo:=True;
                  end
             else Error(2);
           end;
        End
   else Error(1);
  Close(SkFile);
 End.Program SkanAnalizCode;
 Uses
  Crt;
 Const
  Number : Set of Char = ['0'..'9'];
  Letter : Set of Char = ['a'..'z'];
  Symbol : Set of Char = ['(',')','[',']','{','}',':',';',','
                         ,'+','-','=','*','/','<','>','"',#39
