1 | <?xml version="1.0" encoding="UTF-8"?> |
---|
2 | <language id="cobra" _name="Cobra" version="2.0" _section="Sources"> |
---|
3 | <metadata> |
---|
4 | <property name="mimetypes"></property> |
---|
5 | <property name="globs">*.cobra;*.COBRA</property> |
---|
6 | <property name="line-comment-start"></property> |
---|
7 | </metadata> |
---|
8 | |
---|
9 | <styles> |
---|
10 | <style id="namespace" _name="Namespace" map-to="def:preprocessor"/> |
---|
11 | <style id="keyword" _name="Keyword" map-to="def:keyword"/> |
---|
12 | <style id="multiline-string" _name="Multiline string" map-to="def:string"/> |
---|
13 | <style id="string" _name="String" map-to="def:string"/> |
---|
14 | <style id="string-sub" _name="String Substitution" map-to="def:special-char"/> |
---|
15 | <style id="character" _name="Character" map-to="def:character" /> |
---|
16 | <style id="escaped-character" _name="Escaped Character" map-to="def:special-char"/> |
---|
17 | <style id="special" _name="Special Variable" map-to="def:identifier"/> |
---|
18 | <style id="number" _name="Numbers" map-to="def:number"/> |
---|
19 | <style id="builtin-constant" _name="Builtin Constant" map-to="def:special-constant"/> |
---|
20 | <style id="language-type" _name="Language Type" map-to="def:type"/> |
---|
21 | <style id="builtin-function" _name="Builtin Function" map-to="def:builtin"/> |
---|
22 | <style id="comment" _name="Comment" map-to="def:comment"/> |
---|
23 | <style id="access-modifier" _name="Access Modifier" map-to="def:preprocessor" /> |
---|
24 | <style id="operator" _name="Operator" map-to="def:operator" /> |
---|
25 | </styles> |
---|
26 | |
---|
27 | <definitions> |
---|
28 | <define-regex id="identifier">[_a-zA-Z][_a-zA-Z0-9]*</define-regex> |
---|
29 | <define-regex id="type-identifier">[a-zA-Z][_a-zA-Z0-9]*</define-regex> |
---|
30 | <define-regex id="number">[1-9][0-9]*</define-regex> |
---|
31 | <define-regex id="string-prefix">[cnrsu]*|[CNRSU]*</define-regex> |
---|
32 | |
---|
33 | <context id="escaped-character" style-ref="escaped-character" extend-parent="true"> |
---|
34 | <match extended="true"> |
---|
35 | \\( # leading backslash |
---|
36 | [\\'"abfnrtv] | # single escaped char |
---|
37 | u[0-9A-Fa-f]{4} | # xxxx - character with 16-bit hex value xxxx |
---|
38 | x[0-9A-Fa-f]{1,2} | # \xhh - character with hex value hh |
---|
39 | [0-7]{1,3} # \ooo - character with octal value ooo |
---|
40 | ) |
---|
41 | </match> |
---|
42 | </context> |
---|
43 | |
---|
44 | <context id="string-substitution" style-ref="def:preprocessor" extend-parent="false"> |
---|
45 | <match>\[([\w.\[\]_-]+)\]</match> |
---|
46 | </context> |
---|
47 | |
---|
48 | <context id="escaped-string-substitution" style-ref="string" extend-parent="false"> |
---|
49 | <match>\\\[([\w.\[\]_-]+)\]</match> |
---|
50 | </context> |
---|
51 | |
---|
52 | <context id="double-quoted-string" style-ref="string" end-at-line-end="true"> |
---|
53 | <start>(?<!")(\%{string-prefix})"</start> |
---|
54 | <end>"</end> |
---|
55 | <include> |
---|
56 | <context sub-pattern="1" where="start" style-ref="comment" /> |
---|
57 | <context ref="escaped-character"/> |
---|
58 | <context ref="string-substitution" /> |
---|
59 | <context ref="escaped-string-substitution" /> |
---|
60 | </include> |
---|
61 | </context> |
---|
62 | |
---|
63 | <context id="single-quoted-string" style-ref="string" end-at-line-end="true"> |
---|
64 | <start>(?<!')(\%{string-prefix})'</start> |
---|
65 | <end>'</end> |
---|
66 | <include> |
---|
67 | <context sub-pattern="1" where="start" style-ref="comment" /> |
---|
68 | <context ref="escaped-character"/> |
---|
69 | <context ref="def:line-continue"/> |
---|
70 | <context ref="string-substitution" /> |
---|
71 | <context ref="escaped-string-substitution" /> |
---|
72 | </include> |
---|
73 | </context> |
---|
74 | |
---|
75 | <context id="single-quoted-docstring" style-ref="comment"> |
---|
76 | <start>^\s*'''</start> |
---|
77 | <end>'''</end> |
---|
78 | <include> |
---|
79 | <context ref="def:in-comment" /> |
---|
80 | </include> |
---|
81 | </context> |
---|
82 | |
---|
83 | <context id="double-quoted-docstring" style-ref="comment"> |
---|
84 | <start>^\s*"""</start> |
---|
85 | <end>\s*"""</end> |
---|
86 | <include> |
---|
87 | <context ref="def:in-comment" /> |
---|
88 | </include> |
---|
89 | </context> |
---|
90 | |
---|
91 | <context id="argpair"> |
---|
92 | <match>\s+\-([\w\-]+):\s*([^\s]+)</match> |
---|
93 | <include> |
---|
94 | <context sub-pattern="1" style-ref="comment" /> |
---|
95 | <context sub-pattern="2" style-ref="special" /> |
---|
96 | </include> |
---|
97 | </context> |
---|
98 | |
---|
99 | <context id="args"> |
---|
100 | <start>(@args)</start> |
---|
101 | <end>$</end> |
---|
102 | <include> |
---|
103 | <context sub-pattern="1" where="start" style-ref="namespace" /> |
---|
104 | <context ref="argpair" /> |
---|
105 | </include> |
---|
106 | </context> |
---|
107 | |
---|
108 | <context id="test-markers" style-ref="access-modifier"> |
---|
109 | <match>\.(warning|error|require|args|compile\-only|no\-warnings|skip)\.</match> |
---|
110 | </context> |
---|
111 | |
---|
112 | <context id="singleline-comment" style-ref="comment"> |
---|
113 | <start>#</start> |
---|
114 | <end>$</end> |
---|
115 | <include> |
---|
116 | <context ref="def:in-comment" /> |
---|
117 | <context ref="test-markers" /> |
---|
118 | </include> |
---|
119 | </context> |
---|
120 | |
---|
121 | <context id="multiline-comment" style-ref="comment"> |
---|
122 | <start>\/#</start> |
---|
123 | <end>#\/</end> |
---|
124 | <include> |
---|
125 | <context ref="def:in-comment" /> |
---|
126 | </include> |
---|
127 | </context> |
---|
128 | |
---|
129 | <context id="cobra"> |
---|
130 | <include> |
---|
131 | <context ref="def:shebang"/> |
---|
132 | <context ref="args" /> |
---|
133 | <context ref="single-quoted-docstring" /> |
---|
134 | <context ref="double-quoted-docstring" /> |
---|
135 | <context ref="double-quoted-string" /> |
---|
136 | <context ref="single-quoted-string" /> |
---|
137 | <context ref="multiline-comment" /> |
---|
138 | <context ref="singleline-comment" /> |
---|
139 | |
---|
140 | <context id="specials" style-ref="special"> |
---|
141 | <prefix>(?<![\w\.])</prefix> |
---|
142 | <keyword>base</keyword> |
---|
143 | <keyword>this</keyword> |
---|
144 | </context> |
---|
145 | |
---|
146 | <context id="constants" style-ref="builtin-constant"> |
---|
147 | <prefix>(?<![\w\.])</prefix> |
---|
148 | <keyword>true</keyword> |
---|
149 | <keyword>false</keyword> |
---|
150 | <keyword>nil</keyword> |
---|
151 | </context> |
---|
152 | |
---|
153 | <context id="float" style-ref="number"> |
---|
154 | <match>\%{def:float}</match> |
---|
155 | </context> |
---|
156 | |
---|
157 | <context id="decimal" style-ref="number"> |
---|
158 | <match>(?<![\w\.])([1-9][0-9]*|0)[lL]?(?![\w\.])</match> |
---|
159 | </context> |
---|
160 | |
---|
161 | <context id="octal" style-ref="number"> |
---|
162 | <match>(?<![\w\.])0[0-7]+[lL]?(?![\w\.])</match> |
---|
163 | </context> |
---|
164 | |
---|
165 | <context id="hex" style-ref="number"> |
---|
166 | <match>(?<![\w\.])0[xX][0-9A-Fa-f]+[lL]?(?![\w\.])</match> |
---|
167 | </context> |
---|
168 | |
---|
169 | <context id="integer" style-ref="number"> |
---|
170 | <match extended="true"> |
---|
171 | (?<![\w\.]) |
---|
172 | [1-9][\d_]* |
---|
173 | </match> |
---|
174 | </context> |
---|
175 | |
---|
176 | <context id="namespace-handler" style-ref="namespace"> |
---|
177 | <keyword>use</keyword> |
---|
178 | <keyword>import</keyword> |
---|
179 | </context> |
---|
180 | |
---|
181 | <context id="simple-type"> |
---|
182 | <match extended="true"> |
---|
183 | \b(as)\s+ |
---|
184 | ((?:out|inout|vari)\s+)? |
---|
185 | ((?:\%{type-identifier}\.?)+\??) |
---|
186 | (?!<) # generic openers should not be handled here, they are part of "generic-type" |
---|
187 | </match> |
---|
188 | <include> |
---|
189 | <context sub-pattern="1" style-ref="keyword" /> |
---|
190 | <context sub-pattern="2" style-ref="keyword" /> |
---|
191 | <context sub-pattern="3" style-ref="language-type" /> |
---|
192 | </include> |
---|
193 | </context> |
---|
194 | |
---|
195 | <context id="typecasting"> |
---|
196 | <match extended="true"> |
---|
197 | \b(to)\s+ |
---|
198 | ((?:\%{type-identifier}\.?)*\??) |
---|
199 | (?!<) # generic openers should not be handled as with "simple-type" |
---|
200 | </match> |
---|
201 | <include> |
---|
202 | <context sub-pattern="1" style-ref="keyword" /> |
---|
203 | <context sub-pattern="2" style-ref="language-type" /> |
---|
204 | </include> |
---|
205 | </context> |
---|
206 | |
---|
207 | <context id="generic-part" extend-parent="false"> |
---|
208 | <match>(of)\s+(\%{type-identifier})(?!<)</match> |
---|
209 | <include> |
---|
210 | <context sub-pattern="1" style-ref="keyword" /> |
---|
211 | <context sub-pattern="2" style-ref="language-type" /> |
---|
212 | </include> |
---|
213 | </context> |
---|
214 | |
---|
215 | <context id="generic-type" extend-parent="false" style-inside="true"> |
---|
216 | <start>((?:out|inout|vari|to)\s+)?(\%{type-identifier})<</start> |
---|
217 | <end>>(?!>)</end> |
---|
218 | <include> |
---|
219 | <context sub-pattern="1" where="start" style-ref="keyword" /> |
---|
220 | <context sub-pattern="2" where="start" style-ref="language-type" /> |
---|
221 | <context ref="generic-part" /> |
---|
222 | <context ref="generic-type" /> |
---|
223 | <context style-ref="keyword" extend-parent="false"> |
---|
224 | <match>,\s*(\%{type-identifier})</match> |
---|
225 | <include> |
---|
226 | <context sub-pattern="1" style-ref="language-type" /> |
---|
227 | </include> |
---|
228 | </context> |
---|
229 | </include> |
---|
230 | </context> |
---|
231 | |
---|
232 | <context id="initialization"> |
---|
233 | <start extended="true"> |
---|
234 | (?<![\w\.]|(?:def|cue|sig|pro|get|set)\s) |
---|
235 | (\%{type-identifier}) |
---|
236 | (\() # opening paren |
---|
237 | </start> |
---|
238 | <end>\)(?!\))</end> |
---|
239 | <include> |
---|
240 | <context sub-pattern="1" where="start" style-ref="language-type" /> |
---|
241 | <context ref="initialization" /> |
---|
242 | <context ref="double-quoted-string" /> |
---|
243 | <context ref="single-quoted-string" /> |
---|
244 | <context ref="specials" /> |
---|
245 | <context ref="constants" /> |
---|
246 | <context ref="float" /> |
---|
247 | <context ref="decimal" /> |
---|
248 | <context ref="octal" /> |
---|
249 | <context ref="hex" /> |
---|
250 | <context ref="simple-type" /> |
---|
251 | <context ref="generic-type" /> |
---|
252 | </include> |
---|
253 | </context> |
---|
254 | |
---|
255 | <context id="access-modifiers" style-ref="access-modifier"> |
---|
256 | <keyword>abstract</keyword> |
---|
257 | <keyword>fake</keyword> |
---|
258 | <keyword>internal</keyword> |
---|
259 | <keyword>new</keyword> |
---|
260 | <keyword>nonvirtual</keyword> |
---|
261 | <keyword>private</keyword> |
---|
262 | <keyword>protected</keyword> |
---|
263 | <keyword>public</keyword> |
---|
264 | <keyword>shared</keyword> |
---|
265 | |
---|
266 | <keyword>override</keyword> |
---|
267 | <keyword>partial</keyword> |
---|
268 | <keyword>virtual</keyword> |
---|
269 | </context> |
---|
270 | |
---|
271 | <context> |
---|
272 | <match>([\+\-\*\/=%!\?&<>]+)</match> |
---|
273 | <include> |
---|
274 | <context sub-pattern="1" style-ref="keyword" /> |
---|
275 | </include> |
---|
276 | </context> |
---|
277 | |
---|
278 | <context id="keyword" style-ref="keyword"> |
---|
279 | <prefix>(?<![\.])\b</prefix> |
---|
280 | <keyword>vari</keyword> |
---|
281 | <keyword>inout</keyword> |
---|
282 | <keyword>out</keyword> |
---|
283 | <keyword>adds</keyword> |
---|
284 | <keyword>all</keyword> |
---|
285 | <keyword>and</keyword> |
---|
286 | <keyword>any</keyword> |
---|
287 | <keyword>as</keyword> |
---|
288 | <keyword>assert</keyword> |
---|
289 | <keyword>base</keyword> |
---|
290 | <keyword>body</keyword> |
---|
291 | <keyword>branch</keyword> |
---|
292 | <keyword>break</keyword> |
---|
293 | <keyword>callable</keyword> |
---|
294 | <keyword>catch</keyword> |
---|
295 | <keyword>class</keyword> |
---|
296 | <keyword>const</keyword> |
---|
297 | <keyword>continue</keyword> |
---|
298 | <keyword>cue</keyword> |
---|
299 | <keyword>def</keyword> |
---|
300 | <keyword>do</keyword> |
---|
301 | <keyword>dynamiceach</keyword> |
---|
302 | <keyword>else</keyword> |
---|
303 | <keyword>end</keyword> |
---|
304 | <keyword>ensure</keyword> |
---|
305 | <keyword>enum</keyword> |
---|
306 | <keyword>event</keyword> |
---|
307 | <keyword>every</keyword> |
---|
308 | <keyword>except</keyword> |
---|
309 | <keyword>expect</keyword> |
---|
310 | <keyword>extend</keyword> |
---|
311 | <keyword>finally</keyword> |
---|
312 | <keyword>for</keyword> |
---|
313 | <keyword>from</keyword> |
---|
314 | <keyword>get</keyword> |
---|
315 | <keyword>has</keyword> |
---|
316 | <keyword>if</keyword> |
---|
317 | <keyword>ignore</keyword> |
---|
318 | <keyword>implements</keyword> |
---|
319 | <keyword>implies</keyword> |
---|
320 | <keyword>in</keyword> |
---|
321 | <keyword>inherits</keyword> |
---|
322 | <keyword>inlined</keyword> |
---|
323 | <keyword>interface</keyword> |
---|
324 | <keyword>invariant</keyword> |
---|
325 | <keyword>is</keyword> |
---|
326 | <keyword>listen</keyword> |
---|
327 | <keyword>lock</keyword> |
---|
328 | <keyword>mixin</keyword> |
---|
329 | <keyword>must</keyword> |
---|
330 | <keyword>namespace</keyword> |
---|
331 | <keyword>not</keyword> |
---|
332 | <keyword>objc</keyword> |
---|
333 | <keyword>of</keyword> |
---|
334 | <keyword>old</keyword> |
---|
335 | <keyword>on</keyword> |
---|
336 | <keyword>or</keyword> |
---|
337 | <keyword>pass</keyword> |
---|
338 | <keyword>passthrough</keyword> |
---|
339 | <keyword>post</keyword> |
---|
340 | <keyword>print</keyword> |
---|
341 | <keyword>pro</keyword> |
---|
342 | <keyword>raise</keyword> |
---|
343 | <keyword>ref</keyword> |
---|
344 | <keyword>require</keyword> |
---|
345 | <keyword>return</keyword> |
---|
346 | <keyword>same</keyword> |
---|
347 | <keyword>set</keyword> |
---|
348 | <keyword>sig</keyword> |
---|
349 | <keyword>stop</keyword> |
---|
350 | <keyword>struct</keyword> |
---|
351 | <keyword>success</keyword> |
---|
352 | <keyword>test</keyword> |
---|
353 | <keyword>this</keyword> |
---|
354 | <keyword>throw</keyword> |
---|
355 | <keyword>to</keyword> |
---|
356 | <keyword>trace</keyword> |
---|
357 | <keyword>try</keyword> |
---|
358 | <keyword>using</keyword> |
---|
359 | <keyword>var</keyword> |
---|
360 | <keyword>where</keyword> |
---|
361 | <keyword>while</keyword> |
---|
362 | <keyword>yield</keyword> |
---|
363 | </context> |
---|
364 | </include> |
---|
365 | </context> |
---|
366 | </definitions> |
---|
367 | </language> |
---|
368 | |
---|