⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcommon.pas

📁 简单编译器的源代码,是大学课程设计内容,附简单测试用例
💻 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.
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -