forked from KrystianBigaj/synweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSynHighlighterWeb.pas
9265 lines (8485 loc) · 264 KB
/
SynHighlighterWeb.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{-------------------------------------------------------------------------------
SynWeb
Copyright (C) 2005-2011 Krystian Bigaj
*** MPL
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is Krystian Bigaj.
Alternatively, the contents of this file may be used under the terms
of the GNU Lesser General Public license (the "LGPL License"),
in which case the provisions of LGPL License are applicable instead of those
above. If you wish to allow use of your version of this file only
under the terms of the LGPL License and not to allow others to use
your version of this file under the MPL, indicate your decision by
deleting the provisions above and replace them with the notice and
other provisions required by the LGPL License. If you do not delete
the provisions above, a recipient may use your version of this file
under either the MPL or the LGPL License.
*** LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
***
You may retrieve the latest version of this file at the SynWeb home page,
located at http://sourceforge.net/projects/synweb
Contact: [email protected]
Homepage: http://flatdev.ovh.org
-------------------------------------------------------------------------------}
(*
Known limitations:
- SynWeb highlighters support only single line SetLine (don't use more than one line).
- Doesn't support #13#10, #10 or #13 as new line. Always use #0 as line break.
- Php: Doesn't support multi-line encapsuled strings in String, only single line:
eg. "somestring {$a["some array{$b['key'].... <- only single line encapsuled values
- TSynWebSmartySyn limitations:
- Options.SmartyLDelim MUST begin with '{' and Options.SmartyRDelim MUST begin with '}'.
- Smarty highlighter doesn't support {literal} ... {/literal}
*)
{
@abstract(Provides an web-files (Multi Html/XHtml/Wml/Xml/Xslt/Css/ECMAScript/Php/Smarty) highlighter for SynEdit
@author(Krystian Bigaj <[email protected]>)
@created(2005-05-21)
The SynHighlighterWeb unit provides SynEdit with a Multi Html/XHtml/Wml/Xml/Xslt/Css/ECMAScript/Php highlighter.
}
unit SynHighlighterWeb;
{$I SynWeb.inc}
interface
uses
Graphics,
SynUnicode,
SynEditTypes,
SynEditHighlighter,
SynHighlighterWebData,
Classes,
SysUtils;
// Highlighter -----------------------------------------------------------------
type
TSynWebEngine = class;
TSynWebBase = class;
PSynWebOptions = ^TSynWebOptions;
TSynWebOptions = record
FMLVersion: TSynWebMLVersion;
FHtmlVersion: TSynWebHtmlVersion;
FHtml5XmlMode: Boolean;
FWmlVersion: TSynWebWmlVersion;
FXsltVersion: TSynWebXSLTVersion;
FCssVersion: TSynWebCssVersion;
FPhpVersion: TSynWebPhpVersion;
FPhpShortOpenTag: Boolean;
FPhpAspTags: Boolean;
FAllowASPTags: Boolean;
FXmlMode: Boolean;
FPhpEmbeded: Boolean;
FCssEmbeded: Boolean;
FEsEmbeded: Boolean;
FSmartyLDelim: AnsiString;
FSmartyRDelim: AnsiString;
end;
PSynWebInstance = ^TSynWebInstance;
TSynWebInstance = record
FRun: Longint;
FRange: Longword;
FLine: PAnsiChar;
FLineRef: AnsiString;
FLineNumber: Integer;
FTokenLastID: Integer;
FTokenPos: Integer;
FTokenID: TSynWebTokenKind;
FStringLen, FStringLenClean: Integer;
FTokenLastSymbolId: Integer;
FToIdent: PAnsiChar;
FHashTable: PSynWebHashTable;
FNextClearBits: Boolean;
FNextUseNextAH: Boolean;
FUseNextAH: Boolean;
FHighlighterType: TSynWebHighlighterType;
FPrevHighlighterType, FNextHighlighterType: TSynWebHighlighterType;
FHighlighterSW: Boolean;
FHighlighterMode: TSynWebHighlighterMode;
FCssMask: Longword;
FNextProcTable: TSynWebProcTableProc;
FSYN_ATTR_COMMENT: TSynHighlighterAttributes;
FSYN_ATTR_STRING: TSynHighlighterAttributes;
FSYN_ATTR_WHITESPACE: TSynHighlighterAttributes;
FOptions: TSynWebOptions;
FHighlither: TSynWebBase;
FCssVendorPropertyId: Integer;
FCssInstancePropertyId: Integer;
end;
{ TSynWebOptionsBase }
TSynWebOptionsBase = class(TPersistent)
private
FOptions: PSynWebOptions;
FEngineOptions: PSynWebOptions;
FUseEngineOptions: Boolean;
FOnChange: TNotifyEvent;
function GetHtml5XmlMode: Boolean;
procedure SetHtml5XmlMode(const Value: Boolean);
function GetHtmlVersion: TSynWebHtmlVersion;
procedure SetHtmlVersion(const Value: TSynWebHtmlVersion);
function GetWmlVersion: TSynWebWmlVersion;
procedure SetWmlVersion(const Value: TSynWebWmlVersion);
function GetXsltVersion: TSynWebXSLTVersion;
procedure SetXsltVersion(const Value: TSynWebXSLTVersion);
function GetCssVersion: TSynWebCssVersion;
procedure SetCssVersion(const Value: TSynWebCssVersion);
function GetPhpVersion: TSynWebPhpVersion;
procedure SetPhpVersion(const Value: TSynWebPhpVersion);
function GetPhpAspTags: Boolean;
procedure SetPhpAspTags(const Value: Boolean);
function GetPhpShortOpenTag: Boolean;
procedure SetPhpShortOpenTag(const Value: Boolean);
function GetAllowASPTags: Boolean;
procedure SetAllowASPTags(const Value: Boolean);
function GetCssEmbeded: Boolean;
procedure SetCssEmbeded(const Value: Boolean);
function GetEsEmbeded: Boolean;
procedure SetEsEmbeded(const Value: Boolean);
function GetPhpEmbeded: Boolean;
procedure SetPhpEmbeded(const Value: Boolean);
procedure SetUseEngineOptions(const Value: Boolean);
procedure SetEngineOptions(AEngine: PSynWebOptions);
procedure DoOnChange;
procedure UpdateOptions;
protected
procedure AssignTo(Dest: TPersistent); override;
procedure UpdateMLOption; virtual;
function UsingEngineOptions: Boolean;
property Html5XmlMode: Boolean read GetHtml5XmlMode write SetHtml5XmlMode default True;
property HtmlVersion: TSynWebHtmlVersion read GetHtmlVersion write SetHtmlVersion default shvXHtml10Transitional;
property WmlVersion: TSynWebWmlVersion read GetWmlVersion write SetWmlVersion default swvWml13;
property XsltVersion: TSynWebXSLTVersion read GetXsltVersion write SetXsltVersion default swvXslt20;
property CssVersion: TSynWebCssVersion read GetCssVersion write SetCssVersion default scvCss21;
property PhpVersion: TSynWebPhpVersion read GetPhpVersion write SetPhpVersion default spvPhp5;
property PhpShortOpenTag: Boolean read GetPhpShortOpenTag write SetPhpShortOpenTag default True;
property PhpAspTags: Boolean read GetPhpAspTags write SetPhpAspTags default False;
property AllowASPTags: Boolean read GetAllowASPTags write SetAllowASPTags default True;
property CssEmbeded: Boolean read GetCssEmbeded write SetCssEmbeded default False;
property PhpEmbeded: Boolean read GetPhpEmbeded write SetPhpEmbeded default False;
property EsEmbeded: Boolean read GetEsEmbeded write SetEsEmbeded default False;
property UseEngineOptions: Boolean read FUseEngineOptions write SetUseEngineOptions default False;
public
constructor Create(AOptions: PSynWebOptions);
function IsXmlMode: Boolean;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
{ TSynWebHtmlOptions }
TSynWebHtmlOptions = class(TSynWebOptionsBase)
protected
procedure UpdateMLOption; override;
public
constructor Create(AOptions: PSynWebOptions);
published
property Html5XmlMode;
property HtmlVersion;
property CssVersion;
property PhpVersion;
property PhpShortOpenTag;
property PhpAspTags;
property AllowASPTags;
property CssEmbeded default True;
property PhpEmbeded default True;
property EsEmbeded default True;
property UseEngineOptions;
end;
{ TSynWebSmartyOptions }
TSynWebSmartyOptions = class(TSynWebOptionsBase)
private
function GetSmartyLDelim: String;
procedure SetSmartyLDelim(const Value: String);
function GetSmartyRDelim: String; protected
procedure SetSmartyRDelim(const Value: String);
protected
procedure UpdateMLOption; override;
public
constructor Create(AOptions: PSynWebOptions);
published
property SmartyLDelim: String read GetSmartyLDelim write SetSmartyLDelim;
property SmartyRDelim: String read GetSmartyRDelim write SetSmartyRDelim;
property Html5XmlMode;
property HtmlVersion;
property CssVersion;
property PhpVersion;
property CssEmbeded default True;
property EsEmbeded default True;
property UseEngineOptions;
end;
{ TSynWebWmlOptions }
TSynWebWmlOptions = class(TSynWebOptionsBase)
protected
procedure UpdateMLOption; override;
public
constructor Create(AOptions: PSynWebOptions);
published
property WmlVersion;
property PhpVersion;
property PhpShortOpenTag;
property PhpAspTags;
property AllowASPTags;
property PhpEmbeded default True;
property UseEngineOptions;
end;
{ TSynWebXsltOptions }
TSynWebXsltOptions = class(TSynWebOptionsBase)
protected
procedure UpdateMLOption; override;
public
constructor Create(AOptions: PSynWebOptions);
published
property XsltVersion;
property PhpVersion;
property PhpShortOpenTag;
property PhpAspTags;
property AllowASPTags;
property PhpEmbeded default True;
property UseEngineOptions;
end;
{ TSynWebXmlOptions }
TSynWebXmlOptions = class(TSynWebOptionsBase)
protected
procedure UpdateMLOption; override;
public
constructor Create(AOptions: PSynWebOptions);
published
property PhpVersion;
property PhpShortOpenTag default False;
property PhpAspTags;
property PhpEmbeded default True;
property UseEngineOptions;
end;
{ TSynWebCssOptions }
TSynWebCssOptions = class(TSynWebOptionsBase)
published
property Html5XmlMode;
property HtmlVersion;
property CssVersion;
property PhpVersion;
property PhpShortOpenTag;
property PhpAspTags;
property PhpEmbeded;
property UseEngineOptions;
end;
{ TSynWebEsOptions }
TSynWebEsOptions = class(TSynWebOptionsBase)
published
property PhpVersion;
property PhpShortOpenTag;
property PhpAspTags;
property PhpEmbeded;
property UseEngineOptions;
end;
{ TSynWebPhpCliOptions }
TSynWebPhpCliOptions = class(TSynWebOptionsBase)
published
property PhpVersion;
property PhpShortOpenTag;
property PhpAspTags;
property UseEngineOptions;
end;
{ TSynWebPhpPlainOptions }
TSynWebPhpPlainOptions = class(TSynWebOptionsBase)
published
property PhpVersion;
property UseEngineOptions;
end;
{ TSynWebEngineOptions }
TSynWebEngineOptions = class(TSynWebOptionsBase)
public
constructor Create(AOptions: PSynWebOptions);
published
property Html5XmlMode;
property HtmlVersion;
property WmlVersion;
property XsltVersion;
property CssVersion;
property PhpVersion;
property PhpShortOpenTag;
property PhpAspTags;
end;
{ TSynWebBase }
TSynWebBaseClass = class of TSynWebBase;
TSynWebBase = class(TSynCustomHighlighter)
private
FInstance: TSynWebInstance;
FEngine: TSynWebEngine;
FActiveHighlighter: Boolean;
FActiveHighlighters: TSynWebHighlighterTypes;
FOptions: TSynWebOptionsBase;
procedure SetupActiveHighlighter; virtual; abstract;
procedure SetActiveHighlighter(const Value: Boolean);
procedure SetEngine(const Value: TSynWebEngine);
protected
{$IFDEF UNISYNEDIT}
procedure DoSetLine(const Value: UnicodeString; LineNumber: Integer); override;
{$ENDIF}
procedure DoDefHighlightChange;
function GetAttribCount: Integer; override;
function GetAttribute(idx: Integer): TSynHighlighterAttributes; override;
{$IFNDEF UNISYNEDIT}
function GetIdentChars: TSynIdentChars; override;
{$ENDIF}
{$IFDEF UNISYNEDIT}
function GetSampleSource: UnicodeString; override;
{$ELSE}
function GetSampleSource: String; override;
{$ENDIF}
public
procedure Assign(Source: TPersistent); override;
{$IFDEF UNISYNEDIT}
class function GetFriendlyLanguageName: UnicodeString; override;
class function SynWebSample: UnicodeString; virtual; abstract;
{$ELSE}
class function SynWebSample: String; virtual; abstract;
{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetDefaultAttribute(Index: Integer): TSynHighlighterAttributes;
override;
function GetTokenAttribute: TSynHighlighterAttributes; override;
{$IFNDEF UNISYNEDIT}
function GetToken: String; override;
{$ENDIF}
function GetTokenLen: Integer;
function GetTokenPos: Integer; override;
function GetTokenID: TSynWebTokenKind;
function GetTokenKind: Integer; override;
function GetRange: Pointer; override;
function GetEol: Boolean; override;
function GetHighlighterType: TSynWebHighlighterType;
function GetCharBeforeToken: AnsiChar;
function GetCharAfterToken: AnsiChar;
function PhpGetKeywordId: Integer;
function PhpGetFunctionId: Integer;
function PhpGetSymbolId: Integer;
function PhpGetRange: TSynWebPhpRangeState;
function MLGetTagID: Integer;
function MLGetTagKind: Integer;
function MLGetRange: TSynWebMLRangeState;
function CssGetPropertyId: Integer;
function CssGetRange: TSynWebCssRangeState;
function EsGetSymbolId: Integer;
function EsGetRange: TSynWebEsRangeState;
procedure SetRange(Value: Pointer); override;
{$IFNDEF UNISYNEDIT}
procedure SetLine(NewValue: String; LineNumber: Integer); override;
{$ENDIF}
procedure Next; override;
{$IFDEF UNISYNEDIT}
function GetActiveHighlighter(ARange: Pointer; const ALine: UnicodeString;
ACaretX, ACaretY: Integer): TSynWebHighlighterTypes;
{$ELSE}
function GetActiveHighlighter(ARange: Pointer; const ALine: String;
ACaretX, ACaretY: Integer): TSynWebHighlighterTypes;
{$ENDIF}
property InternalInstanceData: TSynWebInstance read FInstance;
property ActiveHighlighters: TSynWebHighlighterTypes read FActiveHighlighters
write FActiveHighlighters;
published
property ActiveHighlighterSwitch: Boolean
read FActiveHighlighter write SetActiveHighlighter;
property Engine: TSynWebEngine read FEngine write SetEngine;
end;
{ TSynWebMLSyn }
TSynWebMLSyn = class(TSynWebBase)
private
procedure SetupActiveHighlighter; override;
public
constructor Create(AOwner: TComponent); override;
procedure ResetRange; override;
end;
{ TSynWebHtmlSyn }
TSynWebHtmlSynClass = class of TSynWebHtmlSyn;
TSynWebHtmlSyn = class(TSynWebMLSyn)
private
function GetOptions: TSynWebHtmlOptions;
procedure SetOptions(const AValue: TSynWebHtmlOptions);
public
class function GetLanguageName: string; override;
{$IFDEF UNISYNEDIT}
class function GetFriendlyLanguageName: UnicodeString; override;
class function SynWebSample: UnicodeString; override;
{$ELSE}
class function SynWebSample: String; override;
{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
published
property Options: TSynWebHtmlOptions read GetOptions write SetOptions;
end;
{ TSynWebSmartySyn }
TSynWebSmartySynClass = class of TSynWebSmartySyn;
TSynWebSmartySyn = class(TSynWebMLSyn)
private
function GetOptions: TSynWebSmartyOptions;
procedure SetOptions(const AValue: TSynWebSmartyOptions);
public
class function GetLanguageName: string; override;
{$IFDEF UNISYNEDIT}
class function SynWebSample: UnicodeString; override;
{$ELSE}
class function SynWebSample: String; override;
{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
published
property Options: TSynWebSmartyOptions read GetOptions write SetOptions;
end;
{ TSynWebWmlSyn }
TSynWebWmlSynClass = class of TSynWebWmlSyn;
TSynWebWmlSyn = class(TSynWebMLSyn)
private
function GetOptions: TSynWebWmlOptions;
procedure SetOptions(const AValue: TSynWebWmlOptions);
public
class function GetLanguageName: string; override;
{$IFDEF UNISYNEDIT}
class function SynWebSample: UnicodeString; override;
{$ELSE}
class function SynWebSample: String; override;
{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
published
property Options: TSynWebWmlOptions read GetOptions write SetOptions;
end;
{ TSynWebXsltSyn }
TSynWebXsltSynClass = class of TSynWebXsltSyn;
TSynWebXsltSyn = class(TSynWebMLSyn)
private
function GetOptions: TSynWebXsltOptions;
procedure SetOptions(const AValue: TSynWebXsltOptions);
public
class function GetLanguageName: string; override;
{$IFDEF UNISYNEDIT}
class function SynWebSample: UnicodeString; override;
{$ELSE}
class function SynWebSample: String; override;
{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
published
property Options: TSynWebXsltOptions read GetOptions write SetOptions;
end;
{ TSynWebXmlSyn }
TSynWebXmlSynClass = class of TSynWebXmlSyn;
TSynWebXmlSyn = class(TSynWebMLSyn)
private
function GetOptions: TSynWebXmlOptions;
procedure SetOptions(const AValue: TSynWebXmlOptions);
public
class function GetLanguageName: string; override;
{$IFDEF UNISYNEDIT}
class function GetFriendlyLanguageName: UnicodeString; override;
class function SynWebSample: UnicodeString; override;
{$ELSE}
class function SynWebSample: String; override;
{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
published
property Options: TSynWebXmlOptions read GetOptions write SetOptions;
end;
{ TSynWebCssSyn }
TSynWebCssSynClass = class of TSynWebCssSyn;
TSynWebCssSyn = class(TSynWebBase)
private
procedure SetupActiveHighlighter; override;
function GetOptions: TSynWebCssOptions;
procedure SetOptions(const AValue: TSynWebCssOptions);
public
class function GetLanguageName: string; override;
{$IFDEF UNISYNEDIT}
class function GetFriendlyLanguageName: UnicodeString; override;
class function SynWebSample: UnicodeString; override;
{$ELSE}
class function SynWebSample: String; override;
{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
procedure ResetRange; override;
published
property Options: TSynWebCssOptions read GetOptions write SetOptions;
end;
{ TSynWebEsSyn }
TSynWebEsSynClass = class of TSynWebEsSyn;
TSynWebEsSyn = class(TSynWebBase)
private
procedure SetupActiveHighlighter; override;
function GetOptions: TSynWebEsOptions;
procedure SetOptions(const AValue: TSynWebEsOptions);
public
class function GetLanguageName: string; override;
{$IFDEF UNISYNEDIT}
class function GetFriendlyLanguageName: UnicodeString; override;
class function SynWebSample: UnicodeString; override;
{$ELSE}
class function SynWebSample: String; override;
{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
procedure ResetRange; override;
published
property Options: TSynWebEsOptions read GetOptions write SetOptions;
end;
{ TSynWebPhpCliSyn }
TSynWebPhpCliSynClass = class of TSynWebPhpCliSyn;
TSynWebPhpCliSyn = class(TSynWebBase)
private
procedure SetupActiveHighlighter; override;
function GetOptions: TSynWebPhpCliOptions;
procedure SetOptions(const AValue: TSynWebPhpCliOptions);
public
class function GetLanguageName: string; override;
{$IFDEF UNISYNEDIT}
class function SynWebSample: UnicodeString; override;
{$ELSE}
class function SynWebSample: String; override;
{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
procedure ResetRange; override;
published
property Options: TSynWebPhpCliOptions read GetOptions write SetOptions;
end;
{ TSynWebPhpPlainSyn }
TSynWebPhpPlainSynClass = class of TSynWebPhpPlainSyn;
TSynWebPhpPlainSyn = class(TSynWebBase)
private
procedure SetupActiveHighlighter; override;
function GetOptions: TSynWebPhpPlainOptions;
procedure SetOptions(const AValue: TSynWebPhpPlainOptions);
public
class function GetLanguageName: string; override;
{$IFDEF UNISYNEDIT}
class function GetFriendlyLanguageName: UnicodeString; override;
class function SynWebSample: UnicodeString; override;
{$ELSE}
class function SynWebSample: String; override;
{$ENDIF}
public
constructor Create(AOwner: TComponent); override;
procedure ResetRange; override;
published
property Options: TSynWebPhpPlainOptions read GetOptions write SetOptions;
end;
{ TSynWebEngineSpecialAttributes }
TSynWebSpecialAttriute = (swsaPhpVarPrefix, swsaPhpMarker, swsaTagScript, swsaTagStyle);
TSynWebSpecialAttriutes = set of TSynWebSpecialAttriute;
TSynWebEngineSpecialAttributes = class(TPersistent)
private
FEngine: TSynWebEngine;
FOptions: TSynWebSpecialAttriutes;
FInactiveOptions: TSynWebSpecialAttriutes;
FAttributes: array[TSynWebSpecialAttriute] of TSynHighlighterAttributes;
procedure SetOptions(AOptions: TSynWebSpecialAttriutes);
procedure SetInactiveOptions(AOptions: TSynWebSpecialAttriutes);
procedure SetAttribute(AIndex: Integer; const AAttribute: TSynHighlighterAttributes);
function GetAttribute(AIndex: Integer): TSynHighlighterAttributes;
public
constructor Create(AOwner: TSynWebEngine);
published
property Options: TSynWebSpecialAttriutes read FOptions write SetOptions default [swsaPhpMarker];
property InactiveOptions: TSynWebSpecialAttriutes read FInactiveOptions write SetInactiveOptions default [swsaPhpMarker];
property PhpVarPrefix: TSynHighlighterAttributes index 0 read GetAttribute write SetAttribute;
property PhpMarker: TSynHighlighterAttributes index 1 read GetAttribute write SetAttribute;
property TagScript: TSynHighlighterAttributes index 2 read GetAttribute write SetAttribute;
property TagStyle: TSynHighlighterAttributes index 3 read GetAttribute write SetAttribute;
end;
{ TSynWebEngine }
TSynWebEngine = class(TComponent)
private
// Global ------------------------------------------------------------------
FNotifyList: TList;
FInstance: PSynWebInstance;
FAttributes: TStringList;
FInactiveAttri: TSynHighlighterAttributes;
FTokenAttributeTable: TSynWebTokenAttributeTable;
FPhpHereDocList: TStringList;
FEngineOptions: TSynWebOptions;
FOptions: TSynWebEngineOptions;
FSpecialAttri: TSynWebEngineSpecialAttributes;
FIsSpecialAttribute: Boolean;
FSpecialAttribute: TSynWebSpecialAttriute;
// Markup Language ---------------------------------------------------------
FMLTagIdentFuncTable: array[0..MLTagMaxKeyHash] of TSynWebIdentFuncTableFunc;
FMLAttrIdentFuncTable: array[0..MLAttrMaxKeyHash] of TSynWebIdentFuncTableFunc;
FMLSpecialIdentFuncTable: array[0..MLSpecialMaxKeyHash] of TSynWebIdent2FuncTableFunc;
FMLRangeProcTable: array[Low(TSynWebMLRangeState)..High(TSynWebMLRangeState)] of TSynWebProcTableProc;
FMLWhitespaceAttri: TSynHighlighterAttributes;
FMLCommentAttri: TSynHighlighterAttributes;
FMLTextAttri: TSynHighlighterAttributes;
FMLEscapeAttri: TSynHighlighterAttributes;
FMLSymbolAttri: TSynHighlighterAttributes;
FMLTagAttri: TSynHighlighterAttributes;
FMLTagNameAttri: TSynHighlighterAttributes;
FMLTagNameUndefAttri: TSynHighlighterAttributes;
FMLTagKeyAttri: TSynHighlighterAttributes;
FMLTagKeyUndefAttri: TSynHighlighterAttributes;
FMLTagKeyValueAttri: TSynHighlighterAttributes;
FMLTagKeyValueQuotedAttri: TSynHighlighterAttributes;
FMLErrorAttri: TSynHighlighterAttributes;
// Css ---------------------------------------------------------------------
FCssProcTable: array[AnsiChar] of TSynWebProcTableProc;
FCssPropIdentFuncTable: array[0..CssPropMaxKeyHash] of TSynWebIdentFuncTableFunc;
FCssValIdentFuncTable: array[0..CssValMaxKeyHash] of TSynWebIdentFuncTableFunc;
FCssSpecialIdentFuncTable: array[0..CssSpecialMaxKeyHash] of TSynWebIdent2FuncTableFunc;
FCssRangeProcTable: array[Low(TSynWebCssRangeState)..High(TSynWebCssRangeState)] of TSynWebProcTableProc;
FCssWhitespaceAttri: TSynHighlighterAttributes;
FCssRulesetWhitespaceAttri: TSynHighlighterAttributes;
FCssSelectorAttri: TSynHighlighterAttributes;
FCssSelectorUndefAttri: TSynHighlighterAttributes;
FCssSelectorClassAttri: TSynHighlighterAttributes;
FCssSelectorIdAttri: TSynHighlighterAttributes;
FCssSpecialAttri: TSynHighlighterAttributes;
FCssCommentAttri: TSynHighlighterAttributes;
FCssPropAttri: TSynHighlighterAttributes;
FCssPropUndefAttri: TSynHighlighterAttributes;
FCssValAttri: TSynHighlighterAttributes;
FCssValUndefAttri: TSynHighlighterAttributes;
FCssValStringAttri: TSynHighlighterAttributes;
FCssValNumberAttri: TSynHighlighterAttributes;
FCssSymbolAttri: TSynHighlighterAttributes;
FCssErrorAttri: TSynHighlighterAttributes;
FOnCssCheckVendorProperty: TSynWebCssCheckVendorPropertyEvent;
FOnCssCheckVendorValue: TSynWebCssCheckVendorValueEvent;
FOnCssGetVendorPropertyFlags: TSynWebCssGetVendorPropertyFlagsEvent;
// ECMAScript --------------------------------------------------------------
FEsProcTable: array[AnsiChar] of TSynWebProcTableProc;
FEsIdentFuncTable: array[0..EsKeywordsMaxKeyHash] of TSynWebIdentFuncTableFunc;
FEsRangeProcTable: array[Low(TSynWebEsRangeState)..High(TSynWebEsRangeState)] of TSynWebProcTableProc;
FEsWhitespaceAttri: TSynHighlighterAttributes;
FEsIdentifierAttri: TSynHighlighterAttributes;
FEsKeyAttri: TSynHighlighterAttributes;
FEsCommentAttri: TSynHighlighterAttributes;
FEsStringAttri: TSynHighlighterAttributes;
FEsNumberAttri: TSynHighlighterAttributes;
FEsSymbolAttri: TSynHighlighterAttributes;
FEsErrorAttri: TSynHighlighterAttributes;
// Php ---------------------------------------------------------------------
FPhpProcTable: array[AnsiChar] of TSynWebProcTableProc;
FPhpIdentFuncTable: array[0..PhpKeywordsMaxKeyHash] of TSynWebIdentFuncTableFunc;
FPhpRangeProcTable: array[Low(TSynWebPhpRangeState)..High(TSynWebPhpRangeState)] of TSynWebProcTableProc;
FPhpWhitespaceAttri: TSynHighlighterAttributes;
FPhpInlineTextAttri: TSynHighlighterAttributes;
FPhpIdentifierAttri: TSynHighlighterAttributes;
FPhpKeyAttri: TSynHighlighterAttributes;
FPhpFunctionAttri: TSynHighlighterAttributes;
FPhpVariableAttri: TSynHighlighterAttributes;
FPhpConstAttri: TSynHighlighterAttributes;
FPhpMethodAttri: TSynHighlighterAttributes;
FPhpStringAttri: TSynHighlighterAttributes;
FPhpStringSpecialAttri: TSynHighlighterAttributes;
FPhpCommentAttri: TSynHighlighterAttributes;
FPhpDocCommentAttri: TSynHighlighterAttributes;
FPhpDocCommentTagAttri: TSynHighlighterAttributes;
FPhpSymbolAttri: TSynHighlighterAttributes;
FPhpNumberAttri: TSynHighlighterAttributes;
FPhpErrorAttri: TSynHighlighterAttributes;
// MarkupLanguage ----------------------------------------------------------
procedure MLMakeMethodTables;
procedure MLNext;
function MLGetRange: TSynWebMLRangeState;
procedure MLSetRange(const ARange: TSynWebMLRangeState);
function MLGetTag: Integer;
procedure MLSetTag(const ATag: Integer);
function MLCheckNull(ADo: Boolean = True): Boolean;
procedure MLSpaceProc;
procedure MLAmpersandProc;
procedure MLBraceOpenProc;
procedure MLErrorProc;
procedure MLBraces;
procedure MLRangeTextProc;
procedure MLRangeCommentProc;
procedure MLRangeCommentCloseProc;
procedure MLRangeTagDOCTYPEProc;
procedure MLRangeTagCDATAProc;
procedure MLRangeTagProc;
procedure MLRangeTagCloseProc;
procedure MLRangeTagKeyProc;
procedure MLRangeTagKeyEqProc;
procedure MLRangeTagKeyValueProc;
procedure MLRangeTagKeyValueQuoted1Proc;
procedure MLRangeTagKeyValueQuoted2Proc;
function MLTagKeyComp(const ID: Integer): Boolean;
function MLTagCheck: TSynWebTokenKind;
{$I SynHighlighterWeb_TagsFuncList.inc}
function MLAttrKeyComp(const ID: Integer): Boolean;
function MLAttrCheck: TSynWebTokenKind;
{$I SynHighlighterWeb_AttrsFuncList.inc}
function MLSpecialKeyComp(const ID: Integer): Boolean;
function MLSpecialCheck(AStart, ALen: Integer): Integer;
{$I SynHighlighterWeb_SpecialFuncList.inc}
// Css ---------------------------------------------------------------------
procedure CssMakeMethodTables;
procedure CssNextBg;
procedure CssNext;
procedure CssUpdateBg;
function CssGetRange: TSynWebCssRangeState;
procedure CssSetRange(const ARange: TSynWebCssRangeState);
function CssGetProp: Integer;
function CssIsPropVendor: Boolean;
procedure CssSetProp(const AProp: Integer);
procedure CssSetPropVendor;
function CssCheckPropData(ABit: Byte): Boolean;
function CssCheckNull(ADo: Boolean = True): Boolean;
procedure CssCheckVendor(var AIsVendor: Boolean);
procedure CssSpaceProc;
procedure CssAtKeywordProc;
procedure CssSlashProc;
procedure CssBraceOpenProc;
procedure CssCurlyBraceOpenProc;
procedure CssCurlyBraceCloseProc;
procedure CssSelectorsProc;
procedure CssAttribProc;
procedure CssHashProc;
procedure CssDotProc;
procedure CssCommaProc;
procedure CssColonProc;
procedure CssSemiColonProc;
procedure CssExclamationProc;
procedure CssStringProc;
procedure CssPlusProc;
procedure CssMinusProc;
procedure CssNumberProc;
procedure CssNumberDefProc(APropValue: Boolean = True);
procedure CssIdentProc;
function CssIdentStartProc: Boolean;
function CssCustomStringProc(AShl: Longword; ADo: Boolean = True): Boolean;
function CssNotWhitespace: Boolean;
procedure CssSymbolProc;
procedure CssErrorProc;
procedure CssRangeRulesetProc;
procedure CssRangeSelectorAttribProc;
procedure CssRangeSelectorPseudoProc;
procedure CssRangeAtKeywordProc;
procedure CssRangePropProc;
procedure CssRangePropValProc;
procedure CssRangePropValStrProc;
procedure CssRangePropValRgbProc;
procedure CssRangePropValFuncProc;
procedure CssRangePropValSpecialProc;
procedure CssRangePropValImportantProc;
procedure CssRangePropValUrlProc;
procedure CssRangePropValRectProc;
procedure CssRangeCommentProc;
function CssPropKeyComp(const ID: Integer): Boolean;
function CssPropCheck: TSynWebTokenKind;
{$I SynHighlighterWeb_CssPropsFuncList.inc}
function CssValKeyComp(const ID: Integer): Boolean;
function CssValCheck: TSynWebTokenKind;
{$I SynHighlighterWeb_CssValsFuncList.inc}
function CssSpecialKeyComp(const ID: Integer): Boolean;
function CssSpecialCheck(AStart, ALen: Integer): Integer;
{$I SynHighlighterWeb_CssSpecialFuncList.inc}
// ECMAScript --------------------------------------------------------------
procedure EsMakeMethodTables;
procedure EsNext;
function EsGetRange: TSynWebEsRangeState;
procedure EsSetRange(const ARange: TSynWebEsRangeState);
function EsCheckNull(ADo: Boolean = True): Boolean;
procedure EsSetSymbolId(ASymbolId: Integer);
procedure EsSpaceProc;
procedure EsSlashProc;
procedure EsLowerProc;
procedure EsEqualProc;
procedure EsNotProc;
procedure EsGreaterProc;
procedure EsAndProc;
procedure EsPlusProc;
procedure EsMinusProc;
procedure EsOrProc;
procedure EsMulProc;
procedure EsModProc;
procedure EsXorProc;
procedure EsCurlyBraceOpenProc;
procedure EsCurlyBraceCloseProc;
procedure EsBoxBracketOpenProc;
procedure EsBoxBracketCloseProc;
procedure EsParentheseOpenProc;
procedure EsParentheseCloseProc;
procedure EsObjAccessProc;
procedure EsSemiColonProc;
procedure EsCommaProc;
procedure EsQuestionProc;
procedure EsColonProc;
procedure EsTildeProc;
procedure EsBackSlashProc;
procedure EsNumberProc;
procedure EsString34Proc;
procedure EsString39Proc;
procedure EsIdentProc;
procedure EsErrorProc;
procedure EsRangeDefaultProc;
procedure EsRangeCommentProc;
procedure EsRangeCommentMultiProc;
procedure EsRangeString34Proc;
procedure EsRangeString39Proc;
procedure EsRangeRegExpProc;
function EsKeywordComp(const ID: Integer): Boolean;
function EsIdentCheck: TSynWebTokenKind;
{$I SynHighlighterWeb_EsKeywordsFuncList.inc}
// Php ---------------------------------------------------------------------
procedure PhpMakeMethodTables;
procedure PhpNext;
procedure PhpCliNext;
function PhpGetRange: TSynWebPhpRangeState;
procedure PhpSetRange(const ARange: TSynWebPhpRangeState);
procedure PhpSetSymbolId(ASymbolId: Integer);
function PhpCheckBegin(ABegin: Boolean = True): Boolean;
procedure PhpBegin(ATagKind: TSynWebPhpOpenTag);
procedure PhpEnd(AMLTag: Boolean);
function CheckSmartyBegin: Boolean;
function CheckSmartyEnd: Boolean;
procedure PhpSpaceProc;
procedure PhpQuestionProc;
procedure PhpNumberProc;
function PhpCheckNumberProc: Boolean;
procedure PhpString34Proc;
procedure PhpString39Proc;
procedure PhpStringShellProc;
procedure PhpAndProc;
procedure PhpOrProc;
procedure PhpAtSymbolProc;
procedure PhpEqualProc;
procedure PhpGreaterProc;
procedure PhpLowerProc;
procedure PhpPlusProc;
procedure PhpMinusProc;
procedure PhpMulProc;
procedure PhpDivProc;
procedure PhpModProc;
procedure PhpXorProc;
procedure PhpSlashProc;
procedure PhpBackslashProc;
procedure PhpPercentProc;
procedure PhpHashProc;
procedure PhpNotProc;
procedure PhpDotProc;
procedure PhpColonProc;
procedure PhpParentheseOpenProc;
procedure PhpParentheseCloseProc;