1 <?xml version="1.0" encoding="UTF-8"?>
4 Author: Alexis Laferrière <alexis.laf@xymus.net>
5 Copyright (C) 2009 Alexis Laferrière <alexis.laf@xymus.net>
8 Copyright (C) 2004 Archit Baweja <bighead@users.sourceforge.net>
9 Copyright (C) 2005 Michael Witrant <mike@lepton.fr>
10 Copyright (C) 2006 Gabriel Bauman <gbauman@gmail.com>
12 This library is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 <language id="nit" _name="Nit" version="2.0" _section="Sources">
29 <property name="mimetypes">text/x-nit</property>
30 <property name="globs">*.nit</property>
31 <property name="line-comment-start">#</property>
35 <style id="escape" _name="Escaped Character" map-to="def:special-char"/>
36 <style id="comment" _name="Comment" map-to="def:comment"/>
37 <style id="attribute-definition" _name="Attribute Definition" map-to="def:statement"/>
38 <style id="module-handler" _name="Module handler" map-to="def:preprocessor"/>
39 <style id="keyword" _name="Keyword" map-to="def:keyword"/>
40 <style id="null-value" _name="Nil Constant" map-to="def:special-constant"/>
41 <style id="boolean" _name="Boolean value" map-to="def:boolean"/>
42 <style id="floating-point" _name="Floating point number" map-to="def:floating-point"/>
43 <style id="decimal" _name="Decimal number" map-to="def:decimal"/>
44 <style id="base-n-integer" _name="Base-N number" map-to="def:base-n-integer"/>
45 <style id="string" _name="String" map-to="def:string"/>
46 <style id="builtin" _name="Builtin" map-to="def:type"/>
47 <style id="class-name" _name="Constant" map-to="def:type"/>
48 <style id="symbol" _name="Symbol" map-to="def:string"/>
49 <style id="special-variable" _name="Special Variable" map-to="def:identifier"/>
50 <style id="predefined-variable" _name="Predefined Variable" map-to="def:identifier"/>
51 <style id="variable" _name="Variable" map-to="def:identifier"/>
56 <context id="escape" style-ref="escape">
57 <match>\\((0-7){3}|(x[a-fA-F0-9]{2})|(c\S)|([CM]-\S)|(M-C-\S)|.)</match>
60 <context id="multiline-comment" style-ref="comment">
61 <start>^=begin</start>
64 <context ref="escape"/>
65 <context ref="def:in-comment"/>
69 <context id="definitions" style-ref="keyword">
70 <keyword>class</keyword>
71 <keyword>fun</keyword>
72 <keyword>redef</keyword>
73 <keyword>var</keyword>
74 <keyword>module</keyword>
75 <keyword>type</keyword>
76 <keyword>universal</keyword>
77 <keyword>enum</keyword>
80 <context id="module-handlers" style-ref="module-handler">
81 <keyword>import</keyword>
84 <context id="keywords" style-ref="keyword">
86 <keyword>end</keyword>
87 <keyword>intrude</keyword>
88 <keyword>private</keyword>
90 <keyword>then</keyword>
91 <keyword>else</keyword>
92 <keyword>while</keyword>
93 <keyword>for</keyword>
94 <keyword>assert</keyword>
96 <keyword>abstract</keyword>
97 <keyword>intern</keyword>
98 <keyword>extern</keyword>
99 <keyword>public</keyword>
100 <keyword>protected</keyword>
101 <keyword>or</keyword>
102 <keyword>as</keyword>
103 <keyword>isa</keyword>
104 <keyword>break</keyword>
105 <keyword>continue</keyword>
106 <keyword>return</keyword>
107 <keyword>label</keyword>
108 <keyword>abort</keyword>
109 <keyword>nullable</keyword>
110 <keyword>new</keyword>
111 <keyword>special</keyword>
112 <keyword>super</keyword>
113 <keyword>init</keyword>
114 <keyword>in</keyword>
115 <keyword>or</keyword>
116 <keyword>and</keyword>
117 <keyword>not</keyword>
118 <keyword>writable</keyword>
119 <keyword>readable</keyword>
122 <context id="special-variables" style-ref="special-variable">
123 <keyword>self</keyword>
126 <context id="instance-variables" style-ref="variable">
127 <match>(::)?\b_[a-zA-Z_][a-zA-Z0-9_]*</match>
130 <context id="class-name" style-ref="class-name">
131 <match>(::)?\b[A-Z][A-Za-z0-9_]*\b</match>
134 <context id="null-value" style-ref="null-value">
135 <keyword>null</keyword>
138 <context id="boolean" style-ref="boolean">
139 <keyword>false</keyword>
140 <keyword>true</keyword>
143 <define-regex id="underscore_num">\d(_?\d)*</define-regex>
145 <define-regex id="float" extended="true">
146 ( (\%{underscore_num})?\.\%{underscore_num} | \%{underscore_num}\. ) |
147 ( (\%{underscore_num}|(\%{underscore_num})?\.\%{underscore_num}|\%{underscore_num}\.)[eE][+-]?\%{underscore_num} )
150 <context id="float" style-ref="floating-point">
151 <match>(?<![\w\.])\%{float}(?![\w\.])</match>
154 <context id="decimal" style-ref="decimal">
155 <match>(?<![\w\.])([1-9](_?[0-9])*|0)(?![\w\.])</match>
158 <!-- in double quotes and backticks -->
159 <!-- FIXME: really would like for the syntax highlight to go back
160 to none here, as any ruby code could go here -->
161 <context id="complex-interpolation" style-ref="escape">
165 <context ref="nit:*"/>
169 <!-- ruby strings do not end at line end,
170 so we cannot use def:string
171 (parts lifted from perl.lang) -->
172 <context id="double-quoted-string" style-ref="string">
176 <context ref="escape"/>
177 <context ref="def:line-continue"/>
178 <context ref="complex-interpolation"/>
182 <context id="single-quoted-string" style-ref="string">
186 <context style-ref="escape">
187 <match>\\['\\]</match>
192 <context id="backtick-quoted-string" style-ref="string">
196 <context ref="escape"/>
197 <context ref="def:line-continue"/>
198 <context ref="complex-interpolation"/>
204 <context ref="def:shebang"/>
205 <context ref="def:shell-like-comment"/>
206 <context ref="double-quoted-string"/>
207 <context ref="single-quoted-string"/>
208 <context ref="backtick-quoted-string"/>
209 <context ref="definitions"/>
210 <context ref="module-handlers"/>
211 <context ref="keywords"/>
212 <context ref="special-variables"/>
213 <context ref="instance-variables"/>
214 <context ref="class-name"/>
215 <context ref="null-value"/>
216 <context ref="boolean"/>
217 <context ref="float"/>
218 <context ref="decimal"/>