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

📄 synhighlightercobol.pas

📁 SynEditStudio delphi 代码编辑器
💻 PAS
📖 第 1 页 / 共 5 页
字号:
begin
  for I := #0 to #255 do
  begin
    case I of
      '-', '0'..'9', 'a'..'z', 'A'..'Z', '.': Identifiers[I] := True;
    else
      Identifiers[I] := False;
    end;
    J := UpCase(I);
    case I in ['-', 'A'..'Z', 'a'..'z'] of
      True: mHashTable[I] := Ord(J) - 64
    else
      mHashTable[I] := 0;
    end;
  end;
end;

procedure TSynCobolSyn.InitIdent;
var
  I: Integer;
  pF: PIdentFuncTableFunc;
begin
  pF := PIdentFuncTableFunc(@fIdentFuncTable);
  for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do
  begin
    pF^ := AltFunc;
    Inc(pF);
  end;
  fIdentFuncTable[2] := Func2;
  fIdentFuncTable[5] := Func5;
  fIdentFuncTable[6] := Func6;
  fIdentFuncTable[7] := Func7;
  fIdentFuncTable[9] := Func9;
  fIdentFuncTable[10] := Func10;
  fIdentFuncTable[11] := Func11;
  fIdentFuncTable[13] := Func13;
  fIdentFuncTable[15] := Func15;
  fIdentFuncTable[16] := Func16;
  fIdentFuncTable[17] := Func17;
  fIdentFuncTable[19] := Func19;
  fIdentFuncTable[21] := Func21;
  fIdentFuncTable[22] := Func22;
  fIdentFuncTable[23] := Func23;
  fIdentFuncTable[24] := Func24;
  fIdentFuncTable[25] := Func25;
  fIdentFuncTable[26] := Func26;
  fIdentFuncTable[27] := Func27;
  fIdentFuncTable[28] := Func28;
  fIdentFuncTable[29] := Func29;
  fIdentFuncTable[30] := Func30;
  fIdentFuncTable[31] := Func31;
  fIdentFuncTable[32] := Func32;
  fIdentFuncTable[33] := Func33;
  fIdentFuncTable[34] := Func34;
  fIdentFuncTable[35] := Func35;
  fIdentFuncTable[36] := Func36;
  fIdentFuncTable[37] := Func37;
  fIdentFuncTable[38] := Func38;
  fIdentFuncTable[39] := Func39;
  fIdentFuncTable[40] := Func40;
  fIdentFuncTable[41] := Func41;
  fIdentFuncTable[42] := Func42;
  fIdentFuncTable[43] := Func43;
  fIdentFuncTable[44] := Func44;
  fIdentFuncTable[45] := Func45;
  fIdentFuncTable[46] := Func46;
  fIdentFuncTable[47] := Func47;
  fIdentFuncTable[48] := Func48;
  fIdentFuncTable[49] := Func49;
  fIdentFuncTable[50] := Func50;
  fIdentFuncTable[51] := Func51;
  fIdentFuncTable[52] := Func52;
  fIdentFuncTable[53] := Func53;
  fIdentFuncTable[54] := Func54;
  fIdentFuncTable[55] := Func55;
  fIdentFuncTable[56] := Func56;
  fIdentFuncTable[57] := Func57;
  fIdentFuncTable[58] := Func58;
  fIdentFuncTable[59] := Func59;
  fIdentFuncTable[60] := Func60;
  fIdentFuncTable[61] := Func61;
  fIdentFuncTable[62] := Func62;
  fIdentFuncTable[63] := Func63;
  fIdentFuncTable[64] := Func64;
  fIdentFuncTable[65] := Func65;
  fIdentFuncTable[66] := Func66;
  fIdentFuncTable[67] := Func67;
  fIdentFuncTable[68] := Func68;
  fIdentFuncTable[69] := Func69;
  fIdentFuncTable[70] := Func70;
  fIdentFuncTable[71] := Func71;
  fIdentFuncTable[72] := Func72;
  fIdentFuncTable[73] := Func73;
  fIdentFuncTable[74] := Func74;
  fIdentFuncTable[75] := Func75;
  fIdentFuncTable[76] := Func76;
  fIdentFuncTable[77] := Func77;
  fIdentFuncTable[78] := Func78;
  fIdentFuncTable[79] := Func79;
  fIdentFuncTable[80] := Func80;
  fIdentFuncTable[81] := Func81;
  fIdentFuncTable[82] := Func82;
  fIdentFuncTable[83] := Func83;
  fIdentFuncTable[84] := Func84;
  fIdentFuncTable[85] := Func85;
  fIdentFuncTable[86] := Func86;
  fIdentFuncTable[87] := Func87;
  fIdentFuncTable[88] := Func88;
  fIdentFuncTable[89] := Func89;
  fIdentFuncTable[90] := Func90;
  fIdentFuncTable[91] := Func91;
  fIdentFuncTable[92] := Func92;
  fIdentFuncTable[93] := Func93;
  fIdentFuncTable[94] := Func94;
  fIdentFuncTable[95] := Func95;
  fIdentFuncTable[96] := Func96;
  fIdentFuncTable[97] := Func97;
  fIdentFuncTable[98] := Func98;
  fIdentFuncTable[99] := Func99;
  fIdentFuncTable[100] := Func100;
  fIdentFuncTable[101] := Func101;
  fIdentFuncTable[102] := Func102;
  fIdentFuncTable[103] := Func103;
  fIdentFuncTable[104] := Func104;
  fIdentFuncTable[105] := Func105;
  fIdentFuncTable[106] := Func106;
  fIdentFuncTable[107] := Func107;
  fIdentFuncTable[108] := Func108;
  fIdentFuncTable[110] := Func110;
  fIdentFuncTable[111] := Func111;
  fIdentFuncTable[112] := Func112;
  fIdentFuncTable[113] := Func113;
  fIdentFuncTable[114] := Func114;
  fIdentFuncTable[115] := Func115;
  fIdentFuncTable[116] := Func116;
  fIdentFuncTable[117] := Func117;
  fIdentFuncTable[119] := Func119;
  fIdentFuncTable[120] := Func120;
  fIdentFuncTable[121] := Func121;
  fIdentFuncTable[122] := Func122;
  fIdentFuncTable[123] := Func123;
  fIdentFuncTable[124] := Func124;
  fIdentFuncTable[125] := Func125;
  fIdentFuncTable[126] := Func126;
  fIdentFuncTable[127] := Func127;
  fIdentFuncTable[128] := Func128;
  fIdentFuncTable[130] := Func130;
  fIdentFuncTable[131] := Func131;
  fIdentFuncTable[132] := Func132;
  fIdentFuncTable[133] := Func133;
  fIdentFuncTable[134] := Func134;
  fIdentFuncTable[137] := Func137;
  fIdentFuncTable[138] := Func138;
  fIdentFuncTable[140] := Func140;
  fIdentFuncTable[141] := Func141;
  fIdentFuncTable[146] := Func146;
  fIdentFuncTable[147] := Func147;
  fIdentFuncTable[149] := Func149;
  fIdentFuncTable[150] := Func150;
  fIdentFuncTable[152] := Func152;
  fIdentFuncTable[153] := Func153;
  fIdentFuncTable[157] := Func157;
  fIdentFuncTable[160] := Func160;
  fIdentFuncTable[161] := Func161;
  fIdentFuncTable[163] := Func163;
  fIdentFuncTable[165] := Func165;
  fIdentFuncTable[167] := Func167;
  fIdentFuncTable[173] := Func173;
  fIdentFuncTable[174] := Func174;
  fIdentFuncTable[188] := Func188;
  fIdentFuncTable[208] := Func208;
end;

function TSynCobolSyn.KeyHash(ToHash: PChar): Integer;
var
  fRun: LongInt;
begin
  fRun := Run;
  Result := 0;

  if (ToHash^ in ['a'..'z', 'A'..'Z']) and (fRun <= fCodeEndPos) then
  begin
    inc(Result, mHashTable[ToHash^]);
    inc(ToHash);
    inc(fRun);

    while (ToHash^ in ['-', '0'..'9', 'a'..'z', 'A'..'Z']) and (fRun <= fCodeEndPos) do
    begin
      inc(Result, mHashTable[ToHash^]);
      inc(ToHash);
      inc(fRun);
    end;
  end;

  fStringLen := ToHash - fToIdent;
end;

function TSynCobolSyn.KeyComp(const aKey: String): Boolean;
var
  I: Integer;
  Temp: PChar;
begin
  Temp := fToIdent;
  if Length(aKey) = fStringLen then
  begin
    Result := True;
    for i := 1 to fStringLen do
    begin
      if mHashTable[Temp^] <> mHashTable[aKey[i]] then
      begin
        Result := False;
        break;
      end;
      inc(Temp);
    end;
  end
  else
    Result := False;
end;

function TSynCobolSyn.Func2: TtkTokenKind;
begin
  if KeyComp('B-AND') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func5: TtkTokenKind;
