1 <?xml version="1.0" encoding="UTF-8"?>
3 This file is part of NIT ( http://www.nitlanguage.org ).
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
9 http://www.apache.org/licenses/LICENSE-2.0
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.
17 <language id="nit" _name="Nit" version="2.0" _section="Source">
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>
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"/>
46 The following styles do not inherit from `def` because most style
47 schemes highlight them too much.
49 <style id="operator" _name="Operator"/> <!-- "def:operator" -->
50 <style id="variable" _name="Variable or Method"/> <!-- "def:identifier" -->
52 <!-- TODO: Implement `bad_string` and `bad_char`?
53 <style id="error" _name="Error" map-to="def:error"/>
57 <default-regex-options extended="true"/>
58 <keyword-char-class>[A-Za-z0-9_]</keyword-char-class>
61 <define-regex id="space" extended="false">[ \n\r\t]</define-regex>
63 <!-- Keywords and operators -->
65 <context id="reserved" style-ref="reserved">
66 <keyword>package</keyword>
67 <keyword>yield</keyword>
70 <context id="kwimport" style-ref="module-handler">
71 <keyword>import</keyword>
74 <context id="kwnull" style-ref="null-value">
75 <keyword>null</keyword>
78 <context id="keyword" style-ref="keyword">
79 <keyword>abort</keyword>
80 <keyword>abstract</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>
89 <keyword>else</keyword>
90 <keyword>end</keyword>
91 <keyword>enum</keyword>
92 <keyword>extern</keyword>
93 <keyword>for</keyword>
94 <keyword>fun</keyword>
96 <keyword>init</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>
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>
150 <context id="boolean" style-ref="boolean">
151 <keyword>true</keyword>
152 <keyword>false</keyword>
155 <context id="special-variable" style-ref="special-variable">
156 <keyword>self</keyword>
159 <context id="operator-keyword" style-ref="keyword">
160 <keyword>and</keyword>
161 <keyword>implies</keyword>
162 <keyword>not</keyword>
163 <keyword>or</keyword>
166 <context id="operator-punctuation" style-ref="operator">
196 <context id="attribute" style-ref="attribute">
197 <match>\%[ _[a-z][A-Za-z0-9_]* \%]</match>
200 <context id="type" style-ref="type">
201 <match>\%[ [A-Z][A-Za-z0-9_]* \%]</match>
204 <context id="variable" style-ref="variable">
205 <match>\%[ [a-z][A-Za-z0-9_]* \%]</match>
210 <define-regex id="integer-suffix">
214 <context id="binary" style-ref="binary">
215 <match>[+-]?0[Bb][01_]+\%{integer-suffix}</match>
218 <context id="octal" style-ref="octal">
219 <match>[+-]?0[Oo][0-7_]+\%{integer-suffix}</match>
222 <context id="hexadecimal" style-ref="hexadecimal">
223 <match>[+-]?0[Xx][0-9A-Fa-f_]+\%{integer-suffix}</match>
226 <context id="decimal" style-ref="decimal">
227 <match>[+-]?[0-9][0-9_]*\%{integer-suffix}</match>
230 <context id="floating-point" style-ref="floating-point">
231 <match>[+-]?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[Ee][+-]?[0-9]+)?</match>
234 <!-- Strings and characters -->
236 <context id="escaped-apostrophe" style-ref="escaped-character">
240 <context id="escaped-character" style-ref="escaped-character">
244 <context id="interpolation" style-ref="escaped-character">
248 <!-- FIXME: Reset style -->
249 <context ref="nit" />
253 <context id="long-interpolation" style-ref="escaped-character">
254 <start>\{\{\{</start>
257 <!-- FIXME: Reset style -->
258 <context ref="nit" />
262 <context id="long-string" style-ref="string" class="string">
263 <start>"""|'''</start>
264 <end>\%{0@start}</end>
266 <context ref="escaped-character"/>
267 <context ref="long-interpolation"/>
271 <context id="character" style-ref="character" class="string">
275 <context ref="escaped-apostrophe"/>
279 <context id="string" style-ref="string" class="string">
283 <context ref="escaped-character"/>
284 <context ref="interpolation"/>
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}*
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"/>
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}*
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"/>
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}*
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"/>
338 <context id="extern-code-default" style-ref="extern-code">
339 <!-- By default, the embedded language is C. -->
343 <!-- FIXME: Reset style -->
348 <!-- Main context -->
349 <context id="nit" class="no-spell-check">
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"/>