📄 synhighlighterpaxpascal.pas
字号:
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func102: TtkTokenKind;
begin
if KeyComp('Function') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func103: TtkTokenKind;
begin
if KeyComp('Virtual') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func105: TtkTokenKind;
begin
if KeyComp('Procedure') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func106: TtkTokenKind;
begin
if KeyComp('Protected') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func112: TtkTokenKind;
begin
if PackageSource and KeyComp('requires') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func117: TtkTokenKind;
begin
if KeyComp('Exports') then
begin
Result := tkKey;
fRange := rsExports;
end
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func126: TtkTokenKind;
begin
if (fRange = rsProperty) and (DelphiVersion >= dvDelphi4) and KeyComp('Implements') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func129: TtkTokenKind;
begin
if (DelphiVersion >= dvDelphi3) and KeyComp('Dispinterface') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func132: TtkTokenKind;
begin
if (DelphiVersion >= dvDelphi4) and KeyComp('Reintroduce') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func133: TtkTokenKind;
begin
if KeyComp('Property') then
begin
Result := tkKey;
fRange := rsProperty;
end
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func136: TtkTokenKind;
begin
if (DelphiVersion >= dvDelphi2) and KeyComp('Finalization') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func141: TtkTokenKind;
begin
if (DelphiVersion >= dvDelphi3) and (fRange = rsProperty) and KeyComp('Writeonly') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func143: TtkTokenKind;
begin
if KeyComp('Destructor') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func166: TtkTokenKind;
begin
if KeyComp('Constructor') then
Result := tkKey
else if KeyComp('Implementation') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func168: TtkTokenKind;
begin
if KeyComp('Initialization') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.Func191: TtkTokenKind;
begin
if (DelphiVersion >= dvDelphi3) and KeyComp('Resourcestring') then
Result := tkKey
else if (DelphiVersion >= dvDelphi3) and KeyComp('Stringresource') then
Result := tkKey
else
Result := tkIdentifier;
end;
function TSynPaxPascalSyn.AltFunc: TtkTokenKind;
begin
Result := tkIdentifier
end;
function TSynPaxPascalSyn.IdentKind(MayBe: PChar): TtkTokenKind;
var
HashKey: Integer;
begin
fToIdent := MayBe;
HashKey := KeyHash(MayBe);
if HashKey < 192 then Result := fIdentFuncTable[HashKey] else
Result := tkIdentifier;
end;
procedure TSynPaxPascalSyn.MakeMethodTables;
var
I: Char;
begin
for I := #0 to #255 do
case I of
#0: fProcTable[I] := NullProc;
#10: fProcTable[I] := LFProc;
#13: fProcTable[I] := CRProc;
#1..#9, #11, #12, #14..#32:
fProcTable[I] := SpaceProc;
'#': fProcTable[I] := AsciiCharProc;
'$': fProcTable[I] := IntegerProc;
#39: fProcTable[I] := StringProc;
'0'..'9': fProcTable[I] := NumberProc;
'A'..'Z', 'a'..'z', '_':
fProcTable[I] := IdentProc;
'{': fProcTable[I] := BraceOpenProc;
'}', '!', '"', '%', '&', '('..'/', ':'..'@', '['..'^', '`', '~':
begin
case I of
'(': fProcTable[I] := RoundOpenProc;
'.': fProcTable[I] := PointProc;
';': fProcTable[I] := SemicolonProc; //mh 2000-10-08
'/': fProcTable[I] := SlashProc;
':', '>': fProcTable[I] := ColonOrGreaterProc;
'<': fProcTable[I] := LowerProc;
'@': fProcTable[I] := AddressOpProc;
else
fProcTable[I] := SymbolProc;
end;
end;
else
fProcTable[I] := UnknownProc;
end;
end;
constructor TSynPaxPascalSyn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fD4syntax := True;
fDelphiVersion := LastDelphiVersion;
fPackageSource := True;
fAsmAttri := TSynHighlighterAttributes.Create(SYNS_AttrAssembler);
AddAttribute(fAsmAttri);
fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment);
fCommentAttri.Style:= [fsItalic];
AddAttribute(fCommentAttri);
fDirecAttri := TSynHighlighterAttributes.Create(SYNS_AttrPreprocessor);
fDirecAttri.Style:= [fsItalic];
AddAttribute(fDirecAttri);
fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier);
AddAttribute(fIdentifierAttri);
fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord);
fKeyAttri.Style:= [fsBold];
AddAttribute(fKeyAttri);
fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber);
AddAttribute(fNumberAttri);
fFloatAttri := TSynHighlighterAttributes.Create(SYNS_AttrFloat);
AddAttribute(fFloatAttri);
fHexAttri := TSynHighlighterAttributes.Create(SYNS_AttrHexadecimal);
AddAttribute(fHexAttri);
fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace);
AddAttribute(fSpaceAttri);
fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString);
AddAttribute(fStringAttri);
fCharAttri := TSynHighlighterAttributes.Create(SYNS_AttrCharacter);
AddAttribute(fCharAttri);
fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol);
AddAttribute(fSymbolAttri);
SetAttributesOnChange(DefHighlightChange);
InitIdent;
MakeMethodTables;
fRange := rsUnknown;
fAsmStart := False;
fDefaultFilter := SYNS_FilterPascal;
end; { Create }
procedure TSynPaxPascalSyn.SetLine(NewValue: string; LineNumber:Integer);
begin
fLine := PChar(NewValue);
Run := 0;
fLineNumber := LineNumber;
Next;
end; { SetLine }
procedure TSynPaxPascalSyn.AddressOpProc;
begin
fTokenID := tkSymbol;
inc(Run);
if fLine[Run] = '@' then inc(Run);
end;
procedure TSynPaxPascalSyn.AsciiCharProc;
begin
fTokenID := tkChar;
Inc(Run);
while FLine[Run] in ['0'..'9', '$', 'A'..'F', 'a'..'f'] do
Inc(Run);
end;
procedure TSynPaxPascalSyn.BorProc;
begin
case fLine[Run] of
#0: NullProc;
#10: LFProc;
#13: CRProc;
else
begin
if fLine[Succ(Run)] = '$' then
fTokenID := tkDirec
else
fTokenID := tkComment;
repeat
if fLine[Run] = '}' then
begin
Inc(Run);
if fRange = rsBorAsm then
fRange := rsAsm
else
fRange := rsUnKnown;
break;
end;
Inc(Run);
until fLine[Run] in [#0, #10, #13];
end;
end;
end;
procedure TSynPaxPascalSyn.BraceOpenProc;
begin
if fRange = rsAsm then
fRange := rsBorAsm
else
fRange := rsBor;
BorProc;
end;
procedure TSynPaxPascalSyn.ColonOrGreaterProc;
begin
fTokenID := tkSymbol;
inc(Run);
if fLine[Run] = '=' then inc(Run);
end;
procedure TSynPaxPascalSyn.CRProc;
begin
fTokenID := tkSpace;
inc(Run);
if fLine[Run] = #10 then
Inc(Run);
end; { CRProc }
procedure TSynPaxPascalSyn.IdentProc;
begin
fTokenID := IdentKind((fLine + Run));
inc(Run, fStringLen);
while Identifiers[fLine[Run]] do
Inc(Run);
end; { IdentProc }
procedure TSynPaxPascalSyn.IntegerProc;
begin
inc(Run);
fTokenID := tkHex;
while FLine[Run] in ['0'..'9', 'A'..'F', 'a'..'f'] do
Inc(Run);
end; { IntegerProc }
procedure TSynPaxPascalSyn.LFProc;
begin
fTokenID := tkSpace;
inc(Run);
end; { LFProc }
procedure TSynPaxPascalSyn.LowerProc;
begin
fTokenID := tkSymbol;
inc(Run);
if fLine[Run] in ['=', '>'] then
Inc(Run);
end; { LowerProc }
procedure TSynPaxPascalSyn.NullProc;
begin
fTokenID := tkNull;
end; { NullProc }
procedure TSynPaxPascalSyn.NumberProc;
begin
Inc(Run);
fTokenID := tkNumber;
while FLine[Run] in ['0'..'9', '.', 'e', 'E', '-', '+'] do
begin
case FLine[Run] of
'.':
if FLine[Run + 1] = '.' then
Break
else
fTokenID := tkFloat;
'e', 'E': fTokenID := tkFloat;
'-', '+':
begin
if fTokenID <> tkFloat then // arithmetic
Break;
if not (FLine[Run - 1] in ['e', 'E']) then
Break; //float, but it ends here
end;
end;
Inc(Run);
end;
end; { NumberProc }
procedure TSynPaxPascalSyn.PointProc;
begin
fTokenID := tkSymbol;
inc(Run);
if fLine[Run] in ['.', ')'] then
Inc(Run);
end; { PointProc }
procedure TSynPaxPascalSyn.AnsiProc;
begin
case fLine[Run] of
#0: NullProc;
#10: LFProc;
#13: CRProc;
else
fTokenID := tkComment;
repeat
if (fLine[Run] = '*') and (fLine[Run + 1] = ')') then begin
Inc(Run, 2);
if fRange = rsAnsiAsm then
fRange := rsAsm
else
fRange := rsUnKnown;
break;
end;
Inc(Run);
until fLine[Run] in [#0, #10, #13];
end;
end;
procedure TSynPaxPascalSyn.RoundOpenProc;
begin
Inc(Run);
case fLine[Run] of
'*':
begin
Inc(Run);
if fRange = rsAsm then
fRange := rsAnsiAsm
else
fRange := rsAnsi;
fTokenID := tkComment;
if not (fLine[Run] in [#0, #10, #13]) then
AnsiProc;
end;
'.':
begin
inc(Run);
fTokenID := tkSymbol;
end;
else
fTokenID := tkSymbol;
end;
end;
{begin} //mh 2000-10-08
procedure TSynPaxPascalSyn.SemicolonProc;
begin
Inc(Run);
fTokenID := tkSymbol;
if fRange in [rsProperty, rsExports] then //pp 2001-14-08
fRange := rsUnknown;
end;
{end} //mh 2000-10-08
procedure TSynPaxPascalSyn.SlashProc;
begin
Inc(Run);
if (fLine[Run] = '/') and (fDelphiVersion > dvDelphi1) then //pp 2001-14-08
begin
fTokenID := tkComment;
repeat
Inc(Run);
until fLine[Run] in [#0, #10, #13];
end
else
fTokenID := tkSymbol;
end;
procedure TSynPaxPascalSyn.SpaceProc;
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -