www.pudn.com > byyl.rar > PCOMMON.PAS


unit pcommon; 
 
interface 
 
uses 
   Dialogs; 
 
type 
   ErrorKind = (Ambiguous3, Comment3, Kind3, Numeral3,Range3, 
                Syntax3, Type3, Undefined3); 
   String0 = string[100];  ShortString = string[20]; 
var 
  PLName: ShortString; 
  LineNo: integer; 
  Emitting, Errors, CorrectLine: Boolean; 
  Input1, Output1, Notes: text; 
  procedure TestLimit(Length, Maximum: integer); 
  procedure Emit(Value: integer); 
  procedure Rerun; 
  procedure NewLine(Number: integer); 
  procedure Error(Kind: ErrorKind); 
 
implementation 
 
  procedure Emit(Value: integer); 
  begin 
      if Emitting then  Writeln(Output1, Value) 
  end; 
 
  procedure Rerun; 
  begin 
      Reset(Input1); 
      Emitting := true 
  end; 
 
  procedure NewLine(Number: integer); 
  begin 
      LineNo := Number; 
      CorrectLine := true 
  end; 
 
  procedure Error(Kind: ErrorKind); 
   var 
      Text0: ShortString; 
   begin 
      if not Errors then 
          begin 
              Emitting := false;  Errors := true 
          end; 
      case Kind of 
        Ambiguous3: text0 := 'Ambiguous Name'; 
        Comment3  : text0 := 'Invalid Comment3'; 
        Kind3     : text0 := 'Invalid Kind Name'; 
        Numeral3  : text0 := 'Invalid Numeral'; 
        Range3    : text0 := 'Invalid Index Range'; 
        Syntax3   : text0 := 'Invalid Syntax'; 
        Type3     : text0 := 'Invalid Type'; 
        Undefined3: text0 := 'Undefined Name' 
      end; 
     if CorrectLine then 
         begin 
             Writeln(Notes,'Line',LineNo:4,'  ',Text0); 
             CorrectLine := false 
         end; 
  end; 
 
  procedure TestLimit(Length, Maximum: integer); 
   begin 
      if Length >= Maximum then 
         begin 
             showmessage('Program Too Big!'); 
             Closefile(Input1); 
             Closefile(Output1); 
             exit; 
         end 
  end; 
 
end.