📄 synhighlighterhaskell.pas
字号:
begin
inc(Run);
FExtTokenID := xtkSubtract;
end;
end;
end;
procedure TSynHaskellSyn.ModSymbolProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {mod assign}
begin
inc(Run, 2);
FExtTokenID := xtkModAssign;
end;
else {mod}
begin
inc(Run);
FExtTokenID := xtkMod;
end;
end;
end;
procedure TSynHaskellSyn.NotSymbolProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {not equal}
begin
inc(Run, 2);
FExtTokenID := xtkNotEqual;
end;
else {not}
begin
inc(Run);
FExtTokenID := xtkLogComplement;
end;
end;
end;
procedure TSynHaskellSyn.NullProc;
begin
fTokenID := tkNull;
end;
procedure TSynHaskellSyn.NumberProc;
begin
inc(Run);
fTokenID := tkNumber;
while FLine[Run] in
['0'..'9', 'A'..'F', 'a'..'f', '.', 'u', 'U', 'l', 'L', 'x', 'X'] do
begin
case FLine[Run] of
'.':
if FLine[Run + 1] = '.' then break;
end;
inc(Run);
end;
end;
procedure TSynHaskellSyn.OrSymbolProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {or assign}
begin
inc(Run, 2);
FExtTokenID := xtkIncOrAssign;
end;
'|': {logical or}
begin
inc(Run, 2);
FExtTokenID := xtkLogOr;
end;
else {or}
begin
inc(Run);
FExtTokenID := xtkIncOr;
end;
end;
end;
procedure TSynHaskellSyn.PlusProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {add assign}
begin
inc(Run, 2);
FExtTokenID := xtkAddAssign;
end;
'+': {increment}
begin
inc(Run, 2);
FExtTokenID := xtkIncrement;
end;
else {add}
begin
inc(Run);
FExtTokenID := xtkAdd;
end;
end;
end;
procedure TSynHaskellSyn.PointProc;
begin
fTokenID := tkSymbol;
if (FLine[Run + 1] = '.') and (FLine[Run + 2] = '.') then
begin {ellipse}
inc(Run, 3);
FExtTokenID := xtkEllipse;
end
else {point}
begin
inc(Run);
FExtTokenID := xtkPoint;
end;
end;
procedure TSynHaskellSyn.RoundCloseProc;
begin
inc(Run);
fTokenID := tkSymbol;
FExtTokenID := xtkRoundClose;
end;
procedure TSynHaskellSyn.RoundOpenProc;
begin
inc(Run);
FTokenID := tkSymbol;
FExtTokenID := xtkRoundOpen;
end;
procedure TSynHaskellSyn.SemiColonProc;
begin
inc(Run);
fTokenID := tkSymbol;
FExtTokenID := xtkSemiColon;
if fRange = rsAsm then fRange := rsUnknown;
end;
procedure TSynHaskellSyn.SlashProc;
begin
case FLine[Run + 1] of
'=': {divide assign}
begin
inc(Run, 2);
fTokenID := tkSymbol;
FExtTokenID := xtkDivideAssign;
end;
else {divide}
begin
inc(Run);
fTokenID := tkSymbol;
FExtTokenID := xtkDivide;
end;
end;
end;
procedure TSynHaskellSyn.SpaceProc;
begin
inc(Run);
fTokenID := tkSpace;
while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run);
end;
procedure TSynHaskellSyn.SquareCloseProc;
begin
inc(Run);
fTokenID := tkSymbol;
FExtTokenID := xtkSquareClose;
end;
procedure TSynHaskellSyn.SquareOpenProc;
begin
inc(Run);
fTokenID := tkSymbol;
FExtTokenID := xtkSquareOpen;
end;
procedure TSynHaskellSyn.StarProc;
begin
fTokenID := tkSymbol;
case FLine[Run + 1] of
'=': {multiply assign}
begin
inc(Run, 2);
FExtTokenID := xtkMultiplyAssign;
end;
else {star}
begin
inc(Run);
FExtTokenID := xtkStar;
end;
end;
end;
procedure TSynHaskellSyn.StringProc;
begin
fTokenID := tkString;
repeat
if fLine[Run] = '\' then begin
if fLine[Run + 1] in [#34, '\'] then
Inc(Run);
end;
inc(Run);
until fLine[Run] in [#0, #10, #13, #34];
if FLine[Run] = #34 then
inc(Run);
end;
procedure TSynHaskellSyn.TildeProc;
begin
inc(Run); {bitwise complement}
fTokenId := tkSymbol;
FExtTokenID := xtkBitComplement;
end;
procedure TSynHaskellSyn.XOrSymbolProc;
begin
fTokenID := tkSymbol;
Case FLine[Run + 1] of
'=': {xor assign}
begin
inc(Run, 2);
FExtTokenID := xtkXorAssign;
end;
else {xor}
begin
inc(Run);
FExtTokenID := xtkXor;
end;
end;
end;
procedure TSynHaskellSyn.UnknownProc;
begin
{$IFDEF SYN_MBCSSUPPORT}
if FLine[Run] in LeadBytes then
Inc(Run, 2)
else
{$ENDIF}
inc(Run);
fTokenID := tkUnknown;
end;
procedure TSynHaskellSyn.Next;
begin
fAsmStart := False;
fTokenPos := Run;
case fRange of
rsAnsiC, rsAnsiCAsm,
rsAnsiCAsmBlock: AnsiCProc;
else
begin
fRange := rsUnknown;
fProcTable[fLine[Run]];
end;
end;
end;
function TSynHaskellSyn.GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
begin
case Index of
SYN_ATTR_COMMENT: Result := fCommentAttri;
SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri;
SYN_ATTR_KEYWORD: Result := fKeyAttri;
SYN_ATTR_STRING: Result := fStringAttri;
SYN_ATTR_WHITESPACE: Result := fSpaceAttri;
else Result := nil;
end;
end;
function TSynHaskellSyn.GetEol: Boolean;
begin
Result := fTokenID = tkNull;
end;
function TSynHaskellSyn.GetRange: Pointer;
begin
Result := Pointer(fRange);
end;
function TSynHaskellSyn.GetToken: String;
var
Len: LongInt;
begin
Len := Run - fTokenPos;
SetString(Result, (FLine + fTokenPos), Len);
end;
function TSynHaskellSyn.GetTokenID: TtkTokenKind;
begin
Result := fTokenId;
end;
function TSynHaskellSyn.GetExtTokenID: TxtkTokenKind;
begin
Result := FExtTokenID;
end;
function TSynHaskellSyn.GetTokenAttribute: TSynHighlighterAttributes;
begin
case fTokenID of
tkComment: Result := fCommentAttri;
tkIdentifier: Result := fIdentifierAttri;
tkKey: Result := fKeyAttri;
tkNumber: Result := fNumberAttri;
tkSpace: Result := fSpaceAttri;
tkString: Result := fStringAttri;
tkSymbol: Result := fSymbolAttri;
else Result := nil;
end;
end;
function TSynHaskellSyn.GetTokenKind: integer;
begin
Result := Ord(GetTokenID);
end;
function TSynHaskellSyn.GetTokenPos: Integer;
begin
Result := fTokenPos;
end;
procedure TSynHaskellSyn.ResetRange;
begin
fRange:= rsUnknown;
end;
procedure TSynHaskellSyn.SetRange(Value: Pointer);
begin
fRange := TRangeState(Value);
end;
procedure TSynHaskellSyn.EnumUserSettings(settings: TStrings);
begin
{$IFNDEF SYN_CLX}
{ returns the user settings that exist in the registry }
with TBetterRegistry.Create do
begin
try
RootKey := HKEY_LOCAL_MACHINE;
if OpenKeyReadOnly('\SOFTWARE\Borland\C++Builder') then
begin
try
GetKeyNames(settings);
finally
CloseKey;
end;
end;
finally
Free;
end;
end;
{$ENDIF}
end;
function TSynHaskellSyn.GetIdentChars: TSynIdentChars;
begin
Result := ['_', '0'..'9', 'a'..'z', 'A'..'Z'];
end;
function TSynHaskellSyn.IsFilterStored: Boolean;
begin
Result := fDefaultFilter <> SYNS_FilterHaskell;
end;
class function TSynHaskellSyn.GetLanguageName: string;
begin
Result := SYNS_LangHaskell;
end;
class function TSynHaskellSyn.GetCapabilities: TSynHighlighterCapabilities;
begin
Result := inherited GetCapabilities + [hcUserSettings];
end;
function TSynHaskellSyn.GetSampleSource: string;
begin
Result := '-- Haskell Sample Source'#13#10 +
'tail :: [a] -> [a]'#13#10 +
'tail (x:xs) = xs'#13#10 +
'';
end;
initialization
MakeIdentTable;
{$IFNDEF SYN_CPPB_1}
RegisterPlaceableHighlighter(TSynHaskellSyn);
{$ENDIF}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -