]> git.lizzy.rs Git - rust.git/blob - src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang
auto merge of #15999 : Kimundi/rust/fix_folder, r=nikomatsakis
[rust.git] / src / etc / gedit / share / gtksourceview-3.0 / language-specs / rust.lang
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!-- Syntax highlighting for the under-development Mozilla Rust language -->
4
5 <language id="rust" _name="Rust" version="2.0" _section="Sources">
6   <metadata>
7     <property name="mimetypes">text/x-rust</property>
8     <property name="globs">*.rs</property>
9     <property name="line-comment-start">//</property>
10     <property name="block-comment-start">/*</property>
11     <property name="block-comment-end">*/</property>
12   </metadata>
13
14   <styles>
15     <style id="comment" _name="Comment" map-to="def:comment"/>
16     <style id="string" _name="String" map-to="def:string"/>
17     <style id="char" _name="Character" map-to="def:character"/>
18     <style id="keyword" _name="Keyword" map-to="def:keyword"/>
19     <style id="type" _name="Data Type" map-to="def:type"/>
20     <style id="constant" _name="Constant" map-to="def:constant"/>
21     <style id="identifier" _name="Identifier" map-to="def:identifier"/>
22     <style id="number" _name="Number" map-to="def:number"/>
23     <style id="scope" _name="Scope" map-to="def:preprocessor"/>
24     <style id="attribute" _name="Attribute" map-to="def:preprocessor"/>
25   </styles>
26
27   <definitions>
28
29     <context id="function" style-ref="keyword">
30                 <keyword>fn</keyword>
31     </context>
32
33     <context id="type" style-ref="keyword">
34                 <keyword>type</keyword>
35     </context>
36
37     <context id="keywords" style-ref="keyword">
38                 <keyword>as</keyword>
39                 <keyword>assert</keyword>
40                 <keyword>break</keyword>
41                 <keyword>box</keyword>
42                 <keyword>const</keyword>
43                 <keyword>continue</keyword>
44                 <keyword>crate</keyword>
45                 <keyword>do</keyword>
46                 <keyword>drop</keyword>
47                 <keyword>else</keyword>
48                 <keyword>enum</keyword>
49                 <keyword>export</keyword>
50                 <keyword>extern</keyword>
51                 <keyword>fail</keyword>
52                 <keyword>for</keyword>
53                 <keyword>if</keyword>
54                 <keyword>impl</keyword>
55                 <keyword>in</keyword>
56                 <keyword>let</keyword>
57                 <keyword>log</keyword>
58                 <keyword>loop</keyword>
59                 <keyword>match</keyword>
60                 <keyword>mod</keyword>
61                 <keyword>move</keyword>
62                 <keyword>mut</keyword>
63                 <keyword>priv</keyword>
64                 <keyword>pub</keyword>
65                 <keyword>pure</keyword>
66                 <keyword>ref</keyword>
67                 <keyword>return</keyword>
68                 <keyword>static</keyword>
69                 <keyword>struct</keyword>
70                 <keyword>trait</keyword>
71                 <keyword>unsafe</keyword>
72                 <keyword>use</keyword>
73                 <keyword>while</keyword>
74     </context>
75
76     <context id="types" style-ref="type">
77                 <keyword>bool</keyword>
78                 <keyword>int</keyword>
79                 <keyword>uint</keyword>
80                 <keyword>i8</keyword>
81                 <keyword>i16</keyword>
82                 <keyword>i32</keyword>
83                 <keyword>i64</keyword>
84                 <keyword>u8</keyword>
85                 <keyword>u16</keyword>
86                 <keyword>u32</keyword>
87                 <keyword>u64</keyword>
88                 <keyword>f32</keyword>
89                 <keyword>f64</keyword>
90                 <keyword>char</keyword>
91                 <keyword>str</keyword>
92                 <keyword>Option</keyword>
93                 <keyword>Result</keyword>
94     </context>
95
96     <context id="ctypes" style-ref="type">
97                 <keyword>c_float</keyword>
98                 <keyword>c_double</keyword>
99                 <keyword>c_void</keyword>
100                 <keyword>FILE</keyword>
101                 <keyword>fpos_t</keyword>
102                 <keyword>DIR</keyword>
103                 <keyword>dirent</keyword>
104                 <keyword>c_char</keyword>
105                 <keyword>c_schar</keyword>
106                 <keyword>c_uchar</keyword>
107                 <keyword>c_short</keyword>
108                 <keyword>c_ushort</keyword>
109                 <keyword>c_int</keyword>
110                 <keyword>c_uint</keyword>
111                 <keyword>c_long</keyword>
112                 <keyword>c_ulong</keyword>
113                 <keyword>size_t</keyword>
114                 <keyword>ptrdiff_t</keyword>
115                 <keyword>clock_t</keyword>
116                 <keyword>time_t</keyword>
117                 <keyword>c_longlong</keyword>
118                 <keyword>c_ulonglong</keyword>
119                 <keyword>intptr_t</keyword>
120                 <keyword>uintptr_t</keyword>
121                 <keyword>off_t</keyword>
122                 <keyword>dev_t</keyword>
123                 <keyword>ino_t</keyword>
124                 <keyword>pid_t</keyword>
125                 <keyword>mode_t</keyword>
126                 <keyword>ssize_t</keyword>
127     </context>
128
129     <context id="self" style-ref="identifier">
130                 <keyword>self</keyword>
131     </context>
132
133     <context id="constants" style-ref="constant">
134                 <keyword>true</keyword>
135                 <keyword>false</keyword>
136                 <keyword>Some</keyword>
137                 <keyword>None</keyword>
138                 <keyword>Ok</keyword>
139                 <keyword>Err</keyword>
140                 <keyword>Success</keyword>
141                 <keyword>Failure</keyword>
142                 <keyword>Cons</keyword>
143                 <keyword>Nil</keyword>
144     </context>
145
146     <context id="cconstants" style-ref="constant">
147                 <keyword>EXIT_FAILURE</keyword>
148                 <keyword>EXIT_SUCCESS</keyword>
149                 <keyword>RAND_MAX</keyword>
150                 <keyword>EOF</keyword>
151                 <keyword>SEEK_SET</keyword>
152                 <keyword>SEEK_CUR</keyword>
153                 <keyword>SEEK_END</keyword>
154                 <keyword>_IOFBF</keyword>
155                 <keyword>_IONBF</keyword>
156                 <keyword>_IOLBF</keyword>
157                 <keyword>BUFSIZ</keyword>
158                 <keyword>FOPEN_MAX</keyword>
159                 <keyword>FILENAME_MAX</keyword>
160                 <keyword>L_tmpnam</keyword>
161                 <keyword>TMP_MAX</keyword>
162                 <keyword>O_RDONLY</keyword>
163                 <keyword>O_WRONLY</keyword>
164                 <keyword>O_RDWR</keyword>
165                 <keyword>O_APPEND</keyword>
166                 <keyword>O_CREAT</keyword>
167                 <keyword>O_EXCL</keyword>
168                 <keyword>O_TRUNC</keyword>
169                 <keyword>S_IFIFO</keyword>
170                 <keyword>S_IFCHR</keyword>
171                 <keyword>S_IFBLK</keyword>
172                 <keyword>S_IFDIR</keyword>
173                 <keyword>S_IFREG</keyword>
174                 <keyword>S_IFMT</keyword>
175                 <keyword>S_IEXEC</keyword>
176                 <keyword>S_IWRITE</keyword>
177                 <keyword>S_IREAD</keyword>
178                 <keyword>S_IRWXU</keyword>
179                 <keyword>S_IXUSR</keyword>
180                 <keyword>S_IWUSR</keyword>
181                 <keyword>S_IRUSR</keyword>
182                 <keyword>F_OK</keyword>
183                 <keyword>R_OK</keyword>
184                 <keyword>W_OK</keyword>
185                 <keyword>X_OK</keyword>
186                 <keyword>STDIN_FILENO</keyword>
187                 <keyword>STDOUT_FILENO</keyword>
188                 <keyword>STDERR_FILENO</keyword>
189     </context>
190
191     <context id="line-comment" style-ref="comment" end-at-line-end="true" class="comment" class-disabled="no-spell-check">
192       <start>//</start>
193       <include>
194         <context ref="def:in-line-comment"/>
195       </include>
196     </context>
197
198     <context id="block-comment" style-ref="comment" class="comment" class-disabled="no-spell-check">
199       <start>/\*</start>
200       <end>\*/</end>
201       <include>
202         <context ref="def:in-comment"/>
203       </include>
204     </context>
205
206     <define-regex id="int_suffix" extended="true">
207       (i8|i16|i32|i64|i|u8|u16|u32|u64|u)
208     </define-regex>
209
210     <define-regex id="exponent" extended="true">
211       ([eE][+-]?[0-9_]+)
212     </define-regex>
213
214     <define-regex id="float_suffix" extended="true">
215       (\%{exponent}?(f32|f64)?)|(\.[0-9][0-9_]*\%{exponent}?)?(f32|f64)?|\.
216     </define-regex>
217
218     <define-regex id="num_suffix" extended="true">
219       \%{int_suffix}|\%{float_suffix}
220     </define-regex>
221
222     <define-regex id="hex_digit" extended="true">
223       [0-9a-fA-F]
224     </define-regex>
225
226     <define-regex id="oct_digit" extended="true">
227       [0-7]
228     </define-regex>
229
230     <context id="number" style-ref="number">
231       <match extended="true">
232         ((?&lt;=\.\.)|(?&lt;![\w\.]))
233         (
234         [1-9][0-9_]*\%{num_suffix}?|
235         0[0-9_]*\%{num_suffix}?|
236         0b[01_]+\%{int_suffix}?|
237         0o(\%{oct_digit}|_)+\%{int_suffix}?|
238         0x(\%{hex_digit}|_)+\%{int_suffix}?
239         )
240         ((?![\w\.].)|(?=\.\.))
241       </match>
242     </context>
243
244     <define-regex id="ident" extended="true">
245       ([^[:cntrl:][:space:][:punct:][:digit:]]|_)([^[:cntrl:][:punct:][:space:]]|_)*
246     </define-regex>
247
248     <context id="scope" style-ref="scope">
249       <match extended="true">
250         \%{ident}::
251       </match>
252     </context>
253
254     <context id="lifetime" style-ref="keyword">
255       <match extended="true">
256         '\%{ident}
257       </match>
258     </context>
259
260     <define-regex id="common_escape" extended="true">
261       '|"|
262       \\|n|r|t|
263       x\%{hex_digit}{2}|
264       u\%{hex_digit}{4}|
265       U\%{hex_digit}{8}
266     </define-regex>
267
268     <context id="string_escape" style-ref="def:special-char">
269       <match>\\\%{common_escape}</match>
270     </context>
271
272     <context id="raw-string" style-ref="string" class="string" class-disabled="no-spell-check">
273       <start>r(#*)"</start>
274       <end>"\%{1@start}</end>
275       <include>
276         <context ref="def:line-continue"/>
277       </include>
278     </context>
279
280     <context id="string" style-ref="string" class="string" class-disabled="no-spell-check">
281       <start>"</start>
282       <end>"</end>
283       <include>
284         <context ref="string_escape"/>
285         <context ref="def:line-continue"/>
286       </include>
287     </context>
288
289     <context id="char" style-ref="char">
290       <match extended="true">'([^\\']|\\\%{common_escape})'</match>
291     </context>
292
293     <context id="attribute" style-ref="attribute" class="attribute">
294       <start extended="true">\#!?\[</start>
295       <end>\]</end>
296       <include>
297         <context ref="def:in-comment"/>
298         <context ref="string"/>
299         <context ref="raw-string"/>
300       </include>
301     </context>
302
303     <context id="rust" class="no-spell-check">
304       <include>
305         <context ref="function"/>
306         <context ref="type"/>
307         <context ref="keywords"/>
308         <context ref="types"/>
309         <context ref="ctypes"/>
310         <context ref="self"/>
311         <context ref="constants"/>
312         <context ref="cconstants"/>
313         <context ref="line-comment"/>
314         <context ref="block-comment"/>
315         <context ref="number"/>
316         <context ref="scope"/>
317         <context ref="string"/>
318         <context ref="raw-string"/>
319         <context ref="char"/>
320         <context ref="lifetime"/>
321         <context ref="attribute"/>
322       </include>
323     </context>
324
325   </definitions>
326
327 </language>