summaryrefslogtreecommitdiffstats
path: root/kate/data/d.xml
blob: d40c413a3cfeefaf7f18ea3a763efa000d352fd2 (plain)
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!--
  ========================================================================

  D.XML supports syntax highlighting for the D programming language under Kate.

  Updated 2007-2008 - Diggory Hardy <[email protected]> (copyright kate project).
  Copyright (C) 2007 - Aziz Köksal <[email protected]>
  Copyright (C) 2007 - Jari-Matti Mäkelä <[email protected]>
  Copyright (C) 2004 - Simon J Mackenzie <[email protected]>

  This code is released under the LGPL as part of tdelibs/kate.

  ========================================================================

  D is a next generation language written by Walter Bright of Digital Mars fame.
  Digital Mars C, C++ and D Compilers can be obtained from http://www.digitalmars.com/d/

  ========================================================================

  UPDATE HISTORY:-
  2008.09.22 - d.xml 1.61 - D 1.035/2.019 - Fix for identifiers starting _ and containing numbers.
  2008.08.01 - d.xml 1.60 - D 1.033/2.017 - Merging ddoc.xml 1.14 since there is no advantage to having it separate.
  2008.07.14 - uncommited                 - Added properties: .tupleof, .offsetof
  2008.06.14 - D.XML 1.53 - D 1.030/2.014 - Added user keyword highlighting.
  2008.06.06 - D.XML 1.53 - D 1.030/2.014 - Small fix involving floats starting . in embedded Ddoc.
                                          - Added nothrow and pure attributes (D2.0 only).
  2008.04.09 - D.XML 1.52 - D 1.028/2.012 - Added properties (especially for arrays).
                                          - Added rules for C-Style indenter (thanks vektorboson!)
  2008.02.22 - D.XML 1.51 - D 1.027/2.011 - Changed char rule behaviour on line end.
                                          - Added support for strings ending with c, w or d (must have got lost at some point).
  2008.02.22 - ddoc.xml 1.14              - Fixes/improvements for macros. Highlights first symbol and non-symbols
                                            before as errors; matches embedded brackets () properly.
  2008.01.09 - D.XML 1.50 - D 1.025/2.009 - Changed pragma, version, deprecated matching to use keyword not DetectString.
  2007.12.18 - D.XML 1.49 - D 1.025/2.009 - Fixed some bugs to make the StartingLetter context exit correctly and match identifiers properly.
  2007.12.12 - D.XML 1.48 - D 1.024/2.008 - Adjusted existing contexts somewhat (mostly cleanup).
                                          - Implemented scope context to hightlight exit in scope(exit) etc.
                                          - Adjusted deprecated keyword highlighting.
                                          - Changed layout somewhat.
                                          - Implemented extra highlighting rules for expressions, attributes, etc.
                                          - Changed a lot of colours.
  2007.11.15 - D.XML 1.47 - D 1.023/2.007 - Fixed a few unapperent "bugs" found by checkdtd.
  2007.11.15 - ddoc.xml 1.13              - Fixed a couple of bugs found by checkdtd and changed the version number format.
  2007.11.5  - ddoc.xml 1.12              - Fixed: correct matching of things like /***/ .
  2007.10.11 - ddoc.xml 1.11              - Safety catch: check for unterminated code sections (i.e. check for end of
                                            ddoc comment even in code sections).
                                          - Used DetectIdentifier to (presumably) improve performance.
  2007.10.09 - uncommited - ditto         - Changed some context="#pop" tags to context="#stay" within the normal
                                            context (bugfix for ddoc embedded code highlighting).
  2007.10.9  - ddoc.xml 1.10              - Enabled embedded ddoc code highlighting
  2007.10.9  - ddoc.xml 1.00              - Initial version
  2007.10.08 - D.XML 1.46 - D 1.022/2.005 - Stole Alert and Region Marker highlighting from C++ syntax.
                                          - Added support for DDoc highlighting.
                                          - Reviewed the float regexps again! Tried to make the best of both versions.
  2007.09.17 - D.XML 1.45 - D 1.021/2.004 - Reverted back to old regexps (but fixed hex floats).
                                            Can't combine all float regexps into a single RegExpr element using the '|' operator.
                                            It creates strange problems (like program lock-ups and wrong matches).
                                          - Fix: '=' is allowed in import statements now.
                                          - Fix: character literals are matched correctly now.
                                          - The #line special token sequence is matched fully now (the filespec string needs special handling).
  2007.09.10 - D.XML 1.44 - D 1.021/2.004 - Added __EOF__ to specialtokens.
                                          - Replaced float regexps with more accurate ones. Not sure about speed.
                                          - Fixed Octal regexp not to match 0_ .
  2007.07.24 - D.XML 1.43 - D 1.020/2.003 - Added System to ltypes.
                                          - Improved matching of version declarations.
                                          - Fixed matching of hexadecimal floats.
                                          - Deprecated style is stroked out again.
  2007.07.21 - D.XML 1.42 - D 1.018/2.002 - d.xml validates again according to language.xml.
                                          - HTML entities are highlighted now.
                                          - Numbers before and after the slice operator are not highl. as floats anymore.
                                          - Added C++ to ltypes.
                                          - Improved matching of module/import declarations.
  2007.07.01 - D.XML 1.41 - D 1.017/2.001 - fixed matching of numbers, added deprecated style, minor changes to styles, updated authors line
  2007.07.01 - D.XML 1.40 - D 1.017/2.001 - matches now .di extensions, removed phobos-specific printf/writef and added
                                          - library defined symbols string, wstring, dstring, size_t, ptrdiff_t, hash_t,
                                          - Error, Exception, Object, TypeInfo and ClassInfo
  2007.06.30 - D.XML 1.39 - D 1.017 - matching is much faster now, added "lib" to pragma types, added special tokens,
                                    - /+ +/ can be nested now, numbers are matched more correctly, character literals don't span multiple lines anymore
                                    - escape sequences inside strings and character literals are highlighted,
                                    - non-hex characters in hex strings are highlighted with the Error style,
                                    - using more default styles instead of custom ones
  2007.04.11 - D.XML 1.38 - D 1.011 - ref, macro keywords are now supported, fixed \\ inside a string, updated author
  2007.02.12 - D.XML 1.37 - D 1.006 - bool, foreach_reverse, lazy, scope and typeid keywords are now supported, fixed \"
                                    - inside a string, fixed ending of wysiwyg strings.
  2004.08.15 - D.XML 1.36 - D 0.98  - Current release of D.
                                    - package, writef(strictly speaking writef isn't a keyword) - keywords are now supported.
  2004.??.?? - D.XML 1.35 - D 0.??  - Not sure how this release got posted!
  2004.05.23 - D.XML 1.34 - D 0.90  - updated.
  2004.05.19 - D.XML 1.33 - D 0.89  - mixin - keyword is now supported.
  2004.05.19 - D.XML 1.32 - D 0.77  - pragma, typeof - keywords are now supported.
  2004.05.19 - D.XML 1.31 - D 0.76  - is - keyword is now supported.
  2003.09.06 - D.XML 1.30 - D 0.71  - foreach - keyword is now supported.
  2003.08.18 - D.XML 1.20 - D 0.69  - floats are now supported.
                                    - embedded underscores in integer and float literals are now supported.
  2003.08.11 - D.XML 1.10           - updated.
  2003.07.18 - D.XML 1.00           - First released.

  TODO:- Deliminated strings and Token strings (D2.0) are not supported.

   ========================================================================
-->

<language name="D" version="1.62" kateversion="2.5" section="Sources" extensions="*.d;*.D;*.di;*.DI;" mimetype="text/x-dsrc" casesensitive="true" author="Diggory Hardy ([email protected]), Aziz Köksal ([email protected]), Jari-Matti Mäkelä ([email protected]), Simon J Mackenzie ([email protected])" license="LGPL">
  <highlighting>
    <!-- User-defined keywords (add identifiers you'd like highlighted here) -->
    <list name="userkeywords">
    </list>
    <list name="statements">
      <item> asm </item>
      <item> body </item>
      <item> break </item>
      <item> case </item>
      <item> catch </item>
      <item> continue </item>
      <item> default </item>
      <item> do </item>
      <item> else </item>
      <item> finally </item>
      <item> for </item>
      <item> foreach </item>
      <item> foreach_reverse </item>
      <item> goto </item>
      <item> if </item>
      <item> mixin </item>
      <item> return </item>
      <item> switch </item>
      <item> throw </item>
      <item> try </item>
      <item> while </item>
      <item> with </item>
      
      <!-- these are statements according to the spec, although I might call them attributes -->
      <item> synchronized </item>

    </list>

    <list name="attributes">
      <!-- also storage classes -->
      <item> abstract </item>
      <item> align </item>
      <item> auto </item>
      <item> const </item>
      <item> export </item>
      <item> final </item>
      <item> immutable </item>
      <item> inout </item>
      <item> invariant </item>
      <item> lazy </item>
      <item> nothrow </item>
      <item> override </item>
      <item> package </item>
      <item> private </item>
      <item> protected </item>
      <item> public </item>
      <item> pure </item>
      <item> ref </item>
      <item> static </item>
      
      <!-- these may be statements -->
      <!-- in (more common to use as an expression since in attribute is only ever the default) -->
      <item> out </item>
      <item> scope </item>
    </list>
    
    <list name="expressions">
      <!-- primary expressions -->
      <item> false </item>
      <item> null </item>
      <item> super </item>
      <item> this </item>
      <item> true </item>
      <item> typeid </item>
      
      <!-- other expressions -->
      <item> assert </item>
      <item> cast </item>
      <item> is </item>
      <item> new </item>
      <item> delete </item>
      <item> in </item> <!-- also an attribute and a statement -->
      
      <!-- sometimes declarators -->
      <item> delegate </item>
      <item> function </item>
    </list>
    
    <list name="modules">
      <item> module </item>
      <item> import </item> <!-- also an expression -->
    </list>

    <list name="declarators">
      <item> alias </item>
      <item> enum </item>
      <item> typedef </item>
      <item> class </item>
      <item> interface </item>
      <item> struct </item>
      <item> union </item>
    </list>
    
    <list name="types">
      <item> typeof </item>
      
      <item> void </item>
      <item> bool </item>
      <item> byte </item>
      <item> ubyte </item>
      <item> short </item>
      <item> ushort </item>
      <item> int </item>
      <item> uint </item>
      <item> long </item>
      <item> ulong </item>
      <item> cent </item>
      <item> ucent </item>
      <item> float </item>
      <item> double </item>
      <item> real </item>
      <item> ireal </item>
      <item> ifloat </item>
      <item> idouble </item>
      <item> creal </item>
      <item> cfloat </item>
      <item> cdouble </item>
      <item> char </item>
      <item> wchar </item>
      <item> dchar </item>
    </list>

    <list name="templates">
      <item> macro </item> <!-- what's this? just reserved? -->
      <item> template </item>
    </list>
    
    <list name="properties">
      <item> init </item>
      <item> sizeof </item>
      <item> alignof </item>
      <item> mangleof </item>
      <item> stringof </item>
      <item> tupleof </item>
      <item> offsetof </item>
      <item> max </item>
      <item> min </item>
      <item> infinity </item>
      <item> nan </item>
      <item> dig </item>
      <item> epsilon </item>
      <item> mant_dig </item>
      <item> max_10_exp </item>
      <item> max_exp </item>
      <item> min_10_exp </item>
      <item> min_exp </item>
      <item> re </item>
      <item> im </item>
      <item> length </item>
      <item> ptr </item>
      <item> dup </item>
      <item> idup </item>
      <item> reverse </item>
      <item> sort </item>
      <item> keys </item>
      <item> values </item>
      <item> rehash </item>
    </list>
    
    <list name="libsymbols">
      <!-- these are only symbols defined in object.d(i) -->
      <item> size_t </item>
      <item> ptrdiff_t </item>
      <item> hash_t </item>
      <item> Error </item>
      <item> Exception </item>
      <item> Object </item>
      <item> TypeInfo </item>
      <item> ClassInfo </item>
      <item> ModuleInfo </item>
      <item> Interface </item>
      <item> OffsetTypeInfo </item>
      <item> TypeInfo_Typedef </item>
      <item> TypeInfo_Enum </item>
      <item> TypeInfo_Pointer </item>
      <item> TypeInfo_Array </item>
      <item> TypeInfo_StaticArray </item>
      <item> TypeInfo_AssociativeArray </item>
      <item> TypeInfo_Function </item>
      <item> TypeInfo_Delegate </item>
      <item> TypeInfo_Class </item>
      <item> TypeInfo_Interface </item>
      <item> TypeInfo_Struct </item>
      <item> TypeInfo_Tuple </item>
      
      <!-- phobos only as of tango 0.99.3 -->
      <item> string </item>
      <item> wstring </item>
      <item> dstring </item>
      <item> bit </item>
      <item> TypeInfo_Const </item>
      <item> TypeInfo_Invariant </item>
    </list>

    <list name="linkage">
      <item> extern </item>
    </list>
    <list name="ltypes">
      <item> C </item>
      <!-- <item> C++ </item> --><!-- is handled specially in Linkage rule -->
      <item> D </item>
      <item> Windows </item>
      <item> Pascal </item>
      <item> System </item>
    </list>

    <list name="ptypes">
      <item> msg </item>
      <item> lib </item>
    </list>
    
    <list name="scope_keywords">
      <item> exit </item>
      <item> success </item>
      <item> failure </item>
    </list>

    <list name="vtypes">
      <item> DigitalMars </item>
      <item> X86 </item>
      <item> X86_64 </item>
      <item> Windows </item>
      <item> Win32 </item>
      <item> Win64 </item>
      <item> linux </item>
      <item> LittleEndian </item>
      <item> BigEndian </item>
      <item> D_Coverage </item>
      <item> D_InlineAsm_X86 </item>
      <item> unittest </item>
      <item> D_Version2 </item>
      <item> none </item>
      <item> all </item>
    </list>

    <list name="specialtokens">
      <item> __FILE__ </item>
      <item> __LINE__ </item>
      <item> __DATE__ </item>
      <item> __TIME__ </item>
      <item> __TIMESTAMP__ </item>
      <item> __VENDOR__ </item>
      <item> __VERSION__ </item>
      <item> __EOF__ </item>
    </list>
    
    <list name="tests">
      <item> debug </item>
      <item> unittest </item>
    </list>
    
    <list name="pragma">
        <item> pragma </item>
    </list>

    <list name="version">
        <item> version </item>
    </list>
    
    <list name="deprecated">
        <item> deprecated </item>
        <item> volatile </item> <!-- has been deprecated -->
    </list>
    
    <contexts>
      <context name="normal" attribute="Normal Text" lineEndContext="#stay">
        <DetectSpaces />
        <!-- Performance improvement (probably): anything starting with a letter is matched separately -->
        <RegExpr String="[a-zA-Z_]" attribute="Normal Text" context="StartingLetter" lookAhead="true"/>

        <HlCStringChar attribute="EscapeSequence" context="#stay"/>
        <Detect2Chars attribute="EscapeSequence" context="UnicodeShort"   char="\" char1="u"/>
        <Detect2Chars attribute="EscapeSequence" context="UnicodeLong"   char="\" char1="U"/>
        <Detect2Chars attribute="EscapeSequence" context="HTMLEntity"   char="\" char1="&amp;"/>

        <DetectChar attribute="Char"     context="CharLiteral" char="'"/>
        <DetectChar attribute="String"   context="String"      char="&quot;"/>
        <DetectChar attribute="BQString" context="BQString"    char="`"/>

        <StringDetect attribute="Region Marker" context="Region Marker" String="//BEGIN" beginRegion="Region1" firstNonSpace="true" />
        <StringDetect attribute="Region Marker" context="Region Marker" String="//END" endRegion="Region1" firstNonSpace="true" />
        <IncludeRules context="CommentRules" />

        <!-- Match ... and .. before numbers are matched. -->
        <!-- Now in symbols keywords section	-->
        <StringDetect attribute="Normal Text" context="#stay" String="..."/>
        <Detect2Chars attribute="Normal Text"   char="." char1="."/>
        
        <!-- Float starting with a dot -->
        <RegExpr attribute="Float" context="#stay" String="\.\d[\d_]*([eE][-+]?\d[\d_]*)?[fFL]?i?"/>
        
        <!-- Try to match various built-in properties -->
        <DetectChar char="." attribute="Normal Text" context="Properties"/>

        <!-- Look ahead for a digit and switch to NumberLiteral context if found. -->
        <RegExpr context="NumberLiteral" String="\d" attribute="" lookAhead="true"/>

        <!-- #line Integer [Filespec] -->
        <StringDetect attribute="Pragma" context="LinePragma" String="#line"/>
        
        <!-- Rules for the C-style indenter. Currently problems with /// and /++ comments. -->
        <DetectChar attribute="Symbol" context="#stay" char="{" beginRegion="BraceA" />
        <DetectChar attribute="Symbol" context="#stay" char="}" endRegion="BraceA" />
        <AnyChar attribute="Symbol" context="#stay" String=":!%&amp;()+,-/.*&lt;=&gt;?[]|~^&#59;"/>
      </context>

      <context name="StartingLetter" attribute="Normal Text" lineEndContext="#pop">
          <DetectSpaces />
          <!-- fall-through should work now that DetectIdentifier is used (without infinite loops) -->
          <!-- maybe not... got an infinite loop -->
          <RegExpr String="[^a-zA-Z_]" attribute="Normal Text" context="#pop" lookAhead="true"/>
          
          <!-- detect whether scope, in, out, etc. are used as attributes or statements (etc.) -->
          <!-- rules cannot match across newlines unfortunately -->
          <RegExpr String="in\s*(?=\{)"    attribute="Statement"       context="#stay"     />
          <RegExpr String="out\s*(?=(\(([a-zA-Z_][\w_]*)?\)\s*)?\{)" attribute="Statement" context="#stay" />
          <RegExpr String="scope\s*(?=\()" attribute="Statement"       context="Scope"     />
          <RegExpr String="import\s*(?=\()" attribute="Expression"     context="#stay"     />
          <RegExpr String="function\s*(?=\()" attribute="Declarator"   context="#stay"     />
          <RegExpr String="delegate\s*(?=\()" attribute="Declarator"   context="#stay"     />
          
          <keyword String="statements"      attribute="Statement"      context="#stay"     />
          <keyword String="attributes"      attribute="Attribute"      context="#stay"     />
          <keyword String="expressions"     attribute="Expression"     context="#stay"     />
          <keyword String="declarators"     attribute="Declarator"     context="#stay"     />
          <keyword String="templates"       attribute="Template"       context="#stay"     />
          <keyword String="modules"         attribute="Module"         context="ModuleName"/>
          <keyword String="types"           attribute="Type"           context="#stay"     />
          <keyword String="libsymbols"      attribute="LibrarySymbols" context="#stay"     />
          <keyword String="linkage"         attribute="Linkage"        context="Linkage"   />
          <keyword String="specialtokens"   attribute="SpecialTokens"  context="#stay"     />
          <keyword String="tests"           attribute="Tests"          context="#stay"     />
          <!-- These must use keyword not DetectString: DetectString does not check for word-break after string. -->
          <keyword String="pragma"          attribute="Pragma"         context="Pragma"    />
          <keyword String="version"         attribute="Version"        context="Version"   />
          <keyword String="deprecated"      attribute="Deprecated"     context="#stay"     />
          
          <Detect2Chars attribute="RawString" context="RawString" char="r" char1="&quot;"/>
          <Detect2Chars attribute="HexString" context="HexString" char="x" char1="&quot;"/>
          
          <!-- user highlighting: last so as not to interfere with anything else -->
          <keyword String="userkeywords"    attribute="UserKeywords"   context="#stay"     />
          
          <DetectIdentifier />
      </context>
      
      <context name="Properties" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop">
        <keyword String="properties" attribute="Property" context="#pop" />
      </context>
      <context name="NumberLiteral" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop">
        <!-- Float literals -->
        <!-- Floats must be matched before Binary|Octal|Hex|DecInteger -->
        <RegExpr attribute="Float" context="#pop" String="0[xX][\da-fA-F_]*(\.[\da-fA-F_]*)?[pP][-+]?\d[\d_]*[fFL]?i?"/>
        <!-- Float starting with a dot is matched in main context -->
        <!-- All floats except integers -->
        <!-- RegExpr is branched rather than using look aheads for efficiency at the expense of extra length -->
        <RegExpr attribute="Float" context="#pop" String="\d[_\d]*(\.(?!\.)[_\d]*([eE][-+]?\d[_\d]*)?[fFL]?i?|[eE][-+]?\d[_\d]*[fFL]?i?|[fF]i?|[fFL]?i)"/>
        
        <!-- Binary|Octal|Hex|DecInteger -->
        <!-- Common, optional suffix: (L[uU]?|[uU]L?)? -->
        <RegExpr attribute="Binary"  context="#pop" String="0[bB]_*[01][01_]*(L[uU]?|[uU]L?)?"/>
        <!-- Octal must be matched before DecInteger -->
        <RegExpr attribute="Octal"   context="#pop" String="0[0-7_]+(L[uU]?|[uU]L?)?"/>
        <RegExpr attribute="Hex"     context="#pop" String="0[xX]_*[\da-fA-F][\da-fA-F_]*(L[uU]?|[uU]L?)?"/>
        <!-- Decimal integers must be matched last -->
        <RegExpr attribute="Integer" context="#pop" String="\d+[\d_]*(L[uU]?|[uU]L?)?"/>
      </context>

      <context name="LinePragma" attribute="Pragma" lineEndContext="#pop">
        <DetectSpaces/>
        <!-- Match an Integer -->
        <RegExpr attribute="Integer" context="#stay" String="((0([0-7_]+|[bB]_*[01][01_]*|[xX]_*[\da-fA-F][\da-fA-F_]*))|\d+[\d_]*)(L[uU]?|[uU]L?)?"/>
        <RegExpr attribute="String" context="#stay" String="&quot;[^&quot;]*&quot;"/>
        <keyword attribute="SpecialTokens"  context="#stay"      String="specialtokens"/>
        <IncludeRules context="CommentRules" />
        <RegExpr attribute="Error" context="#pop" String=".+"/>
      </context>

      <!-- \u 4HexDigits -->
      <context name="UnicodeShort" attribute="EscapeSequence" lineEndContext="#pop">
        <RegExpr attribute="EscapeSequence" context="#pop" String="[\da-fA-F]{4}"/>
      </context>
      <!-- \U 8HexDigits -->
      <context name="UnicodeLong" attribute="EscapeSequence" lineEndContext="#pop">
        <RegExpr attribute="EscapeSequence" context="#pop" String="[\da-fA-F]{8}"/>
      </context>
      <!-- \& Alpha Alphanumerical+ ; -->
      <context name="HTMLEntity" attribute="EscapeSequence" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
        <RegExpr attribute="EscapeSequence" context="#pop" String="[a-zA-Z]\w+;"/>
      </context>

      <context name="ModuleName" attribute="Module Name" lineEndContext="#stay">
        <DetectSpaces/>
        <IncludeRules context="CommentRules" />
        <RegExpr context="#pop" String="[^\s\w.:,=]" lookAhead="true"/>
      </context>

      <context name="Linkage" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop">
        <DetectSpaces/>
        <DetectChar attribute="Normal Text" context="Linkage2" char="("/>
        <IncludeRules context="CommentRules" />
      </context>
      <context name="Linkage2" attribute="Normal Text" lineEndContext="#stay">
        <DetectSpaces/>
        <StringDetect attribute="Linkage Type" context="#pop#pop" String="C++"/>
        <keyword    attribute="Linkage Type" context="#pop#pop" String="ltypes"/>
        <IncludeRules context="CommentRules" />
        <!-- Fall-through rules, highlighting errors: -->
        <DetectChar char=")" attribute="Normal Text" context="#pop#pop"/>
        <RegExpr String="[^)\s\n]+" attribute="Error" context="#pop#pop"/>
      </context>

      <context name="Version" attribute="Normal Text" lineEndContext="#stay">
        <DetectSpaces/>
        <DetectChar attribute="Normal Text"  context="Version2"  char="="/>
        <DetectChar attribute="Normal Text"  context="Version2" char="("/>
        <IncludeRules context="CommentRules" />
        <!-- Fall-through rules, highlighting errors: -->
        <RegExpr String="[^\s\n]+" attribute="Error" context="#pop"/>
      </context>
      <context name="Version2" attribute="Normal Text" lineEndContext="#stay">
        <DetectSpaces/>
        <keyword    attribute="Version Type" context="#pop#pop" String="vtypes"/>
        <DetectIdentifier attribute="Normal Text" context="#pop#pop"/>
        <RegExpr attribute="Integer" context="#pop#pop" String="\d+[\d_]*(L[uU]?|[uU]L?)?"/>
        <IncludeRules context="CommentRules" />
        <!-- Fall-through rules, highlighting errors: -->
        <DetectChar char=")" attribute="Normal Text" context="#pop#pop"/>
        <RegExpr String="[^)\s\n]+" attribute="Error" context="#pop#pop"/>
      </context>
      
      <context name="Scope" attribute="Normal Text" lineEndContext="#stay" fallthrough="true" fallthroughContext="#pop">
        <DetectSpaces/>
        <DetectChar attribute="Normal Text" context="Scope2" char="("/>
        <IncludeRules context="CommentRules" />
      </context>
      <context name="Scope2" attribute="Normal Text" lineEndContext="#stay">
        <DetectSpaces/>
        <keyword String="scope_keywords" attribute="Expression" context="#pop#pop"/>
        <IncludeRules context="CommentRules" />
        <!-- Fall-through rules, highlighting errors: -->
        <DetectChar char=")" attribute="Normal Text" context="#pop#pop"/>
        <RegExpr String="[^)\s\n]+" attribute="Error" context="#pop#pop"/>
      </context>

      <context name="Pragma" attribute="Pragma" lineEndContext="#stay">
        <DetectSpaces/>
        <DetectChar attribute="Normal Text"  context="Pragma2" char="("/>
        <IncludeRules context="CommentRules" />
        <!-- Fall-through rules, highlighting errors: -->
        <RegExpr String="[^\s\n]+" attribute="Error" context="#pop"/>
      </context>
      <context name="Pragma2" attribute="Pragma" lineEndContext="#stay">
        <DetectSpaces/>
        <keyword    attribute="Version Type" context="#pop#pop" String="ptypes"/>
        <DetectIdentifier attribute="Normal Text" context="#pop#pop"/>
        <IncludeRules context="CommentRules" />
        <!-- Fall-through rules, highlighting errors: -->
        <DetectChar char=")" attribute="Normal Text" context="#pop#pop"/>
        <RegExpr String="[^)\s\n]+" attribute="Error" context="#pop#pop"/>
      </context>

      <!-- Strings -->
      <!-- r"..." -->
      <context name="RawString" attribute="RawString" lineEndContext="#stay">
        <DetectChar attribute="RawString" context="#pop" char="&quot;"/>
      </context>
      <!-- `...` -->
      <context name="BQString" attribute="BQString" lineEndContext="#stay">
        <DetectChar attribute="BQString" context="#pop" char="`"/>
      </context>
      <!-- x"..." -->
      <context name="HexString" attribute="HexString" lineEndContext="#stay">
        <DetectChar attribute="HexString" context="#pop" char="&quot;"/>
        <RegExpr attribute="Error" context="#stay" String="[^\sa-fA-F\d&quot;]+" />
      </context>
      <!-- '...' -->
      <context name="CharLiteral" attribute="Char" lineEndContext="CharLiteralClosing" fallthrough="true" fallthroughContext="#pop">
        <!-- Empty '' -->
        <DetectChar   attribute="Char" context="#pop"  char="'"/>
        <!-- \t \n \r etc. -->
        <HlCStringChar attribute="EscapeSequence" context="CharLiteralClosing"/>
        <!-- \u 4HexDigits | \U 8HexDigits | HTMLEntity -->
        <RegExpr attribute="EscapeSequence" context="CharLiteralClosing" String="\\(u[\da-fA-F]{4}|U[\da-fA-F]{8}|&amp;[a-zA-Z]\w+;)"/>
        <!-- Invalid escape sequences -->
        <RegExpr attribute="Error" context="CharLiteralClosing" String="\\."/>
        <!-- Any character -->
        <RegExpr attribute="Char" context="CharLiteralClosing" String="."/>
      </context>
      <!-- Anything other than a closing ' is now be an error -->
      <context name="CharLiteralClosing" attribute="Error" lineEndContext="#pop#pop" fallthrough="true" fallthroughContext="#pop#pop">
        <DetectChar attribute="Char" context="#pop#pop"  char="'"/>
      </context>
      <!-- "..." -->
      <context name="String" attribute="String" lineEndContext="#stay">
        <HlCStringChar attribute="EscapeSequence"/>
        <Detect2Chars attribute="String" context="#pop" char="&quot;" char1="c"/>
        <Detect2Chars attribute="String" context="#pop" char="&quot;" char1="w"/>
        <Detect2Chars attribute="String" context="#pop" char="&quot;" char1="d"/>
        <DetectChar attribute="String" context="#pop" char="&quot;"/>
        <Detect2Chars attribute="EscapeSequence" context="UnicodeShort"   char="\" char1="u"/>
        <Detect2Chars attribute="EscapeSequence" context="UnicodeLong"   char="\" char1="U"/>
        <Detect2Chars attribute="EscapeSequence" context="HTMLEntity"   char="\" char1="&amp;"/>
      </context>

      <!-- Comments -->
      <context name="CommentRules" attribute="Normal Text" lineEndContext="#pop">
        <IncludeRules context="DdocNormal" />
        <Detect2Chars attribute="Comment" context="CommentLine"   char="/" char1="/"/>
        <Detect2Chars attribute="Comment" context="CommentBlock" char="/" char1="*" beginRegion="CommentBlock"/>
        <Detect2Chars attribute="Comment" context="CommentNested" char="/" char1="+" beginRegion="CommentNested"/>
        <!-- This context is only for including rules from. -->
      </context>
      <context name="Region Marker" attribute="Region Marker" lineEndContext="#pop">
      </context>
      <context name="CommentLine" attribute="Comment" lineEndContext="#pop">
        <DetectSpaces />
        <IncludeRules context="##Alerts" />
      </context>
      <context name="CommentBlock" attribute="Comment" lineEndContext="#stay">
        <DetectSpaces />
        <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="CommentBlock"/>
        <IncludeRules context="##Alerts" />
      </context>
      <context name="CommentNested" attribute="Comment" lineEndContext="#stay">
        <DetectSpaces />
       <Detect2Chars attribute="Comment" context="CommentNested" char="/" char1="+" beginRegion="CommentNested"/>
       <Detect2Chars attribute="Comment" context="#pop" char="+" char1="/" endRegion="CommentNested"/>
       <IncludeRules context="##Alerts" />
      </context>
      
      
      <!-- Ddoc contexts -->
      <context name="DdocNormal" attribute="Normal Text" lineEndContext="#stay">
        <RegExpr attribute="Comment" context="DdocLine" String="/{3,}"/>
        <RegExpr attribute="Comment" context="DdocBlock" String="/\*{2,}(?!/)" beginRegion="DdocBlock"/>
        <RegExpr attribute="Comment" context="DdocNested" String="/\+{2,}(?!/)" beginRegion="DdocNested"/>
      </context>
      
      <context name="DdocLine" attribute="Ddoc" lineEndContext="#pop">
        <DetectSpaces />
        <DetectIdentifier attribute="Ddoc"/>
        <Detect2Chars attribute="Macros" context="DdocMacro" char="$" char1="(" />
        <RegExpr attribute="DdocSection" context="#stay" String="[\w_]+:($|\s)" />
        <IncludeRules context="##Alerts" />
      </context>
      
      <context name="DdocBlock" attribute="Ddoc" lineEndContext="#stay">
        <DetectSpaces />
        <DetectIdentifier attribute="Ddoc"/>
        <RegExpr attribute="Comment" context="#pop" String="\*+/" endRegion="DdocBlock"/>
        <DetectChar attribute="Comment" context="#stay" char="*" firstNonSpace="true" />
        
        <Detect2Chars attribute="Macros" context="DdocMacro" char="$" char1="(" />
        <RegExpr attribute="DdocSection" context="#stay" String="[\w_]+:($|\s)" />
        <IncludeRules context="##Alerts" />
        
        <!-- Avoid matching this; do it this way since (^|\s)-* always matches .- and \s-* never
             matches .- (spaces have already been matched); however -*($|\s) matches just fine.
             Also can't use \b since - is not a word character. -->
        <RegExpr attribute="Ddoc" context="#stay" String="[^-]-{3,}" />
        <RegExpr attribute="Comment" context="DdocBlockCode" String="-{3,}($|\s)" />
      </context>
      
      <context name="DdocNested" attribute="Ddoc" lineEndContext="#stay">
        <DetectSpaces />
        <DetectIdentifier attribute="Ddoc"/>
        <!-- Ddoc recognises nested comments/ddoc, but ignores them as far as formatting is concerned. -->
        <Detect2Chars attribute="Ddoc" context="DdocNested2" char="/" char1="+"/>
        <RegExpr attribute="Comment" context="#pop" String="\++/" endRegion="DdocNested"/>
        <DetectChar attribute="Comment" context="#stay" char="+" firstNonSpace="true" />
        
        <Detect2Chars attribute="Macros" context="DdocMacro" char="$" char1="(" />
        <RegExpr attribute="DdocSection" context="#stay" String="[\w_]+:($|\s)" />
        <IncludeRules context="##Alerts" />
        
        <!-- As above. -->
        <RegExpr attribute="Ddoc" context="#stay" String="[^-]-{3,}" />
        <RegExpr attribute="Comment" context="DdocNestedCode" String="-{3,}($|\s)" />
      </context>
      
      <context name="DdocNested2" attribute="Ddoc" lineEndContext="#stay">
        <DetectSpaces />
        <DetectIdentifier attribute="Ddoc"/>
        <!-- Identical to DdocNested except that nested comments don't recieve any formatting -->
        <RegExpr attribute="Ddoc" context="#pop" String="\++/"/>
        <!-- The above rules should match before the unwanted rule in DdocNested -->
        <IncludeRules context="DdocNested" />
      </context>
      
      <!-- When entering a macro: provides highlighting for first symbol (macro name) -->
      <context name="DdocMacro" attribute="Error" lineEndContext="#stay">
        <DetectSpaces attribute="Macro Text" /> <!-- avoid showing space as an error -->
        
        <DetectChar attribute="Macros" context="#pop" char=")" /> <!-- early end of macro -->
        <IncludeRules context="MacroRules" />
        
        <!-- first symbol of macro -->
        <DetectIdentifier attribute="Macros" context="DdocMacro2" />
      </context>
      <!-- For rest of macro -->
      <context name="DdocMacro2" attribute="Macro Text" lineEndContext="#stay">
        <DetectChar attribute="Macros" context="#pop#pop" char=")" /> <!-- end of macro -->
        <IncludeRules context="MacroRules" />
      </context>
      <!-- For embedded brackets (yeah, extra work to ignore them) -->
      <context name="DdocMacro3" attribute="Macro Text" lineEndContext="#stay">
        <DetectChar attribute="Macro Text" context="#pop" char=")" /> <!-- end of embedded brackets -->
        <IncludeRules context="MacroRules" />
      </context>
      <!-- Rules common to all macros -->
      <context name="MacroRules" attribute="Macro Text" lineEndContext="#stay">
        <Detect2Chars attribute="Macros" context="DdocMacro" char="$" char1="(" /> <!-- embedded -->
        <DetectChar attribute="Macro Text" context="DdocMacro3" char="(" /> <!-- extra brackets -->
        
        <DetectChar attribute="Comment" context="#stay" char="*" firstNonSpace="true" />
      </context>
      
      <context name="DdocBlockCode" attribute="DdocCode" lineEndContext="#stay">
        <DetectSpaces />
        <!-- See update 1.11 -->
        <RegExpr attribute="Comment" context="#pop#pop" String="\*+/" endRegion="DdocBlock"/>
        <DetectChar attribute="Comment" context="#stay" char="*" firstNonSpace="true" />
        <!-- As above. -->
        <RegExpr attribute="DdocCode" context="#stay" String="[^-]-{3,}" />
        <RegExpr attribute="Comment" context="#pop" String="-{3,}($|\s)" />
        <IncludeRules context="##D" />
      </context>
      <context name="DdocNestedCode" attribute="DdocCode" lineEndContext="#stay">
        <DetectSpaces />
        <!-- See update 1.11 -->
        <RegExpr attribute="Comment" context="#pop#pop" String="\++/" endRegion="DdocNested"/>
        <DetectChar attribute="Comment" context="#stay" char="+" firstNonSpace="true" />
        <!-- As above. -->
        <RegExpr attribute="DdocCode" context="#stay" String="[^-]-{3,}" />
        <RegExpr attribute="Comment" context="#pop" String="-{3,}($|\s)" />
        <IncludeRules context="##D" />
      </context>
    </contexts>
    <itemDatas>
      <itemData name="Normal Text"    defStyleNum="dsNormal"/>
      <itemData name="Symbol"         defStyleNum="dsNormal"/>
      
      <!-- keywords -->
      <itemData name="Statement"      defStyleNum="dsKeyword"/>
      <itemData name="Expression"     defStyleNum="dsKeyword"  color="#000080"/>
      <itemData name="Declarator"     defStyleNum="dsKeyword"  color="#800000"/>
      <itemData name="Template"       defStyleNum="dsKeyword"  color="#008000"/>
      
      <itemData name="Attribute"      defStyleNum="dsKeyword"  color="#800080"/>
      <itemData name="Deprecated"     defStyleNum="dsKeyword"  color="#800080" strikeOut="true"/>
      
      <itemData name="Property"       defStyleNum="dsDataType" color="#000080"/>
      
      <itemData name="Type"           defStyleNum="dsDataType"/>
      <itemData name="LibrarySymbols" defStyleNum="dsDataType" italic="1"/>
      
      <itemData name="UserKeywords"   defStyleNum="dsDataType" italic="1"/>
      
      <!-- module, import -->
      <itemData name="Module"         defStyleNum="dsKeyword"  color="#008000"/>
      <itemData name="Module Name"    defStyleNum="dsNormal"   color="#008000"/>
      
      <!-- pragma, special tokens -->
      <itemData name="SpecialTokens"  defStyleNum="dsNormal"   color="#00aa00"/>
      <itemData name="Pragma"         defStyleNum="dsKeyword"  color="#00aa00"/>
      
      <!-- version, extern -->
      <itemData name="Version"        defStyleNum="dsKeyword"  color="#808000"/>
      <itemData name="Version Type"   defStyleNum="dsNormal"   bold="1"/>
      <itemData name="Linkage"        defStyleNum="dsKeyword"  color="#808000"/>
      <itemData name="Linkage Type"   defStyleNum="dsNormal"   bold="1"/>
      
      <itemData name="Tests"        defStyleNum="dsKeyword"    color="#ff00ff"/>

      <itemData name="Comment"        defStyleNum="dsComment"/>
      <itemData name="Region Marker"  defStyleNum="dsRegionMarker" />
      
      <itemData name="Error"          defStyleNum="dsError"/>
      
      <!-- literals -->
      <itemData name="Integer"        defStyleNum="dsDecVal"/>
      <itemData name="Binary"         defStyleNum="dsBaseN"/>
      <itemData name="Octal"          defStyleNum="dsBaseN"/>
      <itemData name="Hex"            defStyleNum="dsBaseN"/>
      <itemData name="Float"          defStyleNum="dsFloat"/>
      
      <itemData name="EscapeSequence" defStyleNum="dsString"   color="#00aa88" selColor="#ff0000"/>
      <itemData name="String"         defStyleNum="dsString"/>
      <itemData name="Char"           defStyleNum="dsChar"/>
      <itemData name="RawString"      defStyleNum="dsString"   color="#a100a1" selColor="#ff00ff"/>
      <itemData name="BQString"       defStyleNum="dsString"   color="#a100a1" selColor="#ff00ff"/>
      <itemData name="HexString"      defStyleNum="dsString"   color="#a10022" selColor="#ff0055"/>
      
      <!-- Ddoc specific -->
      <itemData name="Macros"      defStyleNum="dsOthers" color="#bf5fbf" selColor="#ffffff" bold="1" italic="0" />
      <itemData name="Macro Text"  defStyleNum="dsNormal" color="#bf7fff" selColor="#ffffff" bold="0" italic="0" />
      <itemData name="Ddoc"        defStyleNum="dsComment" color="#7f7fff" />
      <itemData name="DdocSection" defStyleNum="dsKeyword" color="#7f7fff" bold="1" />
      <itemData name="DdocCode"    defStyleNum="dsNormal" italic="1" />
    </itemDatas>
  </highlighting>
  <general>
    <comments>
      <comment name="singleLine" start="//"/>
      <comment name="multiLine"  start="/+" end="+/" region="CommentNested"/>
    </comments>
    <keywords casesensitive="true"/>
  </general>
</language>