📄 synhighlighterdml.pas
字号:
begin
if KeyComp('Lov_selection') and IsQuali then Result := tkQualifier else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func183: TtkTokenKind;
begin
if KeyComp('Display_length') and IsQuali then Result := tkQualifier else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func184: TtkTokenKind;
begin
if KeyComp('Lov_secondary') and IsQuali then Result := tkQualifier else
if KeyComp('Cross_reference') then Result := tkKey else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func185: TtkTokenKind;
begin
if KeyComp('Start_stream') then Result := tkKey else Result := tkIdentifier;
end;
function TSynDmlSyn.Func187: TtkTokenKind;
begin
if KeyComp('Output_block') then Result := tkBlock else Result := tkIdentifier;
end;
function TSynDmlSyn.Func188: TtkTokenKind;
begin
if KeyComp('Output_mask') and IsQuali then Result := tkQualifier else
if KeyComp('Procedure_form') then Result := tkForm else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func203: TtkTokenKind;
begin
if KeyComp('Noexit_forward') and IsQuali then Result := tkQualifier else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func206: TtkTokenKind;
begin
if KeyComp('Lov_reduced_to') and IsQuali then Result := tkQualifier else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func216: TtkTokenKind;
begin
if KeyComp('Receive_arguments') then Result := tkKey else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func219: TtkTokenKind;
begin
if KeyComp('Lov_sorted_by') and IsQuali then Result := tkQualifier else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func221: TtkTokenKind;
begin
if KeyComp('End_disable_trigger') then Result := tkKey else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func232: TtkTokenKind;
begin
if KeyComp('Lov_auto_select') and IsQuali then Result := tkQualifier else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func234: TtkTokenKind;
begin
if KeyComp('Binary_to_poly') then Result := tkFunction else
if KeyComp('Poly_to_binary') then Result := tkFunction else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func235: TtkTokenKind;
begin
if KeyComp('Begin_disable_trigger') then Result := tkKey else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func243: TtkTokenKind;
begin
if KeyComp('Start_transaction') then Result := tkKey else
if KeyComp('Absolute_position') and IsQuali then Result := tkQualifier else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func244: TtkTokenKind;
begin
if KeyComp('Column_heading_row') and IsQuali then Result := tkQualifier else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func255: TtkTokenKind;
begin
if KeyComp('Input_row_height') and IsQuali then Result := tkQualifier else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func313: TtkTokenKind;
begin
if KeyComp('End_signal_to_status') then Result := tkKey else
Result := tkIdentifier;
end;
function TSynDmlSyn.Func327: TtkTokenKind;
begin
if KeyComp('Begin_signal_to_status') then Result := tkKey else
Result := tkIdentifier;
end;
function TSynDmlSyn.AltFunc: TtkTokenKind;
begin
Result := tkIdentifier;
end;
function TSynDmlSyn.IdentKind(MayBe: PChar): TtkTokenKind;
var
HashKey: Integer;
begin
fToIdent := MayBe;
HashKey := KeyHash(MayBe);
if HashKey < 328 then Result := fIdentFuncTable[HashKey] else
Result := tkIdentifier;
end;
procedure TSynDmlSyn.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] := StringProc;
'0'..'9': fProcTable[I] := NumberProc;
'A'..'Z', 'a'..'z', '_':
fProcTable[I] := IdentProc;
'{': fProcTable[I] := SymbolProc;
'}': fProcTable[I] := SymbolProc;
'!': fProcTable[I] := RemProc;
'.': fProcTable[I] := PointProc;
'<': fProcTable[I] := LowerProc;
'>': fProcTable[I] := GreaterProc;
'@': fProcTable[I] := AddressOpProc;
#39, '&', '('..'-', '/', ':', ';', '=', '?', '['..'^', '`', '~':
fProcTable[I] := SymbolProc;
else
fProcTable[I] := UnknownProc;
end;
end;
constructor TSynDmlSyn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fFormAttri:= TSynHighlighterAttributes.Create(SYNS_AttrForm);
fFormAttri.Style:= [fsBold];
fFormAttri.Foreground:= clBlue;
AddAttribute(fFormAttri);
fBlockAttri:= TSynHighlighterAttributes.Create(SYNS_AttrBlock);
fBlockAttri.Style:= [fsBold];
fBlockAttri.Foreground:= clGreen;
AddAttribute(fBlockAttri);
fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrKey);
fKeyAttri.Style:= [fsBold];
AddAttribute(fKeyAttri);
fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment);
fCommentAttri.Style:= [fsBold];
fCommentAttri.Foreground:= clRed;
AddAttribute(fCommentAttri);
fQualiAttri:= TSynHighlighterAttributes.Create(SYNS_AttrQualifier);
fQualiAttri.Style:= [fsItalic];
fQualiAttri.Foreground:= clGreen;
AddAttribute(fQualiAttri);
fFunctionAttri:= TSynHighlighterAttributes.Create(SYNS_AttrFunction);
fFunctionAttri.Style:= [fsItalic];
fFunctionAttri.Foreground:= clBlack;
AddAttribute(fFunctionAttri);
fVariableAttri:= TSynHighlighterAttributes.Create(SYNS_AttrVariable);
fVariableAttri.Style:= [fsBold, fsItalic];
fVariableAttri.Foreground:= clBlack;
AddAttribute(fVariableAttri);
fSpecialAttri:= TSynHighlighterAttributes.Create(SYNS_AttrSpecialVariable);
fSpecialAttri.Style:= [fsItalic];
fSpecialAttri.Foreground:= clBlack;
AddAttribute(fSpecialAttri);
fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier);
AddAttribute(fIdentifierAttri);
fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber);
AddAttribute(fNumberAttri);
fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace);
AddAttribute(fSpaceAttri);
fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString);
AddAttribute(fStringAttri);
fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol);
AddAttribute(fSymbolAttri);
SetAttributesOnChange(DefHighlightChange);
InitIdent;
MakeMethodTables;
fRange := rsUnknown;
fDefaultFilter := SYNS_FilterGembase;
end;
procedure TSynDmlSyn.SetLine(NewValue: String; LineNumber:Integer);
begin
fLine := PChar(NewValue);
Run := 0;
fLineNumber := LineNumber;
Next;
end;
procedure TSynDmlSyn.AddressOpProc;
begin
fTokenID := tkSymbol;
Inc(Run);
if fLine[Run] = '@' then Inc(Run);
end;
procedure TSynDmlSyn.AsciiCharProc;
begin
// variables...
fTokenID := tkVariable;
repeat
inc(Run);
until not (FLine[Run] in ['_', '0'..'9', 'a'..'z', 'A'..'Z']);
end;
procedure TSynDmlSyn.SymbolProc;
begin
inc(Run);
fTokenId := tkSymbol;
end;
procedure TSynDmlSyn.CRProc;
begin
fTokenID := tkSpace;
inc(Run);
if FLine[Run] = #10 then inc(Run);
end;
procedure TSynDmlSyn.GreaterProc;
begin
fTokenID := tkSymbol;
Inc(Run);
if FLine[Run] = '=' then Inc(Run);
end;
procedure TSynDmlSyn.IdentProc;
begin
fTokenID := IdentKind((fLine + Run));
inc(Run, fStringLen);
while Identifiers[fLine[Run]] do inc(Run);
end;
procedure TSynDmlSyn.LFProc;
begin
fTokenID := tkSpace;
inc(Run);
end;
procedure TSynDmlSyn.LowerProc;
begin
fTokenID := tkSymbol;
inc(Run);
if (fLine[Run]= '=') or (fLine[Run]= '>') then Inc(Run);
end;
procedure TSynDmlSyn.NullProc;
begin
fTokenID := tkNull;
end;
procedure TSynDmlSyn.NumberProc;
begin
inc(Run);
fTokenID := tkNumber;
while FLine[Run] in ['0'..'9', '.'] do
begin
case FLine[Run] of
'.':
if FLine[Run + 1] = '.' then break;
end;
inc(Run);
end;
end;
procedure TSynDmlSyn.PointProc;
begin
fTokenID := tkSymbol;
inc(Run);
if (fLine[Run]='.') or (fLine[Run]=')') then inc(Run);
end;
procedure TSynDmlSyn.RemProc;
var
p: PChar;
begin
p := PChar(@fLine[Run - 1]);
while p >= fLine do begin
if not (p^ in [#9, #32]) then begin
inc(Run);
fTokenID := tkSymbol;
exit;
end;
Dec(p);
end;
// it is a comment...
fTokenID := tkComment;
p := PChar(@fLine[Run]);
repeat
Inc(p);
until p^ in [#0, #10, #13];
Run := p - fLine;
end;
procedure TSynDmlSyn.SpaceProc;
var p: PChar;
begin
fTokenID := tkSpace;
p := PChar(@fLine[Run]);
repeat
Inc(p);
until (p^ > #32) or (p^ in [#0, #10, #13]);
Run := p - fLine;
end;
procedure TSynDmlSyn.StringProc;
begin
fTokenID := tkString;
if (FLine[Run + 1] = '"') and (FLine[Run + 2] = '"') then inc(Run, 2);
repeat
inc(Run);
until (FLine[Run] in ['"', #0, #10, #13]);
if FLine[Run] <> #0 then inc(Run);
end;
procedure TSynDmlSyn.UnknownProc;
begin
{$IFDEF SYN_MBCSSUPPORT}
if FLine[Run] in LeadBytes then
Inc(Run, 2)
else
{$ENDIF}
inc(Run);
fTokenID := tkUnknown;
end;
procedure TSynDmlSyn.Next;
begin
fTokenPos := Run;
fProcTable[fLine[Run]];
end;
function TSynDmlSyn.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;
SYN_ATTR_SYMBOL: Result := fSymbolAttri;
else
Result := nil;
end;
end;
function TSynDmlSyn.GetEol: Boolean;
begin
Result := fTokenID = tkNull;
end;
function TSynDmlSyn.GetToken: string;
var
Len: LongInt;
begin
Len := Run - fTokenPos;
SetString(Result, (FLine + fTokenPos), Len);
end;
function TSynDmlSyn.GetTokenID: TtkTokenKind;
begin
Result:= fTokenId;
end;
function TSynDmlSyn.GetTokenAttribute: TSynHighlighterAttributes;
begin
case GetTokenID of
tkForm: Result := fFormAttri;
tkBlock: Result := fBlockAttri;
tkKey: Result := fKeyAttri;
tkComment: Result := fCommentAttri;
tkQualifier: Result := fQualiAttri;
tkFunction: Result := fFunctionAttri;
tkIdentifier: Result := fIdentifierAttri;
tkNumber: Result := fNumberAttri;
tkSpecial: Result := fSpecialAttri;
tkSpace: Result := fSpaceAttri;
tkString: Result := fStringAttri;
tkVariable: Result := fVariableAttri;
tkSymbol: Result := fSymbolAttri;
tkUnknown: Result := fSymbolAttri;
else Result := nil;
end;
end;
function TSynDmlSyn.GetTokenKind: integer;
begin
Result := Ord(GetTokenID);
end;
function TSynDmlSyn.GetTokenPos: Integer;
begin
Result := fTokenPos;
end;
function TSynDmlSyn.GetRange: Pointer;
begin
Result := Pointer(fRange);
end;
procedure TSynDmlSyn.SetRange(Value: Pointer);
begin
fRange := TRangeState(Value);
end;
procedure TSynDmlSyn.ResetRange;
begin
fRange:= rsUnknown;
end;
function TSynDmlSyn.IsFilterStored: Boolean;
begin
Result := fDefaultFilter <> SYNS_FilterGembase;
end;
class function TSynDmlSyn.GetLanguageName: string;
begin
Result := SYNS_LangGembase;
end;
function TSynDmlSyn.GetIdentChars: TSynIdentChars;
begin
Result := TSynValidStringChars;
end;
initialization
MakeIdentTable;
{$IFNDEF SYN_CPPB_1}
RegisterPlaceableHighlighter(TSynDmlSyn);
{$ENDIF}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -