📄 synhighlighterphp.pas
字号:
if KeyComp('true') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func68: TtkTokenKind;
begin
if KeyComp('include') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func69: TtkTokenKind;
begin
if KeyComp('default') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func71: TtkTokenKind;
begin
if KeyComp('const') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func72: TtkTokenKind;
begin
if KeyComp('isset') then Result := tkKey else
if KeyComp('static') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func77: TtkTokenKind;
begin
if KeyComp('print') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func78: TtkTokenKind;
begin
if KeyComp('integer') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func79: TtkTokenKind;
begin
if KeyComp('empty') then Result := tkKey else
if KeyComp('unset') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func80: TtkTokenKind;
begin
if KeyComp('endwhile') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func82: TtkTokenKind;
begin
if KeyComp('switch') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func87: TtkTokenKind;
begin
if KeyComp('string') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func91: TtkTokenKind;
begin
if KeyComp('extends') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func93: TtkTokenKind;
begin
if KeyComp('require') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func96: TtkTokenKind;
begin
if KeyComp('return') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func101: TtkTokenKind;
begin
if KeyComp('continue') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func102: TtkTokenKind;
begin
if KeyComp('function') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func105: TtkTokenKind;
begin
if KeyComp('cfunction') then Result := tkKey else
if KeyComp('endswitch') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func151: TtkTokenKind;
begin
if KeyComp('highlight_file') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func156: TtkTokenKind;
begin
if KeyComp('__FILE__') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func164: TtkTokenKind;
begin
if KeyComp('old_function') then Result := tkKey else
if KeyComp('__LINE__') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func177: TtkTokenKind;
begin
if KeyComp('show_source') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.Func206: TtkTokenKind;
begin
if KeyComp('highlight_string') then Result := tkKey else Result := tkIdentifier;
end;
function TSynPHPSyn.AltFunc: TtkTokenKind;
begin
Result := tkIdentifier;
end;
function TSynPHPSyn.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 TSynPHPSyn.MakeMethodTables;
var
I: Char;
begin
for I := #0 to #255 do
case I of
'&': fProcTable[I] := AndSymbolProc;
#39: fProcTable[I] := String39Proc; // single quote
'@': 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;
'A'..'Z', 'a'..'z', '_': fProcTable[I] := IdentProc;
#10: fProcTable[I] := LFProc;
'<': fProcTable[I] := LowerProc;
'-': fProcTable[I] := MinusProc;
'*': fProcTable[I] := MultiplyProc;
'!': fProcTable[I] := NotSymbolProc;
#0: fProcTable[I] := NullProc;
'0'..'9': fProcTable[I] := NumberProc;
'|': fProcTable[I] := OrSymbolProc;
'+': fProcTable[I] := PlusProc;
'.': fProcTable[I] := PointProc;
'#': fProcTable[I] := PoundProc;
'?': fProcTable[I] := QuestionProc;
'%': fProcTable[I] := RemainderSymbolProc;
')': 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;
#34: fProcTable[I] := String34Proc; // double quote
'~': fProcTable[I] := TildeProc;
'$': fProcTable[I] := VariableProc;
'^': fProcTable[I] := XOrSymbolProc;
else fProcTable[I] := UnknownProc;
end;
end;
constructor TSynPHPSyn.Create(AOwner: TComponent);
begin
{begin} //mh 2000-01-14
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);
AddAttribute(fSpaceAttri);
fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString);
AddAttribute(fStringAttri);
fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol);
AddAttribute(fSymbolAttri);
fVariableAttri := TSynHighlighterAttributes.Create(SYNS_AttrVariable);
AddAttribute(fVariableAttri);
{end} //mh 2000-01-14
SetAttributesOnChange(DefHighlightChange);
InitIdent;
MakeMethodTables;
fDefaultFilter := SYNS_FilterPHP;
fRange := rsUnknown;
end;
procedure TSynPHPSyn.SetLine(NewValue: String; LineNumber: Integer);
begin
fLine := PChar(NewValue);
Run := 0;
fLineNumber := LineNumber;
Next;
end;
procedure TSynPHPSyn.AndSymbolProc;
begin
case FLine[Run + 1] of
'=': {and assign}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
'&': {conditional and}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
else {and}
begin
inc(Run);
fTokenID := tkSymbol;
end;
end;
end;
procedure TSynPHPSyn.AtSymbolProc;
begin
inc(Run);
fTokenId := tkSymbol;
end;
procedure TSynPHPSyn.BraceCloseProc;
begin
inc(Run);
fTokenId := tkSymbol;
end;
procedure TSynPHPSyn.BraceOpenProc;
begin
inc(Run);
fTokenId := tkSymbol;
end;
procedure TSynPHPSyn.CRProc;
begin
fTokenID := tkSpace;
Case FLine[Run + 1] of
#10: inc(Run, 2);
else inc(Run);
end;
end;
procedure TSynPHPSyn.ColonProc;
begin
inc(Run); {colon - conditional}
fTokenID := tkSymbol;
end;
procedure TSynPHPSyn.CommaProc;
begin
inc(Run);
fTokenID := tkSymbol;
end;
procedure TSynPHPSyn.EqualProc;
begin
case FLine[Run + 1] of
'=': {logical equal}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
'>': {Hash operator}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
else {assign}
begin
inc(Run);
fTokenID := tkSymbol;
end;
end;
end;
procedure TSynPHPSyn.GreaterProc;
begin
Case FLine[Run + 1] of
'=': {greater than or equal to}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
'>':
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
else {greater than}
begin
inc(Run);
fTokenID := tkSymbol;
end;
end;
end;
procedure TSynPHPSyn.IdentProc;
begin
fTokenID := IdentKind((fLine + Run));
inc(Run, fStringLen);
while Identifiers[fLine[Run]] do inc(Run);
end;
procedure TSynPHPSyn.LFProc;
begin
fTokenID := tkSpace;
inc(Run);
end;
procedure TSynPHPSyn.LowerProc;
begin
case FLine[Run + 1] of
'=': {less than or equal to}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
'<':
begin
if FLine[Run + 2] = '=' then {shift left assign}
begin
inc(Run, 3)
end
else {shift left}
begin
inc(Run, 2);
end;
fTokenID := tkSymbol;
end;
else {less than}
begin
inc(Run);
fTokenID := tkSymbol;
end;
end;
end;
procedure TSynPHPSyn.MinusProc;
begin
case FLine[Run + 1] of
'=': {subtract assign}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
'-': {decrement}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
'>': {Class operator}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
else {subtract}
begin
inc(Run);
fTokenID := tkSymbol;
end;
end;
end;
procedure TSynPHPSyn.MultiplyProc;
begin
case FLine[Run + 1] of
'=': {multiply assign}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
else {multiply}
begin
inc(Run);
fTokenID := tkSymbol;
end;
end;
end;
procedure TSynPHPSyn.NotSymbolProc;
begin
case FLine[Run + 1] of
'=': {not equal}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
else {logical complement}
begin
inc(Run);
fTokenID := tkSymbol;
end;
end;
end;
procedure TSynPHPSyn.NullProc;
begin
fTokenID := tkNull;
end;
procedure TSynPHPSyn.NumberProc;
begin
inc(Run);
fTokenID := tkNumber;
while FLine[Run] in
['0'..'9', '.', '-', 'l', 'L', 'x', 'X', 'A'..'F', 'a'..'f'] do
begin
case FLine[Run] of
'.':
if FLine[Run + 1] = '.' then break;
end;
inc(Run);
end;
end;
procedure TSynPHPSyn.OrSymbolProc;
begin
case FLine[Run + 1] of
'=': {inclusive or assign}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
'|': {conditional or}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
else {inclusive or}
begin
inc(Run);
fTokenID := tkSymbol;
end;
end;
end;
procedure TSynPHPSyn.PlusProc;
begin
case FLine[Run + 1] of
'=': {add assign}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
'+': {increment}
begin
inc(Run, 2);
fTokenID := tkSymbol;
end;
else {add}
begin
inc(Run);
fTokenID := tkSymbol;
end;
end;
end;
procedure TSynPHPSyn.PointProc;
begin
inc(Run); {point}
fTokenID := tkSymbol;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -