📄 synhighlighteravrc.pas
字号:
begin
if KeyComp('signed') then Result := tkKey else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func65: TtkTokenKind;
begin
if KeyComp('double') then Result := tkKey else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func68: TtkTokenKind;
begin
if KeyComp('true') then Result := tkKey else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func69: TtkTokenKind;
begin
if KeyComp('inline') or KeyComp('__inline__') then Result := tkKey
else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func76: TtkTokenKind;
begin
if KeyComp('const') then Result := tkKey else
if KeyComp('default') then Result := tkKey else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func78: TtkTokenKind;
begin
if KeyComp('union') or KeyComp('static') then Result := tkKey
else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func85: TtkTokenKind;
begin
if KeyComp('short') then Result := tkKey
else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func86: TtkTokenKind;
begin
if KeyComp('sizeof') then Result := tkKey
else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func88: TtkTokenKind;
begin
if KeyComp('switch') then Result := tkKey else
if KeyComp('typedef') then Result := tkKey else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func92: TtkTokenKind;
begin
if KeyComp('extern') then Result := tkKey else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func101: TtkTokenKind;
begin
if KeyComp('unsigned') then Result := tkKey else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func102: TtkTokenKind;
begin
if KeyComp('return') then Result := tkKey else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func104: TtkTokenKind;
begin
if KeyComp('volatile') or KeyComp('__volatile__') then Result := tkKey
else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func107: TtkTokenKind;
begin
if KeyComp('struct') then Result := tkKey
else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func109: TtkTokenKind;
begin
if KeyComp('register') then Result := tkKey else
if KeyComp('continue') then Result := tkKey else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func125: TtkTokenKind;
begin
if KeyComp('__attribute__') then Result := tkKey
else Result := tkIdentifier;
end;
function TSynAVRCSyn.Func134: TtkTokenKind;
begin
if KeyComp('__extension__') then Result := tkKey
else Result := tkIdentifier;
end;
function TSynAVRCSyn.AltFunc: TtkTokenKind;
begin
Result := tkIdentifier;
end;
function TSynAVRCSyn.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 TSynAVRCSyn.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] := 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] := TildeProc;
'^': fProcTable[I] := XOrSymbolProc;
else fProcTable[I] := UnknownProc;
end;
end;
constructor TSynAVRCSyn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fAsmAttri := TSynHighlighterAttributes.Create(SYNS_AttrAssembler);
AddAttribute(fAsmAttri);
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);
fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber);
AddAttribute(fNumberAttri);
fCharAttri := TSynHighlighterAttributes.Create(SYNS_AttrCharacter);
AddAttribute(fCharAttri);
fFloatAttri := TSynHighlighterAttributes.Create(SYNS_AttrFloat);
AddAttribute(fFloatAttri);
fHexAttri := TSynHighlighterAttributes.Create(SYNS_AttrHexadecimal);
AddAttribute(fHexAttri);
fOctalAttri := TSynHighlighterAttributes.Create(SYNS_AttrOctal);
AddAttribute(fOctalAttri);
fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace);
fSpaceAttri.Foreground := clWindow;
AddAttribute(fSpaceAttri);
fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString);
AddAttribute(fStringAttri);
fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol);
AddAttribute(fSymbolAttri);
fDirecAttri := TSynHighlighterAttributes.Create(SYNS_AttrPreprocessor);
AddAttribute(fDirecAttri);
SetAttributesOnChange(DefHighlightChange);
InitIdent;
MakeMethodTables;
fRange := rsUnknown;
fAsmStart := False;
fDefaultFilter := SYNS_FilterCPP;
end; { Create }
procedure TSynAVRCSyn.SetLine(NewValue: String; LineNumber:Integer);
begin
fLine := PChar(NewValue);
Run := 0;
fLineNumber := LineNumber;
Next;
end; { SetLine }
procedure TSynAVRCSyn.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) and
not (fLine[Run] in [#0, #13, #10]) then
fRange := rsMultiLineDirective //dj
else
fRange := rsUnKnown;
break;
end else
inc(Run);
#10: break;
#13: break;
else inc(Run);
end;
end;
procedure TSynAVRCSyn.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 TSynAVRCSyn.AsciiCharProc;
begin
fTokenID := tkChar;
repeat
if fLine[Run] = '\' then begin
if fLine[Run + 1] in [#39, '\'] then //ek 2000-04-26
inc(Run);
end;
inc(Run);
until fLine[Run] in [#0, #10, #13, #39];
if fLine[Run] = #39 then
inc(Run);
end;
procedure TSynAVRCSyn.AtSymbolProc;
begin
fTokenID := tkUnknown;
inc(Run);
end;
procedure TSynAVRCSyn.BraceCloseProc;
begin
inc(Run);
fTokenId := tkSymbol;
FExtTokenID := xtkBraceClose;
end;
procedure TSynAVRCSyn.BraceOpenProc;
begin
inc(Run);
fTokenId := tkSymbol;
FExtTokenID := xtkBraceOpen;
end;
procedure TSynAVRCSyn.CRProc;
begin
fTokenID := tkSpace;
Inc(Run);
if fLine[Run + 1] = #10 then Inc(Run);
end;
procedure TSynAVRCSyn.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 TSynAVRCSyn.CommaProc;
begin
inc(Run);
fTokenID := tkSymbol;
FExtTokenID := xtkComma;
end;
procedure TSynAVRCSyn.DirectiveProc; // dj, rewritten to support multiline directives properly
begin
if Trim(fLine)[1] <> '#' then // '#' is not first char on the line, treat it as an invalid char
begin
fTokenID := tkUnknown;
Inc(Run);
Exit;
end;
fTokenID := tkDirective;
repeat
if fLine[Run] = '/' then // comment?
begin
if fLine[Run + 1] = '/' then // is end of directive as well
begin
fRange := rsUnknown; //ek 2000-04-25
Exit;
end
else
if fLine[Run + 1] = '*' then // might be embedded only
begin
fRange := rsDirectiveComment;
Exit;
end;
end;
if (fLine[Run] = '\') and (fLine[Run +1 ] = #0) then // a multiline directive
begin
Inc(Run);
fRange := rsMultiLineDirective;
Exit;
end;
Inc(Run);
until fLine[Run] in [#0, #10, #13];
end;
procedure TSynAVRCSyn.DirectiveEndProc; // dj, added to support multiline directives properly
begin
fTokenID := tkDirective;
case FLine[Run] of
#0:
begin
NullProc;
Exit;
end;
#10:
begin
LFProc;
Exit;
end;
#13:
begin
CRProc;
Exit;
end;
end;
fRange := rsUnknown;
repeat
case FLine[Run] of
#0, #10, #13: Break;
'/': // comment?
begin
case fLine[Run + 1] of
'/': // is end of directive as well
begin
fRange := rsUnknown; //ek 2000-04-25
Exit;
end;
'*': // might be embedded only
begin
fRange := rsDirectiveComment;
Exit;
end;
end;
end;
'\': // yet another line?
begin
if fLine[Run + 1] = #0 then
begin
Inc(Run);
fRange := rsMultiLineDirective;
Exit;
end;
end;
end;
Inc(Run);
until fLine[Run] in [#0, #10, #13];
end;
procedure TSynAVRCSyn.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 TSynAVRCSyn.GreaterProc;
begin
fTokenID := tkSymbol;
Case FLine[Run + 1] of
'=': {greater than or equal to}
begin
inc(Run, 2);
FExtTokenID := xtkGreaterThanEqual;
end;
'>':
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -