SynHighlighterInno.pas
Upload User: xinxi0535
Upload Date: 2020-12-22
Package Size: 6056k
Code Size: 20k
Category:

Game Hook Crack

Development Platform:

Delphi

  1. {-------------------------------------------------------------------------------
  2. The contents of this file are subject to the Mozilla Public License
  3. Version 1.1 (the "License"); you may not use this file except in compliance
  4. with the License. You may obtain a copy of the License at
  5. http://www.mozilla.org/MPL/
  6. Software distributed under the License is distributed on an "AS IS" basis,
  7. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  8. the specific language governing rights and limitations under the License.
  9. The Original Code is: SynHighlighterInno.pas, released 2000-05-01.
  10. The Initial Author of this file is Satya.
  11. Portions created by Satya are Copyright 2000 Satya.
  12. All Rights Reserved.
  13. Contributors to the SynEdit project are listed in the Contributors.txt file.
  14. Alternatively, the contents of this file may be used under the terms of the
  15. GNU General Public License Version 2 or later (the "GPL"), in which case
  16. the provisions of the GPL are applicable instead of those above.
  17. If you wish to allow use of your version of this file only under the terms
  18. of the GPL and not to allow others to use your version of this file
  19. under the MPL, indicate your decision by deleting the provisions above and
  20. replace them with the notice and other provisions required by the GPL.
  21. If you do not delete the provisions above, a recipient may use your version
  22. of this file under either the MPL or the GPL.
  23. $Id: SynHighlighterInno.pas,v 1.23 2005/01/28 16:53:23 maelh Exp $
  24. You may retrieve the latest version of this file at the SynEdit home page,
  25. located at http://SynEdit.SourceForge.net
  26. Known Issues:
  27. -------------------------------------------------------------------------------}
  28. {
  29. @abstract(Provides an Inno script file highlighter for SynEdit)
  30. @author(Satya)
  31. @created(2000-05-01)
  32. @lastmod(2001-01-23)
  33. The SynHighlighterInno unit provides an Inno script file highlighter for SynEdit.
  34. Check out http://www.jrsoftware.org for the free Inno Setup program,
  35. and http://www.wintax.nl/isx/ for My Inno Setup Extensions.
  36. }
  37. {$IFNDEF QSYNHIGHLIGHTERINNO}
  38. unit SynHighlighterInno;
  39. {$ENDIF}
  40. {$I SynEdit.inc}
  41. interface
  42. uses
  43. {$IFDEF SYN_CLX}
  44.   QGraphics,
  45.   QSynEditTypes,
  46.   QSynEditHighlighter,
  47.   QSynHighlighterHashEntries,
  48. {$ELSE}
  49.   Graphics,
  50.   SynEditTypes,
  51.   SynEditHighlighter,
  52.   SynHighlighterHashEntries,
  53. {$ENDIF}
  54.   SysUtils,
  55.   Classes;
  56. type
  57.   TtkTokenKind = (tkComment, tkConstant, tkIdentifier, tkKey, tkKeyOrParameter,
  58.     tkNull, tkNumber, tkParameter, tkSection, tkSpace, tkString, tkSymbol,
  59.     tkUnknown);
  60.   TProcTableProc = procedure of object;
  61.   TSynInnoSyn = class(TSynCustomHighlighter)
  62.   private
  63.     fLine: PChar;
  64.     fLineNumber: integer;
  65.     fProcTable: array[#0..#255] of TProcTableProc;
  66.     Run: LongInt;
  67.     fStringLen: Integer;
  68.     fToIdent: PChar;
  69.     fTokenPos: Integer;
  70.     fTokenID: TtkTokenKind;
  71.     fConstantAttri: TSynHighlighterAttributes;
  72.     fCommentAttri: TSynHighlighterAttributes;
  73.     fSectionAttri: TSynHighlighterAttributes;
  74.     fParamAttri: TSynHighlighterAttributes;
  75.     fIdentifierAttri: TSynHighlighterAttributes;
  76.     fInvalidAttri: TSynHighlighterAttributes;
  77.     fKeyAttri: TSynHighlighterAttributes;
  78.     fNumberAttri: TSynHighlighterAttributes;
  79.     fSpaceAttri: TSynHighlighterAttributes;
  80.     fStringAttri: TSynHighlighterAttributes;
  81.     fSymbolAttri: TSynHighlighterAttributes;
  82.     fKeywords: TSynHashEntryList;
  83.     function KeyHash(ToHash: PChar): integer;
  84.     function KeyComp(const aKey: string): Boolean;
  85.     procedure SymbolProc;
  86.     procedure CRProc;
  87.     procedure IdentProc;
  88.     procedure LFProc;
  89.     procedure NullProc;
  90.     procedure NumberProc;
  91.     procedure SectionProc;
  92.     procedure SpaceProc;
  93.     procedure EqualProc;
  94.     procedure ConstantProc;
  95.     procedure SemiColonProc;
  96.     procedure StringProc;
  97.     procedure UnknownProc;
  98.     procedure DoAddKeyword(AKeyword: string; AKind: integer);
  99.     function IdentKind(MayBe: PChar): TtkTokenKind;
  100.     procedure MakeMethodTables;
  101.   protected
  102.     function GetIdentChars: TSynIdentChars; override;
  103.     function IsFilterStored: Boolean; override;
  104.   public
  105.     class function GetLanguageName: string; override;
  106.   public
  107.     constructor Create(AOwner: TComponent); override;
  108.     destructor Destroy; override;
  109.     function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
  110.       override;
  111.     function GetEol: Boolean; override;
  112.     function GetToken: string; override;
  113.     function GetTokenAttribute: TSynHighlighterAttributes; override;
  114.     function GetTokenID: TtkTokenKind;
  115.     function GetTokenKind: integer; override;
  116.     function GetTokenPos: Integer; override;
  117.     procedure Next; override;
  118.     procedure SetLine(NewValue: string; LineNumber:Integer); override;
  119.   published
  120.     property ConstantAttri: TSynHighlighterAttributes read fConstantAttri
  121.       write fConstantAttri;
  122.     property CommentAttri: TSynHighlighterAttributes read fCommentAttri
  123.       write fCommentAttri;
  124.     property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri
  125.       write fIdentifierAttri;
  126.     property InvalidAttri: TSynHighlighterAttributes read fInvalidAttri
  127.       write fInvalidAttri;
  128.     property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri;
  129.     property NumberAttri: TSynHighlighterAttributes read fNumberAttri
  130.       write fNumberAttri;
  131.     property ParameterAttri: TSynHighlighterAttributes read fParamAttri
  132.       write fParamAttri;
  133.     property SectionAttri: TSynHighlighterAttributes read fSectionAttri
  134.       write fSectionAttri;
  135.     property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri
  136.       write fSpaceAttri;
  137.     property StringAttri: TSynHighlighterAttributes read fStringAttri
  138.       write fStringAttri;
  139.     property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri
  140.       write fSymbolAttri;
  141.   end;
  142. implementation
  143. uses
  144. {$IFDEF SYN_CLX}
  145.   QSynEditStrConst;
  146. {$ELSE}
  147.   SynEditStrConst;
  148. {$ENDIF}
  149. var
  150.   Identifiers: array[#0..#255] of ByteBool;
  151.   mHashTable: array[#0..#255] of Integer;
  152. const
  153.   {Note: new 'Section names' and the new 'Constants' need not be added
  154.          as they are highlighted automatically}
  155.   {Ref:  Keywords and Parameters are updated as they last appeared in
  156.          Inno Setup / ISX version 1.3.26}
  157.   Keywords: string =
  158.     'AdminPrivilegesRequired,AllowNoIcons,AllowRootDirectory,AllowUNCPath,' +
  159.     'AlwaysCreateUninstallIcon,AlwaysRestart,AlwaysShowComponentsList,' +
  160.     'AlwaysShowDirOnReadyPage,AlwaysShowGroupOnReadyPage,' +
  161.     'AlwaysUsePersonalGroup,AppCopyright,AppId,AppMutex,AppName,AppPublisher,' +
  162.     'AppPublisherURL,AppSupportURL,AppUpdatesURL,AppVerName,AppVersion,' +
  163.     'Attribs,BackColor,BackColor2,BackColorDirection,BackSolid,Bits,' +
  164.     'ChangesAssociations,Check,CodeFile,Comment,Components,Compression,CompressLevel,CopyMode,'+
  165.     'CreateAppDir,CreateUninstallRegKey,DefaultDirName,DefaultGroupName,' +
  166.     'Description,DestDir,DestName,DirExistsWarning,DisableAppendDir,' +
  167.     'DisableDirExistsWarning,DisableDirPage,DisableFinishedPage,' +
  168.     'DisableProgramGroupPage,DisableReadyMemo,DisableReadyPage,' +
  169.     'DisableStartupPrompt,DiskClusterSize,DiskSize,DiskSpaceMBLabel,' +
  170.     'DiskSpanning,DontMergeDuplicateFiles,EnableDirDoesntExistWarning,' +
  171.     'ExtraDiskSpaceRequired,Filename,Flags,FlatComponentsList,FontInstall,' +
  172.     'GroupDescription,HotKey,IconFilename,IconIndex,InfoAfterFile,InfoBeforeFile,' +
  173.     'InstallMode,InternalCompressLevel,Key,LicenseFile,MessagesFile,MinVersion,Name,' +
  174.     'OnlyBelowVersion,OutputBaseFilename,OutputDir,OverwriteUninstRegEntries,' +
  175.     'Parameters,Password,ReserveBytes,Root,RunOnceId,Section,' +
  176.     'ShowComponentSizes,Source,SourceDir,StatusMsg,Subkey,Tasks,Type,Types,' +
  177.     'UninstallDisplayIcon,UninstallDisplayName,UninstallFilesDir,' +
  178.     'UninstallIconName,UninstallLogMode,UninstallStyle,Uninstallable,' +
  179.     'UpdateUninstallLogAppName,UsePreviousAppDir,UsePreviousGroup,' +
  180.     'UsePreviousTasks,UsePreviousSetupType,UseSetupLdr,ValueData,ValueName,' +
  181.     'ValueType,WindowResizable,WindowShowCaption,WindowStartMaximized,' +
  182.     'WindowVisible,WizardImageBackColor,WizardImageFile,WizardSmallImageFile,' +
  183.     'WizardStyle,WorkingDir';
  184.   Parameters: string =
  185.     'HKCC,HKCR,HKCU,HKLM,HKU,alwaysoverwrite,alwaysskipifsameorolder,append,' +
  186.     'binary,classic,closeonexit,comparetimestampalso,confirmoverwrite,' +
  187.     'createkeyifdoesntexist,createonlyiffileexists,createvalueifdoesntexist,' +
  188.     'deleteafterinstall,deletekey,deletevalue,dirifempty,dontcloseonexit,' +
  189.     'dontcreatekey,disablenouninstallwarning,dword,exclusive,expandsz,' +
  190.     'external,files,filesandordirs,fixed,fontisnttruetype,iscustom,isreadme,' +
  191.     'modern,multisz,new,noerror,none,normal,nowait,onlyifdestfileexists,' +
  192.     'onlyifdoesntexist,overwrite,overwritereadonly,postinstall,' +
  193.     'preservestringtype,regserver,regtypelib,restart,restartreplace,' +
  194.     'runmaximized,runminimized,sharedfile,shellexec,showcheckbox,' +
  195.     'skipifnotsilent,skipifsilent,silent,skipifdoesntexist,' +
  196.     'skipifsourcedoesntexist,unchecked,uninsalwaysuninstall,' +
  197.     'uninsclearvalue,uninsdeleteentry,uninsdeletekey,uninsdeletekeyifempty,' +
  198.     'uninsdeletesection,uninsdeletesectionifempty,uninsdeletevalue,' +
  199.     'uninsneveruninstall,useapppaths,verysilent,waituntilidle';
  200.   KeyOrParameter: string = 'string';
  201. procedure MakeIdentTable;
  202. var
  203.   c: char;
  204. begin
  205.   FillChar(Identifiers, SizeOf(Identifiers), 0);
  206.   for c := 'a' to 'z' do
  207.     Identifiers[c] := TRUE;
  208.   for c := 'A' to 'Z' do
  209.     Identifiers[c] := TRUE;
  210.   for c := '0' to '9' do
  211.     Identifiers[c] := TRUE;
  212.   Identifiers['_'] := TRUE;
  213.   FillChar(mHashTable, SizeOf(mHashTable), 0);
  214.   mHashTable['_'] := 1;
  215.   for c := 'a' to 'z' do
  216.     mHashTable[c] := 2 + Ord(c) - Ord('a');
  217.   for c := 'A' to 'Z' do
  218.     mHashTable[c] := 2 + Ord(c) - Ord('A');
  219. end;
  220. function TSynInnoSyn.KeyHash(ToHash: PChar): integer;
  221. begin
  222.   Result := 0;
  223.   while Identifiers[ToHash^] do begin
  224. {$IFOPT Q-}
  225.     Result := 7 * Result + mHashTable[ToHash^];
  226. {$ELSE}
  227.     Result := (7 * Result + mHashTable[ToHash^]) and $FFFFFF;
  228. {$ENDIF}
  229.     inc(ToHash);
  230.   end;
  231.   Result := Result and $1FF; // 511
  232.   fStringLen := ToHash - fToIdent;
  233. end;
  234. function TSynInnoSyn.KeyComp(const aKey: string): Boolean;
  235. var
  236.   i: integer;
  237.   pKey1, pKey2: PChar;
  238. begin
  239.   pKey1 := fToIdent;
  240.   // Note: fStringLen is always > 0 !
  241.   pKey2 := pointer(aKey);
  242.   for i := 1 to fStringLen do
  243.   begin
  244.     if mHashTable[pKey1^] <> mHashTable[pKey2^] then
  245.     begin
  246.       Result := FALSE;
  247.       exit;
  248.     end;
  249.     Inc(pKey1);
  250.     Inc(pKey2);
  251.   end;
  252.   Result := TRUE;
  253. end;
  254. function TSynInnoSyn.IdentKind(MayBe: PChar): TtkTokenKind;
  255. var
  256.   Entry: TSynHashEntry;
  257. begin
  258.   fToIdent := MayBe;
  259.   Entry := fKeywords[KeyHash(MayBe)];
  260.   while Assigned(Entry) do begin
  261.     if Entry.KeywordLen > fStringLen then
  262.       break
  263.     else if Entry.KeywordLen = fStringLen then
  264.       if KeyComp(Entry.Keyword) then begin
  265.         Result := TtkTokenKind(Entry.Kind);
  266.         exit;
  267.       end;
  268.     Entry := Entry.Next;
  269.   end;
  270.   Result := tkIdentifier;
  271. end;
  272. procedure TSynInnoSyn.MakeMethodTables;
  273. var
  274.   I: Char;
  275. begin
  276.   for I := #0 to #255 do
  277.     case I of
  278.       #13: fProcTable[I] := CRProc;
  279.       'A'..'Z', 'a'..'z', '_': fProcTable[I] := IdentProc;
  280.       #10: fProcTable[I] := LFProc;
  281.       #0: fProcTable[I] := NullProc;
  282.       '0'..'9': fProcTable[I] := NumberProc;
  283.       #1..#9, #11, #12, #14..#32: fProcTable[I] := SpaceProc;
  284.       #59 {';'}: fProcTable[I] := SemiColonProc;
  285.       #61 {=} : fProcTable[I] := EqualProc;
  286.       #34: fProcTable[I] := StringProc;
  287.       '#', ':', ',', '(', ')': fProcTable[I] := SymbolProc;
  288.       '{': fProcTable[I] := ConstantProc;
  289.       #91 {[} : fProcTable[i] := SectionProc;
  290.     else
  291.       fProcTable[I] := UnknownProc;
  292.     end;
  293. end;
  294. constructor TSynInnoSyn.Create(AOwner: TComponent);
  295. begin
  296.   inherited Create(AOwner);
  297.   fKeywords := TSynHashEntryList.Create;
  298.   fCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment);
  299.   fCommentAttri.Style := [fsItalic];
  300.   fCommentAttri.Foreground := clGray;
  301.   AddAttribute(fCommentAttri);
  302.   fIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier);
  303.   AddAttribute(fIdentifierAttri);
  304.   fInvalidAttri := TSynHighlighterAttributes.Create(SYNS_AttrIllegalChar);
  305.   AddAttribute(fInvalidAttri);
  306.   fKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord);
  307.   fKeyAttri.Style := [fsBold];
  308.   fKeyAttri.Foreground := clNavy;
  309.   AddAttribute(fKeyAttri);
  310.   fNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber);
  311.   fNumberAttri.Foreground := clMaroon;
  312.   AddAttribute(fNumberAttri);
  313.   fSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace);
  314.   AddAttribute(fSpaceAttri);
  315.   fStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString);
  316.   fStringAttri.Foreground := clBlue;
  317.   AddAttribute(fStringAttri);
  318.   fConstantAttri := TSynHighlighterAttributes.Create(SYNS_AttrDirective);
  319.   fConstantAttri.Style := [fsBold, fsItalic];
  320.   fConstantAttri.Foreground := clTeal;
  321.   AddAttribute(fConstantAttri);
  322.   fSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol);
  323.   AddAttribute(fSymbolAttri);
  324.   //Parameters
  325.   fParamAttri := TSynHighlighterAttributes.Create(SYNS_AttrPreprocessor);
  326.   fParamAttri.Style := [fsBold];
  327.   fParamAttri.Foreground := clOlive;
  328.   AddAttribute(fParamAttri);
  329.   fSectionAttri := TSynHighlighterAttributes.Create(SYNS_AttrSection);
  330.   fSectionAttri.Style := [fsBold];
  331.   fSectionAttri.Foreground := clRed;
  332.   AddAttribute(fSectionAttri);
  333.   SetAttributesOnChange(DefHighlightChange);
  334.   EnumerateKeywords(Ord(tkKey), Keywords, IdentChars, DoAddKeyword);
  335.   EnumerateKeywords(Ord(tkParameter), Parameters, IdentChars, DoAddKeyword);
  336.   EnumerateKeywords(Ord(tkKeyOrParameter), KeyOrParameter, IdentChars,
  337.     DoAddKeyword);
  338.   MakeMethodTables;
  339.   fDefaultFilter := SYNS_FilterInno;
  340. end;
  341. destructor TSynInnoSyn.Destroy;
  342. begin
  343.   fKeywords.Free;
  344.   inherited Destroy;
  345. end;
  346. procedure TSynInnoSyn.SetLine(NewValue: string; LineNumber: Integer);
  347. begin
  348.   fLine := PChar(NewValue);
  349.   Run := 0;
  350.   fLineNumber := LineNumber;
  351.   Next;
  352. end;
  353. procedure TSynInnoSyn.SymbolProc;
  354. begin
  355.   fTokenID := tkSymbol;
  356.   inc(Run);
  357. end;
  358. procedure TSynInnoSyn.CRProc;
  359. begin
  360.   fTokenID := tkSpace;
  361.   inc(Run);
  362.   if fLine[Run] = #10 then inc(Run);
  363. end;
  364. procedure TSynInnoSyn.EqualProc;
  365. begin
  366. // If any word has equal (=) symbol,
  367. // then the immediately followed text is treated as string
  368. // (though it does not have quotes)
  369.   fTokenID := tkString;
  370.   repeat
  371.     Inc(Run);
  372.     if fLine[Run] = ';' then begin
  373.       Inc(Run);
  374.       break;
  375.     end;
  376.   until fLine[Run] in [#0, #10, #13];
  377. end;
  378. procedure TSynInnoSyn.IdentProc;
  379. var
  380.   LookAhead: integer;
  381. begin
  382.   fTokenID := IdentKind((fLine + Run));
  383.   inc(Run, fStringLen);
  384.   if fTokenID = tkKeyOrParameter then begin
  385.     LookAhead := Run;
  386.     while fLine[LookAhead] in [#9, ' '] do
  387.       Inc(LookAhead);
  388.     if fLine[LookAhead] = ':' then
  389.       fTokenID := tkKey
  390.     else
  391.       fTokenID := tkParameter;
  392.   end;
  393. end;
  394. procedure TSynInnoSyn.SectionProc;
  395. begin
  396.   // if it is not column 0 mark as tkParameter and get out of here
  397.   if Run > 0 then
  398.   begin
  399.     fTokenID := tkUnknown;
  400.     inc(Run);
  401.     Exit;
  402.   end;
  403.   // this is column 0 ok it is a Section
  404.   fTokenID := tkSection;
  405.   repeat
  406.     Inc(Run);
  407.     if fLine[Run] = ']' then
  408.     begin
  409.       Inc(Run);
  410.       break;
  411.     end;
  412.   until fLine[Run] in [#0, #10, #13];
  413. end;
  414. procedure TSynInnoSyn.LFProc;
  415. begin
  416.   fTokenID := tkSpace;
  417.   inc(Run);
  418. end;
  419. procedure TSynInnoSyn.NullProc;
  420. begin
  421.   fTokenID := tkNull;
  422. end;
  423. procedure TSynInnoSyn.NumberProc;
  424. begin
  425.   fTokenID := tkNumber;
  426.   repeat
  427.     Inc(Run);
  428.   until not (fLine[Run] in ['0'..'9']);
  429. end;
  430. procedure TSynInnoSyn.ConstantProc;
  431. var
  432.   BraceLevel, LastOpenBrace: Integer;
  433. begin
  434.   { Much of this is based on code from the SkipPastConst function in IS's
  435.     CmnFunc2 unit. [jr] }
  436.   if fLine[Run + 1] = '{' then begin
  437.     { '{{' is not a constant }
  438.     fTokenID := tkUnknown;
  439.     Inc(Run, 2);
  440.     Exit;
  441.   end;
  442.   fTokenID := tkConstant;
  443.   BraceLevel := 1;
  444.   LastOpenBrace := Low(Integer);
  445.   repeat
  446.     Inc(Run);
  447.     case fLine[Run] of
  448.       '{': begin
  449.              if LastOpenBrace <> Run-1 then begin
  450.                Inc(BraceLevel);
  451.                LastOpenBrace := Run;
  452.              end
  453.              else
  454.                { Skip over '{{' when in an embedded constant }
  455.                Dec(BraceLevel);
  456.            end;
  457.       '}': begin
  458.              Dec (BraceLevel);
  459.              if BraceLevel = 0 then begin
  460.                Inc(Run);
  461.                Break;
  462.              end;
  463.            end;
  464. {$IFDEF SYN_MBCSSUPPORT}
  465.     else
  466.       if fLine[Run] in LeadBytes then
  467.         Inc(Run);
  468. {$ENDIF}
  469.     end;
  470.   until fLine[Run] in [#0, #10, #13];
  471. end;
  472. procedure TSynInnoSyn.SpaceProc;
  473. begin
  474.   fTokenID := tkSpace;
  475.   repeat
  476.     Inc(Run);
  477.   until (fLine[Run] > #32) or (fLine[Run] in [#0, #10, #13]);
  478. end;
  479. procedure TSynInnoSyn.SemiColonProc;
  480. var
  481.   I: Integer;
  482. begin
  483.   for I := Run-1 downto 0 do
  484.     if fLine[I] > ' ' then begin
  485.       // If the semicolon is not the first non-whitespace character on the
  486.       // line, then it isn't the start of a comment.
  487.       fTokenID := tkUnknown;
  488.       inc(Run);
  489.       Exit;
  490.     end;
  491.   fTokenID := tkComment;
  492.   repeat
  493.     Inc(Run);
  494.   until (fLine[Run] in [#0, #10, #13]);
  495. end;
  496. procedure TSynInnoSyn.StringProc;
  497. begin
  498.   fTokenID := tkString;
  499.   repeat
  500.     Inc(Run);
  501.     if fLine[Run] = '"' then begin
  502.       Inc(Run);
  503.       if fLine[Run] <> '"' then // embedded "" does not end the string
  504.         break;
  505.     end;
  506.   until fLine[Run] in [#0, #10, #13];
  507. end;
  508. procedure TSynInnoSyn.UnknownProc;
  509. begin
  510. {$IFDEF SYN_MBCSSUPPORT}
  511.   if FLine[Run] in LeadBytes then
  512.     Inc(Run, 2)
  513.   else
  514. {$ENDIF}
  515.   inc(Run);
  516.   fTokenID := tkUnknown;
  517. end;
  518. procedure TSynInnoSyn.Next;
  519. begin
  520.   fTokenPos := Run;
  521.   fProcTable[fLine[Run]];
  522. end;
  523. function TSynInnoSyn.GetDefaultAttribute(Index: integer):
  524.   TSynHighlighterAttributes;
  525. begin
  526.   case Index of
  527.     SYN_ATTR_COMMENT: Result := fCommentAttri;
  528.     SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri;
  529.     SYN_ATTR_KEYWORD: Result := fKeyAttri;
  530.     SYN_ATTR_STRING: Result := fStringAttri;
  531.     SYN_ATTR_WHITESPACE: Result := fSpaceAttri;
  532.     SYN_ATTR_SYMBOL: Result := fSymbolAttri;
  533.   else
  534.     Result := nil;
  535.   end;
  536. end;
  537. function TSynInnoSyn.GetEol: Boolean;
  538. begin
  539.   Result := (fTokenId = tkNull);
  540. end;
  541. function TSynInnoSyn.GetToken: String;
  542. var
  543.   Len: LongInt;
  544. begin
  545.   Len := Run - fTokenPos;
  546.   SetString(Result, (FLine + fTokenPos), Len);
  547. end;
  548. function TSynInnoSyn.GetTokenAttribute: TSynHighlighterAttributes;
  549. begin
  550.   case fTokenID of
  551.     tkComment: Result := fCommentAttri;
  552.     tkParameter: Result := fParamAttri;
  553.     tkSection: Result := fSectionAttri;
  554.     tkIdentifier: Result := fIdentifierAttri;
  555.     tkKey: Result := fKeyAttri;
  556.     tkNumber: Result := fNumberAttri;
  557.     tkSpace: Result := fSpaceAttri;
  558.     tkString: Result := fStringAttri;
  559.     tkConstant: Result := fConstantAttri;
  560.     tkSymbol: Result := fSymbolAttri;
  561.     tkUnknown: Result := fIdentifierAttri;
  562.   else
  563.     Result := nil;
  564.   end;
  565. end;
  566. function TSynInnoSyn.GetTokenKind: integer;
  567. begin
  568.   Result := Ord(fTokenId);
  569. end;
  570. function TSynInnoSyn.GetTokenID: TtkTokenKind;
  571. begin
  572.   Result := fTokenId;
  573. end;
  574. function TSynInnoSyn.GetTokenPos: Integer;
  575. begin
  576.   Result := fTokenPos;
  577. end;
  578. function TSynInnoSyn.GetIdentChars: TSynIdentChars;
  579. begin
  580.   Result := TSynValidStringChars;
  581. end;
  582. function TSynInnoSyn.IsFilterStored: Boolean;
  583. begin
  584.   Result := fDefaultFilter <> SYNS_FilterInno;
  585. end;
  586. class function TSynInnoSyn.GetLanguageName: string;
  587. begin
  588.   Result := SYNS_LangInno;
  589. end;
  590. procedure TSynInnoSyn.DoAddKeyword(AKeyword: string; AKind: integer);
  591. var
  592.   HashValue: integer;
  593. begin
  594.   HashValue := KeyHash(PChar(AKeyword));
  595.   fKeywords[HashValue] := TSynHashEntry.Create(AKeyword, AKind);
  596. end;
  597. initialization
  598.   MakeIdentTable;
  599. {$IFNDEF SYN_CPPB_1}
  600.   RegisterPlaceableHighlighter(TSynInnoSyn);
  601. {$ENDIF}
  602. end.