synhighlighterunreal.pas

来自「一个mwEdit控件原码,比mwCuuEdit0.92a功能先进.」· PAS 代码 · 共 2,004 行 · 第 1/5 页

PAS
2,004
字号
  if KeyComp('CONTINUE') then Result := tkKey else
    if KeyComp('REGISTER') then Result := tkKey else
      if KeyComp('STRUCT') then Result := tkKey else
        if KeyComp('SINGULAR') then Result := tkKey2 else
          if KeyComp('EDITINLINE') then Result := tkKey2 else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func102: TtkTokenKind;
begin
  if KeyComp('FUNCTION') then Result := tkKey else
    if KeyComp('OPTIONAL') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func103: TtkTokenKind;
begin
  if KeyComp('GLOBALCONFIG') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func104: TtkTokenKind;
begin
  if KeyComp('SIMULATED') then Result := tkKey2 else
    if KeyComp('CPPTEXT') then Result := tkKey else Result := tkIdentifier;

end;

function TSynUnrealSyn.Func106: TtkTokenKind;
begin
  if KeyComp('ITERATOR') then Result := tkKey else
    if KeyComp('PROTECTED') then Result := tkKey2 else
      if KeyComp('NOTPLACEABLE') then Result := tkKey2 else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func107: TtkTokenKind;
begin
  if KeyComp('ROTATOR') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func108: TtkTokenKind;
begin
  if KeyComp('OPERATOR') then Result := tkKey else
    if KeyComp('INVARIANT') then Result := tkKey2 else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func109: TtkTokenKind;
begin
  if KeyComp('EDITCONST') then Result := tkKey2 else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func113: TtkTokenKind;
begin
  if KeyComp('TEXTURE') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func115: TtkTokenKind;
begin
  if KeyComp('INTRINSIC') then Result := tkKey2 else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func120: TtkTokenKind;
begin
  if KeyComp('TRANSIENT') then Result := tkKey2 else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func122: TtkTokenKind;
begin
  if KeyComp('REPLICATION') then Result := tkKey2 else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func126: TtkTokenKind;
begin
  if KeyComp('ENUMCOUNT') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func127: TtkTokenKind;
begin
  if KeyComp('NOEXPORT') then Result := tkKey2 else
    if KeyComp('BOUNDINGBOX') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func128: TtkTokenKind;
begin
  if KeyComp('HIDECATEGORIES') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func136: TtkTokenKind;
begin
  if KeyComp('ARRAYCOUNT') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func143: TtkTokenKind;
begin
  if KeyComp('EDITINLINENEW') then Result := tkKey2 else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func144: TtkTokenKind;
begin
  if KeyComp('NOUSERCREATE') then Result := tkKey2 else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func146: TtkTokenKind;
begin
  if KeyComp('EDITINLINEUSE') then Result := tkKey2 else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func147: TtkTokenKind;
begin
  if KeyComp('PREOPERATOR') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func148: TtkTokenKind;
begin
  if KeyComp('PEROBJECTCONFIG') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func156: TtkTokenKind;
begin
  if KeyComp('SCRIPTCONST') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func167: TtkTokenKind;
begin
  if KeyComp('SHOWCATEGORIES') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func172: TtkTokenKind;
begin
  if KeyComp('EDITCONSTARRAY') then Result := tkKey2 else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func174: TtkTokenKind;
begin
  if KeyComp('BOUNDINGVOLUME') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func178: TtkTokenKind;
begin
  if KeyComp('POSTOPERATOR') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func185: TtkTokenKind;
begin
  if KeyComp('COLLAPSECATEGORIES') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func190: TtkTokenKind;
begin
  if KeyComp('EDITINLINENOTIFY') then Result := tkKey2 else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func192: TtkTokenKind;
begin
  if KeyComp('DONTCOLLAPSECATEGORIES') then Result := tkKey else
    if KeyComp('NOTEDITINLINENEW') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func193: TtkTokenKind;
begin
  if KeyComp('NATIVEREPLICATION') then Result := tkKey2 else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func210: TtkTokenKind;
begin
  if KeyComp('DEFAULTPROPERTIES') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func218: TtkTokenKind;
begin
  if KeyComp('EXPORTSTRUCTS') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.Func238: TtkTokenKind;
begin
  if KeyComp('DONTCOLLAPSECATEGORIES') then Result := tkKey else Result := tkIdentifier;
end;

function TSynUnrealSyn.AltFunc: TtkTokenKind;
begin
  Result := tkIdentifier;
end;

function TSynUnrealSyn.IdentKind(MayBe: PChar): TtkTokenKind;
var HashKey: Integer;
begin
  fToIdent := MayBe;
  HashKey := KeyHash(MayBe);
  if HashKey < MAXIDENTTABLE + 1 then Result := fIdentFuncTable[HashKey] else Result := tkIdentifier;
end;

procedure TSynUnrealSyn.MakeMethodTables;
var
  I: Char;
begin
  for I := #0 to #255 do
    case I of
      '&': fProcTable[I] := AndSymbolProc;
      #39: fProcTable[I] := AsciiCharProc;
      '}': fProcTable[I] := BraceCloseProc;
      '{': fProcTable[I] := BraceOpenProc;
      #13: fProcTable[I] := CRProc;
      ':': fProcTable[I] := ColonProc;
      ',': fProcTable[I] := CommaProc;
      '#': fProcTable[I] := DirectiveProc;
      '=': fProcTable[I] := EqualProc;
      '>': fProcTable[I] := GreaterProc;
      '?': fProcTable[I] := QuestionProc;
      'A'..'Z', 'a'..'z', '_': fProcTable[I] := IdentProc;
      #10: fProcTable[I] := LFProc;
      '<': fProcTable[I] := LowerProc;
      '-': fProcTable[I] := MinusProc;
      '%': fProcTable[I] := ModSymbolProc;
      '!': fProcTable[I] := NotSymbolProc;
      #0: fProcTable[I] := NullProc;
      '0'..'9': fProcTable[I] := NumberProc;
      '|': fProcTable[I] := OrSymbolProc;
      '+': fProcTable[I] := PlusProc;
      '.': fProcTable[I] := PointProc;
      ')': fProcTable[I] := RoundCloseProc;
      '(': fProcTable[I] := RoundOpenProc;
      ';': fProcTable[I] := SemiColonProc;
      '/': fProcTable[I] := SlashProc;
      #1..#9, #11, #12, #14..#32: fProcTable[I] := SpaceProc;
      ']': fProcTable[I] := SquareCloseProc;
      '[': fProcTable[I] := SquareOpenProc;
      '*': fProcTable[I] := StarProc;
      #34: fProcTable[I] := StringProc;
      '$', '@': fProcTable[I] := DollarSignProc;
      '~': fProcTable[I] := TildeProc;
      '^': fProcTable[I] := XOrSymbolProc;
      else fProcTable[I] := UnknownProc;
    end;
end;

constructor TSynUnrealSyn.Create(AOwner: TComponent);
begin
{begin}                                                                         //mh 2000-01-14
  inherited Create(AOwner);
  fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment);
  fCommentAttri.Style:= [fsItalic];
  AddAttribute(fCommentAttri);
  fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier);
  AddAttribute(fIdentifierAttri);
  fInvalidAttri := TSynHighlighterAttributes.Create(SYNS_AttrIllegalChar);
  AddAttribute(fInvalidAttri);
  fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord);
  fKeyAttri.Style:= [fsBold];
  AddAttribute(fKeyAttri);
  fKey2Attri := TSynHighlighterAttributes.Create(SYNS_AttrSecondReservedWord);
  fKey2Attri.Style:= [fsBold];
  AddAttribute(fKey2Attri);
  fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber);
  AddAttribute(fNumberAttri);
  fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace);
  fSpaceAttri.Foreground := clWindow;
  AddAttribute(fSpaceAttri);
  fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString);
  AddAttribute(fStringAttri);
  fString2Attri := TSynHighlighterAttributes.Create(SYNS_AttrSingleString);
  AddAttribute(fString2Attri);
  fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol);
  AddAttribute(fSymbolAttri);
  fDirecAttri := TSynHighlighterAttributes.Create(SYNS_AttrDirective);
  AddAttribute(fDirecAttri);
{end}                                                                           //mh 2000-01-14
  SetAttributesOnChange(DefHighlightChange);
  InitIdent;
  MakeMethodTables;
  fRange := rsUnknown;
  fDefaultFilter := SYNS_FilterCPP;
end; { Create }

procedure TSynUnrealSyn.SetLine(NewValue: String; LineNumber:Integer);
begin
  fLine := PChar(NewValue);
  Run := 0;
  fLineNumber := LineNumber;
  Next;
end; { SetLine }

procedure TSynUnrealSyn.AnsiCProc;
begin
  fTokenID := tkComment;
  case FLine[Run] of
    #0:
      begin
        NullProc;
        exit;
      end;
    #10:
      begin
        LFProc;
        exit;
      end;
    #13:
      begin
        CRProc;
        exit;
      end;
  end;

  while FLine[Run] <> #0 do
    case FLine[Run] of
      '*':
        if fLine[Run + 1] = '/' then
        begin
          inc(Run, 2);
          if fRange = rsDirectiveComment then                              
            fRange := rsDirective
          else
            fRange := rsUnKnown;
          break;
        end else
          inc(Run);
      #10: break;
      #13: break;
    else inc(Run);
    end;
end;

procedure TSynUnrealSyn.AndSymbolProc;
begin
  fTokenID := tkSymbol;                                                         //mh 1999-12-06
  case FLine[Run + 1] of
    '=':                               {and assign}
      begin
        inc(Run, 2);
//        fTokenID := tkSymbol;                                                 //mh 1999-12-06
        FExtTokenID := xtkAndAssign;
      end;
    '&':                               {logical and}
      begin
        inc(Run, 2);
//        fTokenID := tkSymbol;                                                 //mh 1999-12-06
        FExtTokenID := xtkLogAnd;
      end;
  else                                 {and}
    begin
      inc(Run);
//      fTokenID := tkSymbol;                                                   //mh 1999-12-06
      FExtTokenID := xtkAnd;
    end;
  end;
end;

procedure TSynUnrealSyn.AsciiCharProc;
begin
  fTokenID := tkString2;
  repeat
    case FLine[Run] of
      #0, #10, #13: break;
      #92:                             {backslash}
        {if we have an escaped single quote it doesn't count}
        if FLine[Run + 1] = #39 then inc(Run);
    end;
    inc(Run);
  until FLine[Run] = #39;
  if FLine[Run] <> #0 then inc(Run);
end;

procedure TSynUnrealSyn.BraceCloseProc;
begin
  inc(Run);
  fTokenId := tkSymbol;
  FExtTokenID := xtkBraceClose;
end;

procedure TSynUnrealSyn.BraceOpenProc;
begin
  inc(Run);
  fTokenId := tkSymbol;
  FExtTokenID := xtkBraceOpen;
end;

procedure TSynUnrealSyn.CRProc;
begin
  fTokenID := tkSpace;
{begin}                                                                         //mh 1999-12-06
(*
  Case FLine[Run + 1] of
    #10: inc(Run, 2);
  else inc(Run);
  end;
*)
  Inc(Run);
  if fLine[Run + 1] = #10 then Inc(Run);
{end}                                                                           //mh 1999-12-06
end;

procedure TSynUnrealSyn.ColonProc;
begin
  fTokenID := tkSymbol;                                                         //mh 1999-12-06
  Case FLine[Run + 1] of
    ':':                               {scope resolution operator}
      begin
        inc(Run, 2);
//        fTokenID := tkSymbol;                                                 //mh 1999-12-06
        FExtTokenID := xtkScopeResolution;
      end;
  else                                 {colon}
    begin
      inc(Run);
//      fTokenID := tkSymbol;                                                   //mh 1999-12-06

⌨️ 快捷键说明

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