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>package</keyword>
75 <keyword>type</keyword>
76 <keyword>universal</keyword>
79 <context id="module-handlers" style-ref="module-handler">
80 <keyword>import</keyword>
83 <context id="keywords" style-ref="keyword">
85 <keyword>end</keyword>
86 <keyword>intrude</keyword>
87 <keyword>private</keyword>
89 <keyword>then</keyword>
90 <keyword>else</keyword>
91 <keyword>while</keyword>
92 <keyword>for</keyword>
93 <keyword>assert</keyword>
95 <keyword>abstract</keyword>
96 <keyword>intern</keyword>
97 <keyword>extern</keyword>
98 <keyword>public</keyword>
99 <keyword>protected</keyword>
100 <keyword>or</keyword>
101 <keyword>as</keyword>
102 <keyword>isa</keyword>
103 <keyword>break</keyword>
104 <keyword>continue</keyword>
105 <keyword>return</keyword>
106 <keyword>label</keyword>
107 <keyword>abort</keyword>
108 <keyword>nullable</keyword>
109 <keyword>new</keyword>
110 <keyword>special</keyword>
111 <keyword>super</keyword>
112 <keyword>init</keyword>
113 <keyword>in</keyword>
114 <keyword>or</keyword>
115 <keyword>and</keyword>
116 <keyword>not</keyword>
117 <keyword>writable</keyword>
118 <keyword>readable</keyword>
121 <context id="special-variables" style-ref="special-variable">
122 <keyword>self</keyword>
125 <context id="instance-variables" style-ref="variable">
126 <match>(::)?\b_[a-zA-Z_][a-zA-Z0-9_]*</match>
129 <context id="class-name" style-ref="class-name">
130 <match>(::)?\b[A-Z][A-Za-z0-9_]*\b</match>
133 <context id="null-value" style-ref="null-value">
134 <keyword>null</keyword>
137 <context id="boolean" style-ref="boolean">
138 <keyword>false</keyword>
139 <keyword>true</keyword>
142 <define-regex id="underscore_num">\d(_?\d)*</define-regex>
144 <define-regex id="float" extended="true">
145 ( (\%{underscore_num})?\.\%{underscore_num} | \%{underscore_num}\. ) |
146 ( (\%{underscore_num}|(\%{underscore_num})?\.\%{underscore_num}|\%{underscore_num}\.)[eE][+-]?\%{underscore_num} )
149 <context id="float" style-ref="floating-point">
150 <match>(?<![\w\.])\%{float}(?![\w\.])</match>
153 <context id="decimal" style-ref="decimal">
154 <match>(?<![\w\.])([1-9](_?[0-9])*|0)(?![\w\.])</match>
157 <!-- in double quotes and backticks -->
158 <!-- FIXME: really would like for the syntax highlight to go back
159 to none here, as any ruby code could go here -->
160 <context id="complex-interpolation" style-ref="escape">
164 <context ref="nit:*"/>
168 <!-- ruby strings do not end at line end,
169 so we cannot use def:string
170 (parts lifted from perl.lang) -->
171 <context id="double-quoted-string" style-ref="string">
175 <context ref="escape"/>
176 <context ref="def:line-continue"/>
177 <context ref="complex-interpolation"/>
181 <context id="single-quoted-string" style-ref="string">
185 <context style-ref="escape">
186 <match>\\['\\]</match>
191 <context id="backtick-quoted-string" style-ref="string">
195 <context ref="escape"/>
196 <context ref="def:line-continue"/>
197 <context ref="complex-interpolation"/>
203 <context ref="def:shebang"/>
204 <context ref="def:shell-like-comment"/>
205 <context ref="double-quoted-string"/>
206 <context ref="single-quoted-string"/>
207 <context ref="backtick-quoted-string"/>
208 <context ref="definitions"/>
209 <context ref="module-handlers"/>
210 <context ref="keywords"/>
211 <context ref="special-variables"/>
212 <context ref="instance-variables"/>
213 <context ref="class-name"/>
214 <context ref="null-value"/>
215 <context ref="boolean"/>
216 <context ref="float"/>
217 <context ref="decimal"/>