begin
  if KeyComp('I-O') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func6: TtkTokenKind;
begin
  if KeyComp('DB') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func7: TtkTokenKind;
begin
  if KeyComp('CD') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func9: TtkTokenKind;
begin
  if KeyComp('DE') then Result := tkKey else
    if KeyComp('ADD') then Result := tkKey else
      if KeyComp('CF') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func10: TtkTokenKind;
begin
  if KeyComp('FD') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func11: TtkTokenKind;
begin
  if KeyComp('CH') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func13: TtkTokenKind;
begin
  if KeyComp('END-ADD') then Result := tkKey else
    if KeyComp('ID') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func15: TtkTokenKind;
begin
  if KeyComp('IF') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func16: TtkTokenKind;
begin
  if KeyComp('LD') then Result := tkKey else
    if KeyComp('B-OR') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func17: TtkTokenKind;
begin
  if KeyComp('CBL') then Result := tkPreprocessor else Result := tkIdentifier;
end;

function TSynCobolSyn.Func19: TtkTokenKind;
begin
  if KeyComp('END-IF') then Result := tkKey else
    if KeyComp('AND') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func21: TtkTokenKind;
begin
  if KeyComp('OF') then Result := tkKey else
    if KeyComp('AT') then Result := tkKey else
      if KeyComp('EGI') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func22: TtkTokenKind;
begin
  if KeyComp('RD') then Result := tkKey else
    if KeyComp('GO') then Result := tkKey else
      if KeyComp('PF') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func23: TtkTokenKind;
begin
  if KeyComp('IN') then Result := tkKey else
    if KeyComp('END') then Result := tkKey else
      if KeyComp('SD') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func24: TtkTokenKind;
begin
  if KeyComp('RF') then Result := tkKey else
    if KeyComp('PH') then Result := tkKey else
      if KeyComp('ARE') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func25: TtkTokenKind;
begin
  if KeyComp('AREA') then Result := tkKey else
    if KeyComp('ALL') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func26: TtkTokenKind;
begin
  if KeyComp('RH') then Result := tkKey else
    if KeyComp('FILE-ID') then Result := tkKey else
      if KeyComp('DATA') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func27: TtkTokenKind;
begin
  if KeyComp('BY') then Result := tkKey else
    if KeyComp('DB-DATA-NAME') then Result := tkKey else
      if KeyComp('EMI') then Result := tkKey else
        if KeyComp('OFF') then Result := tkKey else
          if KeyComp('CODE') then Result := tkKey else Result := tkIdentifier;
end;

function TSynCobolSyn.Func28: TtkTokenKind;
begin
  if KeyComp('COMP-9') then Result := tkKey else
    if KeyComp('COMP-8') then Result := tkKey else
      if KeyComp('COMP-7') then Result := tkKey else
        if KeyComp('DBCS') then Result := tkKey else
          if KeyComp('COMP-1') then Result := tkKey else
            if KeyComp('COMP-2') then Result := tkKey else
              if KeyComp('COMP-0') then Result := tkKey else
                if KeyComp('COMP-6') then Result := tkKey else
                  if KeyComp('COMP-5') then Result := tkKey else
                    if KeyComp('PIC') then Result := tkKey else
                      if KeyComp('BEEP') then Result := tkKey else

⌨️ 快捷键说明

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