program gen_self3;
var 
 a:array[1..10000] of char; i:word;
  f:file of char; b:char;
function  M(k:byte):boolean; 
 begin M:=(a[i]=chr(33)) and (a[i+1]=chr(ord('0')+k)) end;
procedure P(b:byte); begin a[i]:=chr(b); inc(i) end;
procedure G(k:byte); begin repeat dec(i) until M(k) end;
procedure C; begin write(a[i]); inc(i) end;
procedure W; 
 begin 
  write(' P(',ord(a[i]):3,');'); inc(i);
  if (i mod 10) = 0 then writeln;
 end;
begin
 i:=0;

 assign(f,'self3.gen'); reset(f);
 while not eof(f) do begin read(f,b); P(ord(b)) end;
 close(f);
   
 G(0);
 inc(i); inc(i);
 repeat C until M(1);
 G(0);
 repeat W until M(2);
 W; W;
 G(1);
 inc(i); inc(i);
 repeat C until M(2);
 { Do something else here }
end.
