📄 synhighlighterhaskell.pas
字号:
begin
if KeyComp('True') then Result := tkKey else Result := tkIdentifier;
end;
function TSynHaskellSyn.Func70: TtkTokenKind;
begin
if KeyComp('type') then Result := tkKey else Result := tkIdentifier;
end;
function TSynHaskellSyn.Func76: TtkTokenKind;
begin
if KeyComp('module') then Result := tkKey else Result := tkIdentifier;
end;
function TSynHaskellSyn.Func84: TtkTokenKind;
begin
if KeyComp('Integer') then Result := tkKey else Result := tkIdentifier;
end;
function TSynHaskellSyn.Func92: TtkTokenKind;
begin
if KeyComp('String') then Result := tkKey else Result := tkIdentifier;
end;
function TSynHaskellSyn.Func93: TtkTokenKind;
begin
if KeyComp('instance') then Result := tkKey else Result := tkIdentifier;
end;
function TSynHaskellSyn.Func96: TtkTokenKind;
begin
if KeyComp('deriving') then Result := tkKey else Result := tkIdentifier;
end;
function TSynHaskellSyn.Func97: TtkTokenKind;
begin
if KeyComp('import') then Result := tkKey else Result := tkIdentifier;
end;
function TSynHaskellSyn.Func131: TtkTokenKind;
begin
if KeyComp('otherwise') then Result := tkKey else Result := tkIdentifier;
end;
function TSynHaskellSyn.AltFunc: TtkTokenKind;
begin
Result := tkIdentifier;
end;
function TSynHaskellSyn.IdentKind(MayBe: PChar): TtkTokenKind;
var
HashKey: Integer;
begin
fToIdent := MayBe;
HashKey := KeyHash(MayBe);
if HashKey < 207 then Result := fIdentFuncTable[HashKey] else Result := tkIdentifier;
end;
procedure TSynHaskellSyn.MakeMethodTables;
var
I: Char;
begin
for I := #0 to #255 do
case I of
'&': fProcTable[I] := AndSymbolProc;
#39: fProcTable[I] := AsciiCharProc;
'@': fProcTable[I] := AtSymbolProc;
'}': fProcTable[I] := BraceCloseProc;
'{': fProcTable[I] := BraceOpenProc;
#13: fProcTable[I] := CRProc;
':': fProcTable[I] := ColonProc;
',': fProcTable[I] := CommaProc;
'=': 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] := TildeProc;
'^': fProcTable[I] := XOrSymbolProc;
else fProcTable[I] := UnknownProc;
end;
end;
constructor TSynHaskellSyn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment);
fCommentAttri.Style:= [fsItalic];
AddAttribute(fCommentAttri);
fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier);
AddAttribute(fIdentifierAttri);
fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord);
fKeyAttri.Style:= [fsBold];
AddAttribute(fKeyAttri);
fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber);
AddAttribute(fNumberAttri);
fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace);
fSpaceAttri.Foreground := clWindow;
AddAttribute(fSpaceAttri);
fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString);
AddAttribute(fStringAttri);
fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol);
AddAttribute(fSymbolAttri);
SetAttributesOnChange(DefHighlightChange);
InitIdent;
MakeMethodTables;
fRange := rsUnknown;
fAsmStart := False;
fDefaultFilter := SYNS_FilterHaskell;
end; { Create }
procedure TSynHaskellSyn.SetLine(NewValue: String; LineNumber:Integer);
begin
fLine := PChar(NewValue);
Run := 0;
fLineNumber := LineNumber;
Next;
end; { SetLine }
procedure TSynHaskellSyn.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 = rsAnsiCAsm then
fRange := rsAsm
else if fRange = rsAnsiCAsmBlock then
fRange := rsAsmBlock
else if fRange = rsDirectiveComment then
fRange := rsDirective
else
fRange := rsUnKnown;
break;
end else
inc(Run);
#10: break;
#13: break;
else inc(Run);
end;
end;
procedure TSynHaskellSyn.AndSymbolProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {and assign}
begin
inc(Run, 2);
FExtTokenID := xtkAndAssign;
end;
'&': {logical and}
begin
inc(Run, 2);
FExtTokenID := xtkLogAnd;
end;
else {and}
begin
inc(Run);
FExtTokenID := xtkAnd;
end;
end;
end;
procedure TSynHaskellSyn.AsciiCharProc;
begin
fTokenID := tkString;
repeat
if fLine[Run] = '\' then begin
if fLine[Run + 1] in [#39, '\'] then
inc(Run);
end;
inc(Run);
until fLine[Run] in [#0, #10, #13, #39];
if fLine[Run] = #39 then
inc(Run);
end;
procedure TSynHaskellSyn.AtSymbolProc;
begin
fTokenID := tkUnknown;
inc(Run);
end;
procedure TSynHaskellSyn.BraceCloseProc;
begin
inc(Run);
fTokenId := tkSymbol;
FExtTokenID := xtkBraceClose;
if fRange = rsAsmBlock then fRange := rsUnknown;
end;
procedure TSynHaskellSyn.BraceOpenProc;
begin
inc(Run);
fTokenId := tkSymbol;
FExtTokenID := xtkBraceOpen;
if fRange = rsAsm then
begin
fRange := rsAsmBlock;
fAsmStart := True;
end;
end;
procedure TSynHaskellSyn.CRProc;
begin
fTokenID := tkSpace;
Inc(Run);
if fLine[Run + 1] = #10 then Inc(Run);
end;
procedure TSynHaskellSyn.ColonProc;
begin
fTokenID := tkSymbol;
Case FLine[Run + 1] of
':': {scope resolution operator}
begin
inc(Run, 2);
FExtTokenID := xtkScopeResolution;
end;
else {colon}
begin
inc(Run);
FExtTokenID := xtkColon;
end;
end;
end;
procedure TSynHaskellSyn.CommaProc;
begin
inc(Run);
fTokenID := tkSymbol;
FExtTokenID := xtkComma;
end;
procedure TSynHaskellSyn.EqualProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {logical equal}
begin
inc(Run, 2);
FExtTokenID := xtkLogEqual;
end;
else {assign}
begin
inc(Run);
FExtTokenID := xtkAssign;
end;
end;
end;
procedure TSynHaskellSyn.GreaterProc;
begin
fTokenID := tkSymbol;
Case FLine[Run + 1] of
'=': {greater than or equal to}
begin
inc(Run, 2);
FExtTokenID := xtkGreaterThanEqual;
end;
'>':
begin
if FLine[Run + 2] = '=' then {shift right assign}
begin
inc(Run, 3);
FExtTokenID := xtkShiftRightAssign;
end
else {shift right}
begin
inc(Run, 2);
FExtTokenID := xtkShiftRight;
end;
end;
else {greater than}
begin
inc(Run);
FExtTokenID := xtkGreaterThan;
end;
end;
end;
procedure TSynHaskellSyn.QuestionProc;
begin
fTokenID := tkSymbol; {conditional}
FExtTokenID := xtkQuestion;
inc(Run);
end;
procedure TSynHaskellSyn.IdentProc;
begin
fTokenID := IdentKind((fLine + Run));
inc(Run, fStringLen);
while Identifiers[fLine[Run]] do inc(Run);
end;
procedure TSynHaskellSyn.LFProc;
begin
fTokenID := tkSpace;
inc(Run);
end;
procedure TSynHaskellSyn.LowerProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {less than or equal to}
begin
inc(Run, 2);
FExtTokenID := xtkLessThanEqual;
end;
'<':
begin
if FLine[Run + 2] = '=' then {shift left assign}
begin
inc(Run, 3);
FExtTokenID := xtkShiftLeftAssign;
end
else {shift left}
begin
inc(Run, 2);
FExtTokenID := xtkShiftLeft;
end;
end;
else {less than}
begin
inc(Run);
FExtTokenID := xtkLessThan;
end;
end;
end;
procedure TSynHaskellSyn.MinusProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {subtract assign}
begin
inc(Run, 2);
FExtTokenID := xtkSubtractAssign;
end;
'-': {decrement}
begin
fTokenID := tkComment;
inc(Run, 2);
while not (fLine[Run] in [#0, #10, #13]) do Inc(Run);
end;
'>': {arrow}
begin
inc(Run, 2);
FExtTokenID := xtkArrow;
end;
else {subtract}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -