Merge: doc: fixed some typos and other misc. corrections
[nit.git] / misc / gtksourceview / nit.lang
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3         This file is part of NIT ( http://www.nitlanguage.org ).
4
5         Licensed under the Apache License, Version 2.0 (the "License");
6         you may not use this file except in compliance with the License.
7         You may obtain a copy of the License at
8
9                 http://www.apache.org/licenses/LICENSE-2.0
10
11         Unless required by applicable law or agreed to in writing, software
12         distributed under the License is distributed on an "AS IS" BASIS,
13         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14         See the License for the specific language governing permissions and
15         limitations under the License.
16 -->
17 <language id="nit" _name="Nit" version="2.0" _section="Source">
18         <metadata>
19                 <!-- TODO: Register the media type -->
20                 <property name="mimetypes">text/x-nit</property>
21                 <property name="globs">*.nit</property>
22                 <property name="line-comment-start">#</property>
23         </metadata>
24
25         <styles>
26                 <style id="attribute"          _name="Attribute"             map-to="def:builtin"/>
27                 <style id="boolean"            _name="Boolean value"         map-to="def:boolean"/>
28                 <style id="binary"             _name="Binary number"         map-to="def:base-n-integer"/>
29                 <style id="builtin-annotation" _name="Built-in Annotation"   map-to="def:keyword"/>
30                 <style id="character"          _name="Character"             map-to="def:character"/>
31                 <style id="decimal"            _name="Decimal number"        map-to="def:decimal"/>
32                 <style id="escaped-character"  _name="Escaped Character"     map-to="def:special-char"/>
33                 <style id="extern-code"        _name="Extern Code"           map-to="def:preprocessor"/>
34                 <style id="floating-point"     _name="Floating point number" map-to="def:floating-point"/>
35                 <style id="hexadecimal"        _name="Hexadecimal number"    map-to="def:base-n-integer"/>
36                 <style id="keyword"            _name="Keyword"               map-to="def:keyword"/>
37                 <style id="octal"              _name="Octal number"          map-to="def:base-n-integer"/>
38                 <style id="module-handler"     _name="Module Handler"        map-to="def:preprocessor"/>
39                 <style id="null-value"         _name="Null Value"            map-to="def:special-constant"/>
40                 <style id="reserved"           _name="Reserved keyword"      map-to="def:reserved"/>
41                 <style id="special-variable"   _name="Special Variable"      map-to="def:builtin"/>
42                 <style id="string"             _name="String"                map-to="def:string"/>
43                 <style id="type"               _name="Data Type"             map-to="def:type"/>
44
45                 <!--
46                         The following styles do not inherit from `def` because most style
47                         schemes highlight them too much.
48                 -->
49                 <style id="operator"           _name="Operator"/>              <!-- "def:operator" -->
50                 <style id="variable"           _name="Variable or Method"/>    <!-- "def:identifier" -->
51
52                 <!-- TODO: Implement `bad_string` and `bad_char`?
53                 <style id="error"              _name="Error"                 map-to="def:error"/>
54                 -->
55         </styles>
56
57         <default-regex-options extended="true"/>
58         <keyword-char-class>[A-Za-z0-9_]</keyword-char-class>
59
60         <definitions>
61                 <define-regex id="space" extended="false">[ \n\r\t]</define-regex>
62
63                 <!-- Keywords and operators -->
64
65                 <context id="reserved" style-ref="reserved">
66                         <keyword>package</keyword>
67                         <keyword>yield</keyword>
68                 </context>
69
70                 <context id="kwimport" style-ref="module-handler">
71                         <keyword>import</keyword>
72                 </context>
73
74                 <context id="kwnull" style-ref="null-value">
75                         <keyword>null</keyword>
76                 </context>
77
78                 <context id="keyword" style-ref="keyword">
79                         <keyword>abort</keyword>
80                         <keyword>abstract</keyword>
81                         <keyword>as</keyword>
82                         <keyword>assert</keyword>
83                         <keyword>break</keyword>
84                         <keyword>catch</keyword>
85                         <keyword>class</keyword>
86                         <keyword>continue</keyword>
87                         <keyword>__debug__</keyword>
88                         <keyword>do</keyword>
89                         <keyword>else</keyword>
90                         <keyword>end</keyword>
91                         <keyword>enum</keyword>
92                         <keyword>extern</keyword>
93                         <keyword>for</keyword>
94                         <keyword>fun</keyword>
95                         <keyword>if</keyword>
96                         <keyword>init</keyword>
97                         <keyword>in</keyword>
98                         <keyword>interface</keyword>
99                         <keyword>intrude</keyword>
100                         <keyword>isa</keyword>
101                         <keyword>is</keyword>
102                         <keyword>isset</keyword>
103                         <keyword>label</keyword>
104                         <keyword>loop</keyword>
105                         <keyword>module</keyword>
106                         <keyword>new</keyword>
107                         <keyword>nullable</keyword>
108                         <keyword>once</keyword>
109                         <keyword>private</keyword>
110                         <keyword>protected</keyword>
111                         <keyword>public</keyword>
112                         <keyword>redef</keyword>
113                         <keyword>return</keyword>
114                         <keyword>subset</keyword>
115                         <keyword>super</keyword>
116                         <keyword>then</keyword>
117                         <keyword>type</keyword>
118                         <keyword>universal</keyword>
119                         <keyword>var</keyword>
120                         <keyword>while</keyword>
121                         <keyword>with</keyword>
122                 </context>
123
124                 <context id="builtin-annotation" style-ref="builtin-annotation">
125                         <keyword>autoinit</keyword>
126                         <keyword>auto_inspect</keyword>
127                         <keyword>cflags</keyword>
128                         <keyword>conditional</keyword>
129                         <keyword>deprecated</keyword>
130                         <keyword>fixed</keyword>
131                         <keyword>generated</keyword>
132                         <keyword>intern</keyword>
133                         <keyword>lateinit</keyword>
134                         <keyword>lazy</keyword>
135                         <keyword>ldflags</keyword>
136                         <keyword>light_ffi</keyword>
137                         <keyword>new_annotation</keyword>
138                         <keyword>noautoinit</keyword>
139                         <keyword>noinit</keyword>
140                         <keyword>nosuper</keyword>
141                         <keyword>no_warning</keyword>
142                         <keyword>old_style_init</keyword>
143                         <keyword>optional</keyword>
144                         <keyword>pkgconfig</keyword>
145                         <keyword>platform</keyword>
146                         <keyword>readonly</keyword>
147                         <keyword>writable</keyword>
148                 </context>
149
150                 <context id="boolean" style-ref="boolean">
151                         <keyword>true</keyword>
152                         <keyword>false</keyword>
153                 </context>
154
155                 <context id="special-variable" style-ref="special-variable">
156                         <keyword>self</keyword>
157                 </context>
158
159                 <context id="operator-keyword" style-ref="keyword">
160                         <keyword>and</keyword>
161                         <keyword>implies</keyword>
162                         <keyword>not</keyword>
163                         <keyword>or</keyword>
164                 </context>
165
166                 <context id="operator-punctuation" style-ref="operator">
167                         <match>
168                                 \^=? |
169                                 ~ |
170                                 &lt;&lt;?=? |
171                                 &lt;=&gt; |
172                                 ==? |
173                                 &gt;&gt;?=? |
174                                 \| |
175                                 -=? |
176                                 , |
177                                 ; |
178                                 ::? |
179                                 !=? |
180                                 /=? |
181                                 \.{1,3} |
182                                 \( |
183                                 \) |
184                                 \[ |
185                                 \] |
186                                 @ |
187                                 \*\*?=? |
188                                 &amp;=? |
189                                 %=? |
190                                 \+=?
191                         </match>
192                 </context>
193
194                 <!-- Identifiers -->
195
196                 <context id="attribute" style-ref="attribute">
197                         <match>\%[ _[a-z][A-Za-z0-9_]* \%]</match>
198                 </context>
199
200                 <context id="type" style-ref="type">
201                         <match>\%[ [A-Z][A-Za-z0-9_]* \%]</match>
202                 </context>
203
204                 <context id="variable" style-ref="variable">
205                         <match>\%[ [a-z][A-Za-z0-9_]* \%]</match>
206                 </context>
207
208                 <!-- Numbers -->
209
210                 <define-regex id="integer-suffix">
211                         (?:[iu](?:8|16|32))?
212                 </define-regex>
213
214                 <context id="binary" style-ref="binary">
215                         <match>[+-]?0[Bb][01_]+\%{integer-suffix}</match>
216                 </context>
217
218                 <context id="octal" style-ref="octal">
219                         <match>[+-]?0[Oo][0-7_]+\%{integer-suffix}</match>
220                 </context>
221
222                 <context id="hexadecimal" style-ref="hexadecimal">
223                         <match>[+-]?0[Xx][0-9A-Fa-f_]+\%{integer-suffix}</match>
224                 </context>
225
226                 <context id="decimal" style-ref="decimal">
227                         <match>[+-]?[0-9][0-9_]*\%{integer-suffix}</match>
228                 </context>
229
230                 <context id="floating-point" style-ref="floating-point">
231                         <match>[+-]?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[Ee][+-]?[0-9]+)?</match>
232                 </context>
233
234                 <!-- Strings and characters -->
235
236                 <context id="escaped-apostrophe" style-ref="escaped-character">
237                         <match>\\'</match>
238                 </context>
239
240                 <context id="escaped-character" style-ref="escaped-character">
241                         <match>\\.</match>
242                 </context>
243
244                 <context id="interpolation" style-ref="escaped-character">
245                         <start>\{</start>
246                         <end>\}</end>
247                         <include>
248                                 <!-- FIXME: Reset style -->
249                                 <context ref="nit" />
250                         </include>
251                 </context>
252
253                 <context id="long-interpolation" style-ref="escaped-character">
254                         <start>\{\{\{</start>
255                         <end>\}\}\}</end>
256                         <include>
257                                 <!-- FIXME: Reset style -->
258                                 <context ref="nit" />
259                         </include>
260                 </context>
261
262                 <context id="long-string" style-ref="string" class="string">
263                         <start>"""|'''</start>
264                         <end>\%{0@start}</end>
265                         <include>
266                                 <context ref="escaped-character"/>
267                                 <context ref="long-interpolation"/>
268                         </include>
269                 </context>
270
271                 <context id="character" style-ref="character" class="string">
272                         <start>'</start>
273                         <end>'</end>
274                         <include>
275                                 <context ref="escaped-apostrophe"/>
276                         </include>
277                 </context>
278
279                 <context id="string" style-ref="string" class="string">
280                         <start>"</start>
281                         <end>"</end>
282                         <include>
283                                 <context ref="escaped-character"/>
284                                 <context ref="interpolation"/>
285                         </include>
286                 </context>
287
288                 <!-- Extern code -->
289
290                 <context id="extern-code-cpp" style-ref="extern-code">
291                         <start case-sensitive="false">
292                                 (?'cpp_kwin' in) \%{space}*
293                                 (?'cpp_language_name' "c\+\+(?: [^"]*)?") \%{space}*
294                                 `\{
295                         </start>
296                         <end>`\}</end>
297                         <include>
298                                 <context sub-pattern="cpp_kwin" where="start" style-ref="keyword"/>
299                                 <context sub-pattern="cpp_language_name" where="start"
300                                                 style-ref="string" class="string" />
301                                 <!-- FIXME: Reset style -->
302                                 <context ref="cpp:cpp"/>
303                         </include>
304                 </context>
305
306                 <context id="extern-code-java" style-ref="extern-code">
307                         <start case-sensitive="false">
308                                 (?'java_kwin' in) \%{space}*
309                                 (?'java_language_name' "java(?: [^"]*)?") \%{space}*
310                                 `\{
311                         </start>
312                         <end>`\}</end>
313                         <include>
314                                 <context sub-pattern="java_kwin" where="start" style-ref="keyword"/>
315                                 <context sub-pattern="java_language_name" where="start"
316                                                 style-ref="string" class="string" />
317                                 <!-- FIXME: Reset style -->
318                                 <context ref="java:java"/>
319                         </include>
320                 </context>
321
322                 <context id="extern-code-objc" style-ref="extern-code">
323                         <start case-sensitive="false">
324                                 (?'objc_kwin' in) \%{space}*
325                                 (?'objc_language_name' "objc(?: [^"]*)?") \%{space}*
326                                 `\{
327                         </start>
328                         <end>`\}</end>
329                         <include>
330                                 <context sub-pattern="objc_kwin" where="start" style-ref="keyword"/>
331                                 <context sub-pattern="objc_language_name" where="start"
332                                                 style-ref="string" class="string" />
333                                 <!-- FIXME: Reset style -->
334                                 <context ref="objc:objc"/>
335                         </include>
336                 </context>
337
338                 <context id="extern-code-default" style-ref="extern-code">
339                         <!-- By default, the embedded language is C. -->
340                         <start>`\{</start>
341                         <end>`\}</end>
342                         <include>
343                                 <!-- FIXME: Reset style -->
344                                 <context ref="c:c"/>
345                         </include>
346                 </context>
347
348                 <!-- Main context -->
349                 <context id="nit" class="no-spell-check">
350                         <include>
351                                 <context ref="def:shebang"/>
352                                 <context ref="def:shell-like-comment"/>
353                                 <context ref="extern-code-cpp"/>
354                                 <context ref="extern-code-java"/>
355                                 <context ref="extern-code-objc"/>
356                                 <context ref="extern-code-default"/>
357                                 <context ref="long-string"/>
358                                 <context ref="character"/>
359                                 <context ref="string"/>
360                                 <context ref="reserved"/>
361                                 <context ref="kwimport"/>
362                                 <context ref="kwnull"/>
363                                 <context ref="keyword"/>
364                                 <context ref="builtin-annotation"/>
365                                 <context ref="boolean"/>
366                                 <context ref="special-variable"/>
367                                 <context ref="operator-keyword"/>
368                                 <context ref="attribute"/>
369                                 <context ref="type"/>
370                                 <context ref="variable"/>
371                                 <context ref="binary"/>
372                                 <context ref="octal"/>
373                                 <context ref="hexadecimal"/>
374                                 <context ref="decimal"/>
375                                 <context ref="floating-point"/>
376                                 <context ref="operator-punctuation"/>
377                         </include>
378                 </context>
379         </definitions>
380 </language>