1 //Converted by Nyitrai Péter
2 {-------------------------------------------------------------------------------
3 The contents of this file are subject to the Mozilla Public License
4 Version 1.1 (the "License"); you may not use this file except in compliance
5 with the License. You may obtain a copy of the License at
6 http://www.mozilla.org/MPL/
7 
8 Software distributed under the License is distributed on an "AS IS" basis,
9 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
10 the specific language governing rights and limitations under the License.
11 
12 The Original Code is: SynHighlighterVB.pas, released 2000-04-20.
13 The Original Code is based on the wbADSP21xxSyn.pas file from the
14 mwEdit component suite by Martin Waldenburg and other developers, the Initial
15 Author of this file is Max Horvßth.
16 All Rights Reserved.
17 
18 Contributors to the SynEdit and mwEdit projects are listed in the
19 Contributors.txt file.
20 
21 Alternatively, the contents of this file may be used under the terms of the
22 GNU General Public License Version 2 or later (the "GPL"), in which case
23 the provisions of the GPL are applicable instead of those above.
24 If you wish to allow use of your version of this file only under the terms
25 of the GPL and not to allow others to use your version of this file
26 under the MPL, indicate your decision by deleting the provisions above and
27 replace them with the notice and other provisions required by the GPL.
28 If you do not delete the provisions above, a recipient may use your version
29 of this file under either the MPL or the GPL.
30 
31 $Id: SynHighlighterVB.pas,v 1.15 2005/01/28 16:53:25 maelh Exp $
32 
33 You may retrieve the latest version of this file at the SynEdit home page,
34 located at http://SynEdit.SourceForge.net
35 
36 Known Issues:
37 -------------------------------------------------------------------------------}
38 {
39 @abstract(Provides a Visual Basic highlighter for SynEdit)
40 @author(Max Horvßth <TheProfessor@gmx.de>, converted to SynEdit by David Muir <david@loanhead45.freeserve.co.uk>)
41 @created(5 December 1999, converted to SynEdit April 21, 2000)
42 @lastmod(2000-06-23)
43 The SynHighlighterVB unit provides SynEdit with a Visual Basic (.bas) highlighter.
44 }
45 unit SynHighlighterVB;
46 
47 {$I SynEdit.inc}
48 
49 interface
50 
51 uses
52   SysUtils, Classes,
53   LCLIntf, LCLType,
54   Controls, Graphics,
55   SynEditTypes, SynEditHighlighter;
56 
57 type
58   TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, tkSpace,
59     tkString, tkSymbol, tkUnknown);
60 
61   TProcTableProc = procedure of object;
62 
63   PIdentFuncTableFunc = ^TIdentFuncTableFunc;
TtkTokenKindnull64   TIdentFuncTableFunc = function: TtkTokenKind of object;
65 
66 type
67   TSynVBSyn = class(TSynCustomHighlighter)
68   private
69     fLine: PChar;
70     fLineNumber: Integer;
71     fProcTable: array[#0..#255] of TProcTableProc;
72     Run: LongInt;
73     fStringLen: Integer;
74     fToIdent: PChar;
75     fTokenPos: Integer;
76     FTokenID: TtkTokenKind;
77     fIdentFuncTable: array[0..133] of TIdentFuncTableFunc;
78     fCommentAttri: TSynHighlighterAttributes;
79     fIdentifierAttri: TSynHighlighterAttributes;
80     fKeyAttri: TSynHighlighterAttributes;
81     fNumberAttri: TSynHighlighterAttributes;
82     fSpaceAttri: TSynHighlighterAttributes;
83     fStringAttri: TSynHighlighterAttributes;
84     fSymbolAttri: TSynHighlighterAttributes;
KeyHashnull85     function KeyHash(ToHash: PChar): Integer;
KeyCompnull86     function KeyComp(const aKey: String): Boolean;
Func10null87     function Func10: TtkTokenKind;
Func15null88     function Func15: TtkTokenKind;
Func17null89     function Func17: TtkTokenKind;
Func18null90     function Func18: TtkTokenKind;
Func19null91     function Func19: TtkTokenKind;
Func20null92     function Func20: TtkTokenKind;
Func21null93     function Func21: TtkTokenKind;
Func22null94     function Func22: TtkTokenKind;
Func23null95     function Func23: TtkTokenKind;
Func24null96     function Func24: TtkTokenKind;
Func26null97     function Func26: TtkTokenKind;
Func27null98     function Func27: TtkTokenKind;
Func28null99     function Func28: TtkTokenKind;
Func29null100     function Func29: TtkTokenKind;
Func30null101     function Func30: TtkTokenKind;
Func31null102     function Func31: TtkTokenKind;
Func32null103     function Func32: TtkTokenKind;
Func33null104     function Func33: TtkTokenKind;
Func34null105     function Func34: TtkTokenKind;
Func35null106     function Func35: TtkTokenKind;
Func36null107     function Func36: TtkTokenKind;
Func37null108     function Func37: TtkTokenKind;
Func38null109     function Func38: TtkTokenKind;
Func39null110     function Func39: TtkTokenKind;
Func40null111     function Func40: TtkTokenKind;
Func41null112     function Func41: TtkTokenKind;
Func42null113     function Func42: TtkTokenKind;
Func43null114     function Func43: TtkTokenKind;
Func44null115     function Func44: TtkTokenKind;
Func45null116     function Func45: TtkTokenKind;
Func46null117     function Func46: TtkTokenKind;
Func47null118     function Func47: TtkTokenKind;
Func48null119     function Func48: TtkTokenKind;
Func49null120     function Func49: TtkTokenKind;
Func50null121     function Func50: TtkTokenKind;
Func52null122     function Func52: TtkTokenKind;
Func53null123     function Func53: TtkTokenKind;
Func54null124     function Func54: TtkTokenKind;
Func55null125     function Func55: TtkTokenKind;
Func56null126     function Func56: TtkTokenKind;
Func57null127     function Func57: TtkTokenKind;
Func58null128     function Func58: TtkTokenKind;
Func59null129     function Func59: TtkTokenKind;
Func60null130     function Func60: TtkTokenKind;
Func62null131     function Func62: TtkTokenKind;
Func63null132     function Func63: TtkTokenKind;
Func64null133     function Func64: TtkTokenKind;
Func65null134     function Func65: TtkTokenKind;
Func66null135     function Func66: TtkTokenKind;
Func67null136     function Func67: TtkTokenKind;
Func68null137     function Func68: TtkTokenKind;
Func69null138     function Func69: TtkTokenKind;
Func70null139     function Func70: TtkTokenKind;
Func71null140     function Func71: TtkTokenKind;
Func72null141     function Func72: TtkTokenKind;
Func73null142     function Func73: TtkTokenKind;
Func74null143     function Func74: TtkTokenKind;
Func75null144     function Func75: TtkTokenKind;
Func76null145     function Func76: TtkTokenKind;
Func77null146     function Func77: TtkTokenKind;
Func78null147     function Func78: TtkTokenKind;
Func79null148     function Func79: TtkTokenKind;
Func80null149     function Func80: TtkTokenKind;
Func81null150     function Func81: TtkTokenKind;
Func82null151     function Func82: TtkTokenKind;
Func83null152     function Func83: TtkTokenKind;
Func85null153     function Func85: TtkTokenKind;
Func87null154     function Func87: TtkTokenKind;
Func89null155     function Func89: TtkTokenKind;
Func91null156     function Func91: TtkTokenKind;
Func94null157     function Func94: TtkTokenKind;
Func96null158     function Func96: TtkTokenKind;
Func97null159     function Func97: TtkTokenKind;
Func98null160     function Func98: TtkTokenKind;
Func99null161     function Func99: TtkTokenKind;
Func101null162     function Func101: TtkTokenKind;
Func102null163     function Func102: TtkTokenKind;
Func103null164     function Func103: TtkTokenKind;
Func104null165     function Func104: TtkTokenKind;
Func105null166     function Func105: TtkTokenKind;
Func107null167     function Func107: TtkTokenKind;
Func108null168     function Func108: TtkTokenKind;
Func109null169     function Func109: TtkTokenKind;
Func111null170     function Func111: TtkTokenKind;
Func114null171     function Func114: TtkTokenKind;
Func116null172     function Func116: TtkTokenKind;
Func118null173     function Func118: TtkTokenKind;
Func133null174     function Func133: TtkTokenKind;
175     procedure SymbolProc;
176     procedure ApostropheProc;
177     procedure CRProc;
178     procedure DateProc;
179     procedure GreaterProc;
180     procedure IdentProc;
181     procedure LFProc;
182     procedure LowerProc;
183     procedure NullProc;
184     procedure NumberProc;
185     procedure SpaceProc;
186     procedure StringProc;
187     procedure UnknownProc;
AltFuncnull188     function AltFunc: TtkTokenKind;
189     procedure InitIdent;
IdentKindnull190     function IdentKind(MayBe: PChar): TtkTokenKind;
191     procedure MakeMethodTables;
192   protected
GetIdentCharsnull193     function GetIdentChars: TSynIdentChars; override;
GetSampleSourcenull194     function GetSampleSource: String; override;
IsFilterStorednull195     function IsFilterStored: Boolean; override;
196   public
GetLanguageNamenull197     class function GetLanguageName: string; override;
198   public
199     constructor Create(AOwner: TComponent); override;
GetDefaultAttributenull200     function GetDefaultAttribute(Index: integer): TSynHighlighterAttributes;
201       override;
GetEolnull202     function GetEol: Boolean; override;
GetTokenIDnull203     function GetTokenID: TtkTokenKind;
204     procedure SetLine(const NewValue: String; LineNumber: Integer); override;
GetTokennull205     function GetToken: String; override;
206     procedure GetTokenEx(out TokenStart: PChar; out TokenLength: integer); override;
GetTokenAttributenull207     function GetTokenAttribute: TSynHighlighterAttributes; override;
GetTokenKindnull208     function GetTokenKind: integer; override;
GetTokenPosnull209     function GetTokenPos: Integer; override;
210     procedure Next; override;
211   published
212     property CommentAttri: TSynHighlighterAttributes read fCommentAttri
213       write fCommentAttri;
214     property IdentifierAttri: TSynHighlighterAttributes read fIdentifierAttri
215       write fIdentifierAttri;
216     property KeyAttri: TSynHighlighterAttributes read fKeyAttri write fKeyAttri;
217     property NumberAttri: TSynHighlighterAttributes read fNumberAttri
218       write fNumberAttri;
219     property SpaceAttri: TSynHighlighterAttributes read fSpaceAttri
220       write fSpaceAttri;
221     property StringAttri: TSynHighlighterAttributes read fStringAttri
222       write fStringAttri;
223     property SymbolAttri: TSynHighlighterAttributes read fSymbolAttri
224       write fSymbolAttri;
225   end;
226 
227 implementation
228 
229 uses
230   SynEditStrConst;
231 
232 var
233   Identifiers: array[#0..#255] of ByteBool;
234   mHashTable: array[#0..#255] of Integer;
235 
236 procedure MakeIdentTable;
237 var
238   I, J: Char;
239 begin
240   for I := #0 to #255 do
241   begin
242     Case I of
243       '_', '0'..'9', 'a'..'z', 'A'..'Z': Identifiers[I] := True;
244     else Identifiers[I] := False;
245     end;
246     J := UpCase(I);
247     Case I in ['_', 'A'..'Z', 'a'..'z'] of
248       True: mHashTable[I] := Ord(J) - 64
249     else mHashTable[I] := 0;
250     end;
251   end;
252 end;
253 
254 procedure TSynVBSyn.InitIdent;
255 var
256   I: Integer;
257   pF: PIdentFuncTableFunc;
258 begin
259   pF := PIdentFuncTableFunc(@fIdentFuncTable);
260   for I := Low(fIdentFuncTable) to High(fIdentFuncTable) do begin
261     pF^ := @AltFunc;
262     Inc(pF);
263   end;
264   fIdentFuncTable[10] := @Func10;
265   fIdentFuncTable[15] := @Func15;
266   fIdentFuncTable[17] := @Func17;
267   fIdentFuncTable[18] := @Func18;
268   fIdentFuncTable[19] := @Func19;
269   fIdentFuncTable[20] := @Func20;
270   fIdentFuncTable[21] := @Func21;
271   fIdentFuncTable[22] := @Func22;
272   fIdentFuncTable[23] := @Func23;
273   fIdentFuncTable[24] := @Func24;
274   fIdentFuncTable[26] := @Func26;
275   fIdentFuncTable[27] := @Func27;
276   fIdentFuncTable[28] := @Func28;
277   fIdentFuncTable[29] := @Func29;
278   fIdentFuncTable[30] := @Func30;
279   fIdentFuncTable[31] := @Func31;
280   fIdentFuncTable[32] := @Func32;
281   fIdentFuncTable[33] := @Func33;
282   fIdentFuncTable[34] := @Func34;
283   fIdentFuncTable[35] := @Func35;
284   fIdentFuncTable[36] := @Func36;
285   fIdentFuncTable[37] := @Func37;
286   fIdentFuncTable[38] := @Func38;
287   fIdentFuncTable[39] := @Func39;
288   fIdentFuncTable[40] := @Func40;
289   fIdentFuncTable[41] := @Func41;
290   fIdentFuncTable[42] := @Func42;
291   fIdentFuncTable[43] := @Func43;
292   fIdentFuncTable[44] := @Func44;
293   fIdentFuncTable[45] := @Func45;
294   fIdentFuncTable[46] := @Func46;
295   fIdentFuncTable[47] := @Func47;
296   fIdentFuncTable[48] := @Func48;
297   fIdentFuncTable[49] := @Func49;
298   fIdentFuncTable[50] := @Func50;
299   fIdentFuncTable[52] := @Func52;
300   fIdentFuncTable[53] := @Func53;
301   fIdentFuncTable[54] := @Func54;
302   fIdentFuncTable[55] := @Func55;
303   fIdentFuncTable[56] := @Func56;
304   fIdentFuncTable[57] := @Func57;
305   fIdentFuncTable[58] := @Func58;
306   fIdentFuncTable[59] := @Func59;
307   fIdentFuncTable[60] := @Func60;
308   fIdentFuncTable[62] := @Func62;
309   fIdentFuncTable[63] := @Func63;
310   fIdentFuncTable[64] := @Func64;
311   fIdentFuncTable[65] := @Func65;
312   fIdentFuncTable[66] := @Func66;
313   fIdentFuncTable[67] := @Func67;
314   fIdentFuncTable[68] := @Func68;
315   fIdentFuncTable[69] := @Func69;
316   fIdentFuncTable[70] := @Func70;
317   fIdentFuncTable[71] := @Func71;
318   fIdentFuncTable[72] := @Func72;
319   fIdentFuncTable[73] := @Func73;
320   fIdentFuncTable[74] := @Func74;
321   fIdentFuncTable[75] := @Func75;
322   fIdentFuncTable[76] := @Func76;
323   fIdentFuncTable[77] := @Func77;
324   fIdentFuncTable[78] := @Func78;
325   fIdentFuncTable[79] := @Func79;
326   fIdentFuncTable[80] := @Func80;
327   fIdentFuncTable[81] := @Func81;
328   fIdentFuncTable[82] := @Func82;
329   fIdentFuncTable[83] := @Func83;
330   fIdentFuncTable[85] := @Func85;
331   fIdentFuncTable[87] := @Func87;
332   fIdentFuncTable[89] := @Func89;
333   fIdentFuncTable[91] := @Func91;
334   fIdentFuncTable[94] := @Func94;
335   fIdentFuncTable[96] := @Func96;
336   fIdentFuncTable[97] := @Func97;
337   fIdentFuncTable[98] := @Func98;
338   fIdentFuncTable[99] := @Func99;
339   fIdentFuncTable[101] := @Func101;
340   fIdentFuncTable[102] := @Func102;
341   fIdentFuncTable[103] := @Func103;
342   fIdentFuncTable[104] := @Func104;
343   fIdentFuncTable[105] := @Func105;
344   fIdentFuncTable[107] := @Func107;
345   fIdentFuncTable[108] := @Func108;
346   fIdentFuncTable[109] := @Func109;
347   fIdentFuncTable[111] := @Func111;
348   fIdentFuncTable[114] := @Func114;
349   fIdentFuncTable[116] := @Func116;
350   fIdentFuncTable[118] := @Func118;
351   fIdentFuncTable[133] := @Func133;
352 end;
353 
KeyHashnull354 function TSynVBSyn.KeyHash(ToHash: PChar): Integer;
355 begin
356   Result := 0;
357   while ToHash^ in ['_', '0'..'9', 'a'..'z', 'A'..'Z'] do
358   begin
359     inc(Result, mHashTable[ToHash^]);
360     inc(ToHash);
361   end;
362   fStringLen := ToHash - fToIdent;
363 end;
364 
TSynVBSyn.KeyCompnull365 function TSynVBSyn.KeyComp(const aKey: String): Boolean;
366 var
367   I: Integer;
368   Temp: PChar;
369 begin
370   Temp := fToIdent;
371   if Length(aKey) = fStringLen then
372   begin
373     Result := True;
374     for i := 1 to fStringLen do
375     begin
376       if mHashTable[Temp^] <> mHashTable[aKey[i]] then
377       begin
378         Result := False;
379         break;
380       end;
381       inc(Temp);
382     end;
383   end else Result := False;
384 end;
385 
Func10null386 function TSynVBSyn.Func10: TtkTokenKind;
387 begin
388   if KeyComp('ddb') then Result := tkKey else Result := tkIdentifier;
389 end;
390 
TSynVBSyn.Func15null391 function TSynVBSyn.Func15: TtkTokenKind;
392 begin
393   if KeyComp('if') then Result := tkKey else Result := tkIdentifier;
394 end;
395 
TSynVBSyn.Func17null396 function TSynVBSyn.Func17: TtkTokenKind;
397 begin
398   if KeyComp('each') then Result := tkKey else Result := tkIdentifier;
399 end;
400 
TSynVBSyn.Func18null401 function TSynVBSyn.Func18: TtkTokenKind;
402 begin
403   if KeyComp('me') then Result := tkKey else Result := tkIdentifier;
404 end;
405 
TSynVBSyn.Func19null406 function TSynVBSyn.Func19: TtkTokenKind;
407 begin
408   if KeyComp('and') then Result := tkKey else
409     if KeyComp('do') then Result := tkKey else Result := tkIdentifier;
410 end;
411 
Func20null412 function TSynVBSyn.Func20: TtkTokenKind;
413 begin
414   if KeyComp('as') then Result := tkKey else Result := tkIdentifier;
415 end;
416 
Func21null417 function TSynVBSyn.Func21: TtkTokenKind;
418 begin
419   if KeyComp('cdbl') then Result := tkKey else Result := tkIdentifier;
420 end;
421 
Func22null422 function TSynVBSyn.Func22: TtkTokenKind;
423 begin
424   if KeyComp('abs') then Result := tkKey else Result := tkIdentifier;
425 end;
426 
Func23null427 function TSynVBSyn.Func23: TtkTokenKind;
428 begin
429   if KeyComp('end') then Result := tkKey else
430     if KeyComp('end with') then Result := tkKey else
431       if KeyComp('asc') then Result := tkKey else
432         if KeyComp('tab') then Result := tkKey else Result := tkIdentifier;
433 end;
434 
Func24null435 function TSynVBSyn.Func24: TtkTokenKind;
436 begin
437   if KeyComp('iif') then Result := tkKey else Result := tkIdentifier;
438 end;
439 
TSynVBSyn.Func26null440 function TSynVBSyn.Func26: TtkTokenKind;
441 begin
442   if KeyComp('mid') then Result := tkKey else
443     if KeyComp('eof') then Result := tkKey else
444       if KeyComp('dim') then Result := tkKey else Result := tkIdentifier;
445 end;
446 
TSynVBSyn.Func27null447 function TSynVBSyn.Func27: TtkTokenKind;
448 begin
449   if KeyComp('rgb') then Result := tkKey else
450     if KeyComp('base') then Result := tkKey else Result := tkIdentifier;
451 end;
452 
TSynVBSyn.Func28null453 function TSynVBSyn.Func28: TtkTokenKind;
454 begin
455   if KeyComp('fv') then Result := tkKey else
456     if KeyComp('beep') then Result := tkKey else
457       if KeyComp('call') then Result := tkKey else
458         if KeyComp('case') then Result := tkKey else
459           if KeyComp('is') then Result := tkKey else Result := tkIdentifier;
460 end;
461 
TSynVBSyn.Func29null462 function TSynVBSyn.Func29: TtkTokenKind;
463 begin
464   if KeyComp('on') then Result := tkKey else
465     if KeyComp('chr') then Result := tkKey else Result := tkIdentifier;
466 end;
467 
TSynVBSyn.Func30null468 function TSynVBSyn.Func30: TtkTokenKind;
469 begin
470   if KeyComp('loc') then Result := tkKey else
471     if KeyComp('date') then Result := tkKey else Result := tkIdentifier;
472 end;
473 
Func31null474 function TSynVBSyn.Func31: TtkTokenKind;
475 begin
476   if KeyComp('dir') then Result := tkKey else
477     if KeyComp('len') then Result := tkKey else Result := tkIdentifier;
478 end;
479 
Func32null480 function TSynVBSyn.Func32: TtkTokenKind;
481 begin
482   if KeyComp('mod') then Result := tkKey else
483     if KeyComp('get') then Result := tkKey else Result := tkIdentifier;
484 end;
485 
Func33null486 function TSynVBSyn.Func33: TtkTokenKind;
487 begin
488   if KeyComp('name') then Result := tkKey else
489     if KeyComp('lof') then Result := tkKey else
490       if KeyComp('or') then Result := tkKey else
491         if KeyComp('cdate') then Result := tkKey else
492           if KeyComp('cdate') then Result := tkKey else Result := tkIdentifier;
493 end;
494 
Func34null495 function TSynVBSyn.Func34: TtkTokenKind;
496 begin
497   if KeyComp('log') then Result := tkKey else Result := tkIdentifier;
498 end;
499 
Func35null500 function TSynVBSyn.Func35: TtkTokenKind;
501 begin
502   if KeyComp('val') then Result := tkKey else
503     if KeyComp('tan') then Result := tkKey else
504       if KeyComp('to') then Result := tkKey else
505         if KeyComp('atn') then Result := tkKey else Result := tkIdentifier;
506 end;
507 
Func36null508 function TSynVBSyn.Func36: TtkTokenKind;
509 begin
510   if KeyComp('clng') then Result := tkKey else
511     if KeyComp('rnd') then Result := tkKey else
512       if KeyComp('rem') then
513       begin
514         ApostropheProc;
515         fStringLen:=0;
516         Result := tkComment;
517       end
518       else
519         Result := tkIdentifier;
520 end;
521 
TSynVBSyn.Func37null522 function TSynVBSyn.Func37: TtkTokenKind;
523 begin
524   if KeyComp('cos') then Result := tkKey else
525     if KeyComp('begin') then Result := tkKey else
526       if KeyComp('let') then Result := tkKey else
527         if KeyComp('hex') then Result := tkKey else Result := tkIdentifier;
528 end;
529 
TSynVBSyn.Func38null530 function TSynVBSyn.Func38: TtkTokenKind;
531 begin
532   if KeyComp('spc') then Result := tkKey else
533     if KeyComp('pv') then Result := tkKey else
534       if KeyComp('imp') then Result := tkKey else
535         if KeyComp('oct') then Result := tkKey else Result := tkIdentifier;
536 end;
537 
TSynVBSyn.Func39null538 function TSynVBSyn.Func39: TtkTokenKind;
539 begin
540   if KeyComp('dateadd') then Result := tkKey else
541     if KeyComp('clear') then Result := tkKey else
542       if KeyComp('for') then Result := tkKey else
543         if KeyComp('fix') then Result := tkKey else Result := tkIdentifier;
544 end;
545 
TSynVBSyn.Func40null546 function TSynVBSyn.Func40: TtkTokenKind;
547 begin
548   if KeyComp('seek') then Result := tkKey else
549     if KeyComp('sgn') then Result := tkKey else
550       if KeyComp('line') then Result := tkKey else
551         if KeyComp('lcase') then Result := tkKey else Result := tkIdentifier;
552 end;
553 
TSynVBSyn.Func41null554 function TSynVBSyn.Func41: TtkTokenKind;
555 begin
556   if KeyComp('lock') then Result := tkKey else
557     if KeyComp('err') then Result := tkKey else
558       if KeyComp('else') then Result := tkKey else Result := tkIdentifier;
559 end;
560 
Func42null561 function TSynVBSyn.Func42: TtkTokenKind;
562 begin
563   if KeyComp('chdir') then Result := tkKey else
564     if KeyComp('sub') then Result := tkKey else
565       if KeyComp('sin') then Result := tkKey else
566         if KeyComp('new') then Result := tkKey else Result := tkIdentifier;
567 end;
568 
Func43null569 function TSynVBSyn.Func43: TtkTokenKind;
570 begin
571   if KeyComp('csng') then Result := tkKey else
572     if KeyComp('int') then Result := tkKey else
573       if KeyComp('left') then Result := tkKey else Result := tkIdentifier;
574 end;
575 
Func44null576 function TSynVBSyn.Func44: TtkTokenKind;
577 begin
578   if KeyComp('cvar') then Result := tkKey else
579     if KeyComp('kill') then Result := tkKey else
580       if KeyComp('set') then Result := tkKey else
581         if KeyComp('rate') then Result := tkKey else
582           if KeyComp('space') then Result := tkKey else
583             if KeyComp('eqv') then Result := tkKey else Result := tkIdentifier;
584 end;
585 
Func45null586 function TSynVBSyn.Func45: TtkTokenKind;
587 begin
588   if KeyComp('ccur') then Result := tkKey else
589     if KeyComp('irr') then Result := tkKey else
590       if KeyComp('sln') then Result := tkKey else
591         if KeyComp('exp') then Result := tkKey else Result := tkIdentifier;
592 end;
593 
Func46null594 function TSynVBSyn.Func46: TtkTokenKind;
595 begin
596   if KeyComp('cint') then Result := tkKey else
597     if KeyComp('wend') then Result := tkKey else Result := tkIdentifier;
598 end;
599 
Func47null600 function TSynVBSyn.Func47: TtkTokenKind;
601 begin
602   if KeyComp('time') then Result := tkKey else
603     if KeyComp('cbool') then Result := tkKey else
604       if KeyComp('then') then Result := tkKey else Result := tkIdentifier;
605 end;
606 
TSynVBSyn.Func48null607 function TSynVBSyn.Func48: TtkTokenKind;
608 begin
609   if KeyComp('long') then Result := tkKey else
610     if KeyComp('syd') then Result := tkKey else
611       if KeyComp('erase') then Result := tkKey else Result := tkIdentifier;
612 end;
613 
TSynVBSyn.Func49null614 function TSynVBSyn.Func49: TtkTokenKind;
615 begin
616   if KeyComp('ucase') then Result := tkKey else
617     if KeyComp('redim') then Result := tkKey else
618       if KeyComp('pmt') then Result := tkKey else
619         if KeyComp('not') then Result := tkKey else
620           if KeyComp('not') then Result := tkKey else Result := tkIdentifier;
621 end;
622 
TSynVBSyn.Func50null623 function TSynVBSyn.Func50: TtkTokenKind;
624 begin
625   if KeyComp('circle') then Result := tkKey else
626     if KeyComp('open') then Result := tkKey else Result := tkIdentifier;
627 end;
628 
TSynVBSyn.Func52null629 function TSynVBSyn.Func52: TtkTokenKind;
630 begin
631   if KeyComp('raise') then Result := tkKey else
632     if KeyComp('now') then Result := tkKey else
633       if KeyComp('npv') then Result := tkKey else
634         if KeyComp('byte') then Result := tkKey else
635           if KeyComp('form') then Result := tkKey else Result := tkIdentifier;
636 end;
637 
Func53null638 function TSynVBSyn.Func53: TtkTokenKind;
639 begin
640   if KeyComp('nper') then Result := tkKey else Result := tkIdentifier;
641 end;
642 
Func54null643 function TSynVBSyn.Func54: TtkTokenKind;
644 begin
645   if KeyComp('sqr') then Result := tkKey else
646     if KeyComp('class') then Result := tkKey else
647       if KeyComp('close') then Result := tkKey else Result := tkIdentifier;
648 end;
649 
Func55null650 function TSynVBSyn.Func55: TtkTokenKind;
651 begin
652   if KeyComp('mkdir') then Result := tkKey else
653     if KeyComp('datediff') then Result := tkKey else
654       if KeyComp('object') then Result := tkKey else
655         if KeyComp('cbyte') then Result := tkKey else Result := tkIdentifier;
656 end;
657 
Func56null658 function TSynVBSyn.Func56: TtkTokenKind;
659 begin
660   if KeyComp('lset') then Result := tkKey else
661     if KeyComp('shell') then Result := tkKey else
662       if KeyComp('elseif') then Result := tkKey else Result := tkIdentifier;
663 end;
664 
Func57null665 function TSynVBSyn.Func57: TtkTokenKind;
666 begin
667   if KeyComp('str') then Result := tkKey else
668     if KeyComp('goto') then Result := tkKey else
669       if KeyComp('xor') then Result := tkKey else
670         if KeyComp('put') then Result := tkKey else
671           if KeyComp('while') then Result := tkKey else Result := tkIdentifier;
672 end;
673 
Func58null674 function TSynVBSyn.Func58: TtkTokenKind;
675 begin
676   if KeyComp('mirr') then Result := tkKey else
677     if KeyComp('isdate') then Result := tkKey else
678       if KeyComp('ipmt') then Result := tkKey else
679         if KeyComp('exit') then Result := tkKey else
680           if KeyComp('loop') then Result := tkKey else Result := tkIdentifier;
681 end;
682 
TSynVBSyn.Func59null683 function TSynVBSyn.Func59: TtkTokenKind;
684 begin
685   if KeyComp('double') then Result := tkKey else Result := tkIdentifier;
686 end;
687 
TSynVBSyn.Func60null688 function TSynVBSyn.Func60: TtkTokenKind;
689 begin
690   if KeyComp('with') then Result := tkKey else
691     if KeyComp('second') then Result := tkKey else
692       if KeyComp('cstr') then Result := tkKey else
693         if KeyComp('pset') then Result := tkKey else
694           if KeyComp('trim') then Result := tkKey else Result := tkIdentifier;
695 end;
696 
TSynVBSyn.Func62null697 function TSynVBSyn.Func62: TtkTokenKind;
698 begin
699   if KeyComp('rmdir') then Result := tkKey else
700     if KeyComp('right') then Result := tkKey else
701       if KeyComp('rset') then Result := tkKey else
702         if KeyComp('hour') then Result := tkKey else Result := tkIdentifier;
703 end;
704 
TSynVBSyn.Func63null705 function TSynVBSyn.Func63: TtkTokenKind;
706 begin
707   if KeyComp('next') then Result := tkKey else
708     if KeyComp('filelen') then Result := tkKey else
709       if KeyComp('public') then Result := tkKey else
710         if KeyComp('command') then Result := tkKey else
711           if KeyComp('array') then Result := tkKey else Result := tkIdentifier;
712 end;
713 
Func64null714 function TSynVBSyn.Func64: TtkTokenKind;
715 begin
716   if KeyComp('select') then Result := tkKey else
717     if KeyComp('gosub') then Result := tkKey else
718       if KeyComp('boolean') then Result := tkKey else
719         if KeyComp('width') then Result := tkKey else Result := tkIdentifier;
720 end;
721 
Func65null722 function TSynVBSyn.Func65: TtkTokenKind;
723 begin
724   if KeyComp('timer') then Result := tkKey else
725     if KeyComp('ppmt') then Result := tkKey else Result := tkIdentifier;
726 end;
727 
Func66null728 function TSynVBSyn.Func66: TtkTokenKind;
729 begin
730   if KeyComp('freefile') then Result := tkKey else
731     if KeyComp('single') then Result := tkKey else
732       if KeyComp('cverr') then Result := tkKey else Result := tkIdentifier;
733 end;
734 
Func67null735 function TSynVBSyn.Func67: TtkTokenKind;
736 begin
737   if KeyComp('reset') then Result := tkKey else Result := tkIdentifier;
738 end;
739 
Func68null740 function TSynVBSyn.Func68: TtkTokenKind;
741 begin
742   if KeyComp('lbound') then Result := tkKey else Result := tkIdentifier;
743 end;
744 
Func69null745 function TSynVBSyn.Func69: TtkTokenKind;
746 begin
747   if KeyComp('chdrive') then Result := tkKey else Result := tkIdentifier;
748 end;
749 
TSynVBSyn.Func70null750 function TSynVBSyn.Func70: TtkTokenKind;
751 begin
752   if KeyComp('stop') then Result := tkKey else
753     if KeyComp('month') then Result := tkKey else
754       if KeyComp('module') then Result := tkKey else Result := tkIdentifier;
755 end;
756 
TSynVBSyn.Func71null757 function TSynVBSyn.Func71: TtkTokenKind;
758 begin
759   if KeyComp('const') then Result := tkKey else
760     if KeyComp('compare') then Result := tkKey else Result := tkIdentifier;
761 end;
762 
TSynVBSyn.Func72null763 function TSynVBSyn.Func72: TtkTokenKind;
764 begin
765   if KeyComp('ltrim') then Result := tkKey else
766     if KeyComp('static') then Result := tkKey else Result := tkIdentifier;
767 end;
768 
TSynVBSyn.Func73null769 function TSynVBSyn.Func73: TtkTokenKind;
770 begin
771   if KeyComp('curdir') then Result := tkKey else
772     if KeyComp('format') then Result := tkKey else Result := tkIdentifier;
773 end;
774 
TSynVBSyn.Func74null775 function TSynVBSyn.Func74: TtkTokenKind;
776 begin
777   if KeyComp('weekday') then Result := tkKey else
778     if KeyComp('error') then Result := tkKey else Result := tkIdentifier;
779 end;
780 
Func75null781 function TSynVBSyn.Func75: TtkTokenKind;
782 begin
783   if KeyComp('write') then Result := tkKey else Result := tkIdentifier;
784 end;
785 
Func76null786 function TSynVBSyn.Func76: TtkTokenKind;
787 begin
788   if KeyComp('until') then Result := tkKey else
789     if KeyComp('unlock') then Result := tkKey else Result := tkIdentifier;
790 end;
791 
Func77null792 function TSynVBSyn.Func77: TtkTokenKind;
793 begin
794   if KeyComp('ubound') then Result := tkKey else
795     if KeyComp('print') then Result := tkKey else Result := tkIdentifier;
796 end;
797 
Func78null798 function TSynVBSyn.Func78: TtkTokenKind;
799 begin
800   if KeyComp('integer') then Result := tkKey else
801     if KeyComp('rtrim') then Result := tkKey else Result := tkIdentifier;
802 end;
803 
Func79null804 function TSynVBSyn.Func79: TtkTokenKind;
805 begin
806   if KeyComp('empty') then Result := tkKey else Result := tkIdentifier;
807 end;
808 
TSynVBSyn.Func80null809 function TSynVBSyn.Func80: TtkTokenKind;
810 begin
811   if KeyComp('instr') then Result := tkKey else
812     if KeyComp('input') then Result := tkKey else
813       if KeyComp('msgbox') then Result := tkKey else Result := tkIdentifier;
814 end;
815 
TSynVBSyn.Func81null816 function TSynVBSyn.Func81: TtkTokenKind;
817 begin
818   if KeyComp('deftype') then Result := tkKey else
819     if KeyComp('resume') then Result := tkKey else Result := tkIdentifier;
820 end;
821 
TSynVBSyn.Func82null822 function TSynVBSyn.Func82: TtkTokenKind;
823 begin
824   if KeyComp('minute') then Result := tkKey else
825     if KeyComp('switch') then Result := tkKey else
826       if KeyComp('qbcolor') then Result := tkKey else Result := tkIdentifier;
827 end;
828 
TSynVBSyn.Func83null829 function TSynVBSyn.Func83: TtkTokenKind;
830 begin
831   if KeyComp('isobject') then Result := tkKey else Result := tkIdentifier;
832 end;
833 
TSynVBSyn.Func85null834 function TSynVBSyn.Func85: TtkTokenKind;
835 begin
836   if KeyComp('variant') then Result := tkKey else
837     if KeyComp('datepart') then Result := tkKey else Result := tkIdentifier;
838 end;
839 
Func87null840 function TSynVBSyn.Func87: TtkTokenKind;
841 begin
842   if KeyComp('string') then Result := tkKey else
843     if KeyComp('nothing') then Result := tkKey else
844       if KeyComp('isnull') then Result := tkKey else
845         if KeyComp('getobject') then Result := tkKey else Result := tkIdentifier;
846 end;
847 
Func89null848 function TSynVBSyn.Func89: TtkTokenKind;
849 begin
850   if KeyComp('option') then Result := tkKey else
851     if KeyComp('option') then Result := tkKey else
852       if KeyComp('option') then Result := tkKey else Result := tkIdentifier;
853 end;
854 
TSynVBSyn.Func91null855 function TSynVBSyn.Func91: TtkTokenKind;
856 begin
857   if KeyComp('private') then Result := tkKey else
858     if KeyComp('datevalue') then Result := tkKey else
859       if KeyComp('fileattr') then Result := tkKey else
860         if KeyComp('isarray') then Result := tkKey else
861           if KeyComp('fileattr') then Result := tkKey else
862             if KeyComp('filecopy') then Result := tkKey else
863               if KeyComp('getattr') then Result := tkKey else Result := tkIdentifier;
864 end;
865 
TSynVBSyn.Func94null866 function TSynVBSyn.Func94: TtkTokenKind;
867 begin
868   if KeyComp('dateserial') then Result := tkKey else Result := tkIdentifier;
869 end;
870 
TSynVBSyn.Func96null871 function TSynVBSyn.Func96: TtkTokenKind;
872 begin
873   if KeyComp('return') then Result := tkKey else Result := tkIdentifier;
874 end;
875 
Func97null876 function TSynVBSyn.Func97: TtkTokenKind;
877 begin
878   if KeyComp('environ') then Result := tkKey else Result := tkIdentifier;
879 end;
880 
Func98null881 function TSynVBSyn.Func98: TtkTokenKind;
882 begin
883   if KeyComp('explicit') then Result := tkKey else
884     if KeyComp('explicit') then Result := tkKey else Result := tkIdentifier;
885 end;
886 
Func99null887 function TSynVBSyn.Func99: TtkTokenKind;
888 begin
889   if KeyComp('typename') then Result := tkKey else Result := tkIdentifier;
890 end;
891 
TSynVBSyn.Func101null892 function TSynVBSyn.Func101: TtkTokenKind;
893 begin
894   if KeyComp('system') then Result := tkKey else Result := tkIdentifier;
895 end;
896 
TSynVBSyn.Func102null897 function TSynVBSyn.Func102: TtkTokenKind;
898 begin
899   if KeyComp('function') then Result := tkKey else
900     if KeyComp('version') then Result := tkKey else
901       if KeyComp('sendkeys') then Result := tkKey else
902         if KeyComp('iserror') then Result := tkKey else Result := tkIdentifier;
903 end;
904 
TSynVBSyn.Func103null905 function TSynVBSyn.Func103: TtkTokenKind;
906 begin
907   if KeyComp('setattr') then Result := tkKey else Result := tkIdentifier;
908 end;
909 
TSynVBSyn.Func104null910 function TSynVBSyn.Func104: TtkTokenKind;
911 begin
912   if KeyComp('doevents') then Result := tkKey else
913     if KeyComp('strcomp') then Result := tkKey else Result := tkIdentifier;
914 end;
915 
Func105null916 function TSynVBSyn.Func105: TtkTokenKind;
917 begin
918   if KeyComp('randomize') then Result := tkKey else Result := tkIdentifier;
919 end;
920 
Func107null921 function TSynVBSyn.Func107: TtkTokenKind;
922 begin
923   if KeyComp('isempty') then Result := tkKey else
924     if KeyComp('currency') then Result := tkKey else
925       if KeyComp('vartype') then Result := tkKey else
926         if KeyComp('createobject') then Result := tkKey else Result := tkIdentifier;
927 end;
928 
Func108null929 function TSynVBSyn.Func108: TtkTokenKind;
930 begin
931   if KeyComp('timevalue') then Result := tkKey else Result := tkIdentifier;
932 end;
933 
Func109null934 function TSynVBSyn.Func109: TtkTokenKind;
935 begin
936   if KeyComp('filedatetime') then Result := tkKey else Result := tkIdentifier;
937 end;
938 
Func111null939 function TSynVBSyn.Func111: TtkTokenKind;
940 begin
941   if KeyComp('isnumeric') then Result := tkKey else
942     if KeyComp('strconv') then Result := tkKey else
943       if KeyComp('timeserial') then Result := tkKey else Result := tkIdentifier;
944 end;
945 
TSynVBSyn.Func114null946 function TSynVBSyn.Func114: TtkTokenKind;
947 begin
948   if KeyComp('appactivate') then Result := tkKey else Result := tkIdentifier;
949 end;
950 
Func116null951 function TSynVBSyn.Func116: TtkTokenKind;
952 begin
953   if KeyComp('attribute') then Result := tkKey else Result := tkIdentifier;
954 end;
955 
Func118null956 function TSynVBSyn.Func118: TtkTokenKind;
957 begin
958   if KeyComp('ismissing') then Result := tkKey else Result := tkIdentifier;
959 end;
960 
Func133null961 function TSynVBSyn.Func133: TtkTokenKind;
962 begin
963   if KeyComp('property') then Result := tkKey else Result := tkIdentifier;
964 end;
965 
AltFuncnull966 function TSynVBSyn.AltFunc: TtkTokenKind;
967 begin
968   Result := tkIdentifier;
969 end;
970 
TSynVBSyn.IdentKindnull971 function TSynVBSyn.IdentKind(MayBe: PChar): TtkTokenKind;
972 var
973   HashKey: Integer;
974 begin
975   fToIdent := MayBe;
976   HashKey := KeyHash(MayBe);
977   if HashKey < 134 then
978     Result := fIdentFuncTable[HashKey]()
979   else
980     Result := tkIdentifier;
981 end;
982 
983 procedure TSynVBSyn.MakeMethodTables;
984 var
985   I: Char;
986 begin
987   for I := #0 to #255 do
988     case I of
989       '&': fProcTable[I] := @SymbolProc;
990       #39: fProcTable[I] := @ApostropheProc;
991       '}': fProcTable[I] := @SymbolProc;
992       '{': fProcTable[I] := @SymbolProc;
993       #13: fProcTable[I] := @CRProc;
994       ':': fProcTable[I] := @SymbolProc;
995       ',': fProcTable[I] := @SymbolProc;
996       '#': fProcTable[I] := @DateProc;
997       '=': fProcTable[I] := @SymbolProc;
998       '^': fProcTable[I] := @SymbolProc;
999       '>': fProcTable[I] := @GreaterProc;
1000       'A'..'Z', 'a'..'z', '_': fProcTable[I] := @IdentProc;
1001       #10: fProcTable[I] := @LFProc;
1002       '<': fProcTable[I] := @LowerProc;
1003       '-': fProcTable[I] := @SymbolProc;
1004       #0: fProcTable[I] := @NullProc;
1005       '0'..'9': fProcTable[I] := @NumberProc;
1006       '+': fProcTable[I] := @SymbolProc;
1007       '.': fProcTable[I] := @SymbolProc;
1008       ')': fProcTable[I] := @SymbolProc;
1009       '(': fProcTable[I] := @SymbolProc;
1010       ';': fProcTable[I] := @SymbolProc;
1011       '/': fProcTable[I] := @SymbolProc;
1012       '\': fProcTable[I] := @SymbolProc; // integer division
1013        #1..#9, #11, #12, #14..#32: fProcTable[I] := @SpaceProc;
1014       '*': fProcTable[I] := @SymbolProc;
1015       #34: fProcTable[I] := @StringProc;
1016       else fProcTable[I] := @UnknownProc;
1017     end;
1018 end;
1019 
1020 constructor TSynVBSyn.Create(AOwner: TComponent);
1021 begin
1022   inherited Create(AOwner);
1023   fCommentAttri := TSynHighlighterAttributes.Create(@SYNS_AttrComment, SYNS_XML_AttrComment);
1024   fCommentAttri.Style:= [fsItalic];
1025   AddAttribute(fCommentAttri);
1026   fIdentifierAttri := TSynHighlighterAttributes.Create(@SYNS_AttrIdentifier, SYNS_XML_AttrIdentifier);
1027   AddAttribute(fIdentifierAttri);
1028   fKeyAttri := TSynHighlighterAttributes.Create(@SYNS_AttrReservedWord, SYNS_XML_AttrReservedWord);
1029   fKeyAttri.Style:= [fsBold];
1030   AddAttribute(fKeyAttri);
1031   fNumberAttri := TSynHighlighterAttributes.Create(@SYNS_AttrNumber, SYNS_XML_AttrNumber);
1032   AddAttribute(fNumberAttri);
1033   fSpaceAttri := TSynHighlighterAttributes.Create(@SYNS_AttrSpace, SYNS_XML_AttrSpace);
1034   AddAttribute(fSpaceAttri);
1035   fStringAttri := TSynHighlighterAttributes.Create(@SYNS_AttrString, SYNS_XML_AttrString);
1036   AddAttribute(fStringAttri);
1037   fSymbolAttri := TSynHighlighterAttributes.Create(@SYNS_AttrSymbol, SYNS_XML_AttrSymbol);
1038   AddAttribute(fSymbolAttri);
1039   SetAttributesOnChange(@DefHighlightChange);
1040   InitIdent;
1041   MakeMethodTables;
1042   fDefaultFilter := SYNS_FilterVisualBASIC;
1043 end;
1044 
1045 procedure TSynVBSyn.SetLine(const NewValue: String; LineNumber: Integer);
1046 begin
1047   inherited;
1048   fLine := PChar(NewValue);
1049   Run := 0;
1050   fLineNumber := LineNumber;
1051   Next;
1052 end;
1053 
1054 procedure TSynVBSyn.SymbolProc;
1055 begin
1056   inc(Run);
1057   fTokenId := tkSymbol;
1058 end;
1059 
1060 procedure TSynVBSyn.ApostropheProc;
1061 begin
1062   fTokenID := tkComment;
1063   repeat
1064     Inc(Run);
1065   until fLine[Run] in [#0, #10, #13];
1066 end;
1067 
1068 procedure TSynVBSyn.CRProc;
1069 begin
1070   fTokenID := tkSpace;
1071   Inc(Run);
1072   if fLine[Run] = #10 then Inc(Run);
1073 end;
1074 
1075 procedure TSynVBSyn.DateProc;
1076 begin
1077   fTokenID := tkString;
1078   repeat
1079     case FLine[Run] of
1080       #0, #10, #13: break;
1081     end;
1082     inc(Run);
1083   until FLine[Run] = '#';
1084   if FLine[Run] <> #0 then inc(Run);
1085 end;
1086 
1087 procedure TSynVBSyn.GreaterProc;
1088 begin
1089   fTokenID := tkSymbol;
1090   Inc(Run);
1091   if fLine[Run] = '=' then Inc(Run);
1092 end;
1093 
1094 procedure TSynVBSyn.IdentProc;
1095 begin
1096   fTokenID := IdentKind((fLine + Run));
1097   inc(Run, fStringLen);
1098   while Identifiers[fLine[Run]] do inc(Run);
1099 end;
1100 
1101 procedure TSynVBSyn.LFProc;
1102 begin
1103   fTokenID := tkSpace;
1104   inc(Run);
1105 end;
1106 
1107 procedure TSynVBSyn.LowerProc;
1108 begin
1109   fTokenID := tkSymbol;
1110   Inc(Run);
1111   if fLine[Run] in ['=', '>'] then Inc(Run);
1112 end;
1113 
1114 procedure TSynVBSyn.NullProc;
1115 begin
1116   fTokenID := tkNull;
1117 end;
1118 
1119 procedure TSynVBSyn.NumberProc;
1120 begin
1121   inc(Run);
1122   fTokenID := tkNumber;
1123   while FLine[Run] in ['0'..'9'] do inc(Run);
1124   if (FLine[Run]='.') and not(fLine[Run+1]='.')  then begin
1125     inc(Run);
1126     while FLine[Run] in ['0'..'9'] do inc(Run);
1127   end;
1128   if (FLine[Run]='e') or (fLine[Run]='E')  then begin
1129     inc(Run);
1130     if (FLine[Run]='+') or (fLine[Run]='-')  then inc(Run);
1131     while FLine[Run] in ['0'..'9'] do inc(Run);
1132   end;
1133 end;
1134 
1135 procedure TSynVBSyn.SpaceProc;
1136 begin
1137   inc(Run);
1138   fTokenID := tkSpace;
1139   while FLine[Run] in [#1..#9, #11, #12, #14..#32] do inc(Run);
1140 end;
1141 
1142 procedure TSynVBSyn.StringProc;
1143 begin
1144   fTokenID := tkString;
1145   if (FLine[Run + 1] = #34) and (FLine[Run + 2] = #34) then inc(Run, 2);
1146   repeat
1147     case FLine[Run] of
1148       #0, #10, #13: break;
1149     end;
1150     inc(Run);
1151   until FLine[Run] = #34;
1152   if FLine[Run] <> #0 then inc(Run);
1153 end;
1154 
1155 procedure TSynVBSyn.UnknownProc;
1156 begin
1157 {$IFDEF SYN_MBCSSUPPORT}
1158   if FLine[Run] in LeadBytes then
1159     Inc(Run, 2)
1160   else
1161 {$ENDIF}
1162   inc(Run);
1163   while (fLine[Run] in [#128..#191]) OR // continued utf8 subcode
1164    ((fLine[Run]<>#0) and (fProcTable[fLine[Run]] = @UnknownProc)) do inc(Run);
1165   fTokenID := tkUnknown;
1166 end;
1167 
1168 procedure TSynVBSyn.Next;
1169 begin
1170   fTokenPos := Run;
1171   fProcTable[fLine[Run]]();
1172 end;
1173 
GetDefaultAttributenull1174 function TSynVBSyn.GetDefaultAttribute(Index: integer):
1175   TSynHighlighterAttributes;
1176 begin
1177   case Index of
1178     SYN_ATTR_COMMENT: Result := fCommentAttri;
1179     SYN_ATTR_IDENTIFIER: Result := fIdentifierAttri;
1180     SYN_ATTR_KEYWORD: Result := fKeyAttri;
1181     SYN_ATTR_STRING: Result := fStringAttri;
1182     SYN_ATTR_WHITESPACE: Result := fSpaceAttri;
1183     SYN_ATTR_SYMBOL: Result := fSymbolAttri;
1184     SYN_ATTR_NUMBER: Result := fNumberAttri;
1185   else
1186     Result := nil;
1187   end;
1188 end;
1189 
GetEolnull1190 function TSynVBSyn.GetEol: Boolean;
1191 begin
1192   Result := fTokenID = tkNull;
1193 end;
1194 
TSynVBSyn.GetTokennull1195 function TSynVBSyn.GetToken: String;
1196 var
1197   Len: LongInt;
1198 begin
1199   Result := '';
1200   Len := Run - fTokenPos;
1201   SetString(Result, (FLine + fTokenPos), Len);
1202 end;
1203 
1204 procedure TSynVBSyn.GetTokenEx(out TokenStart: PChar;
1205   out TokenLength: integer);
1206 begin
1207   TokenLength:=Run-fTokenPos;
1208   TokenStart:=FLine + fTokenPos;
1209 end;
1210 
GetTokenIDnull1211 function TSynVBSyn.GetTokenID: TtkTokenKind;
1212 begin
1213   Result := fTokenId;
1214 end;
1215 
TSynVBSyn.GetTokenAttributenull1216 function TSynVBSyn.GetTokenAttribute: TSynHighlighterAttributes;
1217 begin
1218   case GetTokenID of
1219     tkComment: Result := fCommentAttri;
1220     tkIdentifier: Result := fIdentifierAttri;
1221     tkKey: Result := fKeyAttri;
1222     tkNumber: Result := fNumberAttri;
1223     tkSpace: Result := fSpaceAttri;
1224     tkString: Result := fStringAttri;
1225     tkSymbol: Result := fSymbolAttri;
1226     tkUnknown: Result := fIdentifierAttri;
1227     else Result := nil;
1228   end;
1229 end;
1230 
GetTokenKindnull1231 function TSynVBSyn.GetTokenKind: integer;
1232 begin
1233   Result := Ord(fTokenId);
1234 end;
1235 
GetTokenPosnull1236 function TSynVBSyn.GetTokenPos: Integer;
1237 begin
1238   Result := fTokenPos;
1239 end;
1240 
GetIdentCharsnull1241 function TSynVBSyn.GetIdentChars: TSynIdentChars;
1242 begin
1243   Result := TSynValidStringChars;
1244 end;
1245 
IsFilterStorednull1246 function TSynVBSyn.IsFilterStored: Boolean;
1247 begin
1248   Result := fDefaultFilter <> SYNS_FilterVisualBASIC;
1249 end;
1250 
TSynVBSyn.GetLanguageNamenull1251 class function TSynVBSyn.GetLanguageName: string;
1252 begin
1253   Result := SYNS_LangVisualBASIC;
1254 end;
1255 
GetSampleSourcenull1256 function TSynVBSyn.GetSampleSource: String;
1257 begin
1258   Result := ''' Syntax highlighting'#13#10+
1259             'Function PrintNumber'#13#10+
1260             '  Dim Number'#13#10+
1261             '  Dim X'#13#10+
1262             ''#13#10+
1263             '  Number = 123456'#13#10+
1264             '  Response.Write "The number is " & number'#13#10+
1265             ''#13#10+
1266             '  For I = 0 To Number'#13#10+
1267             '    X = X + &h4c'#13#10+
1268             '    X = X - &o8'#13#10+
1269             '    X = X + 1.0'#13#10+
1270             '  Next'#13#10+
1271             ''#13#10+
1272             '  I = I + @;  '' illegal character'#13#10+
1273             'End Function';
1274 end;
1275 
1276 initialization
1277   MakeIdentTable;
1278   RegisterPlaceableHighlighter(TSynVBSyn);
1279 
1280 end.
1281