summaryrefslogtreecommitdiffstats
path: root/kate/data/ddoc.xml
blob: 98c7d6f6b13dc9fbcb8401b24faaeca920a677a0 (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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!--
  This file is part of KDE's kate project.

  Copyright 2007-2008 Kate project.
  
  Author: Diggory Hardy <diggory.hardy@gmail.com>
  
  This tqcontains highlighting for Ddoc, the D language embedded documentation comments. Implemented
  for d.xml version 1.46.
  
  Macros are highlighted but the macro name and macro contents/parameters are not highlighted
  differently. Currently the only way I can think of doing this is by matching the macro using a
  RegExpr matching $(XX where XX are the first symbols before any spaces. If anyone has a better
  idea please let me know.
  
  Section names are matched, but too often since it can't really check that they're the first non-
  whitespace item excluding a leading * or +. They could easily be made to match too little instead
  of too much by adding firstNonSpace="true".
  
  Code sections are matched, and formatted by using the standard d highlighting rules. This looks
  good as far as I've tested it, but could lead to some confusion. Note that it does make
  unhighlighted non-identifiers (i.e. things not matching [a-zA-Z_][a-zA-Z0-9_]*) italic.
  
  Updates:
  2008.02.22    ddoc 1.14			Fixes/improvements for macros. Highlights first symbol and non-symbols before as errors; matches embedded brackets () properly.
  2007.11.15	ddoc 1.13			Fixed a couple of bugs found by checkdtd and changed the version number format.
  2007.11.5	ddoc 1.12			Fixed: correct matching of things like /***/ .
  2007.10.11	ddoc 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.9	ddoc 1.10			Enabled embedded ddoc code highlighting
  2007.10.9	ddoc 1.00			Initial version

 **********************************************************************
 * 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 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.                                       *
 **********************************************************************
 -->
<language name="Ddoc" version="1.14" kateversion="2.5" section="Markup" author="Diggory Hardy (diggory.hardy@gmail.com)" license="LGPL" extensions="">
  <highlighting>
    <contexts>
      <context name="Normal" 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="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="Comment"     defStyleNum="dsComment"/>
      <itemData name="Ddoc"        defStyleNum="dsComment" color="#7f7fff" />
      <itemData name="DdocSection" defStyleNum="dsKeyword" color="#7f7fff" bold="1" />
      <itemData name="DdocCode"    defStyleNum="dsNormal" italic="1" />
      
      <itemData name="Error"       defStyleNum="dsError"/>
    </itemDatas>
  </highlighting>
  <general>
    <keywords casesensitive="0" />
  </general>
</language>