| 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:keyword"/> |
|---|
| 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:keyword" /> |
|---|
| 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="multiline-comment"/> |
|---|
| 126 | <context ref="def:in-comment" /> |
|---|
| 127 | </include> |
|---|
| 128 | </context> |
|---|
| 129 | |
|---|
| 130 | <context id="cobra"> |
|---|
| 131 | <include> |
|---|
| 132 | <context ref="def:shebang"/> |
|---|
| 133 | <context ref="args" /> |
|---|
| 134 | <context ref="single-quoted-docstring" /> |
|---|
| 135 | <context ref="double-quoted-docstring" /> |
|---|
| 136 | <context ref="double-quoted-string" /> |
|---|
| 137 | <context ref="single-quoted-string" /> |
|---|
| 138 | <context ref="multiline-comment" /> |
|---|
| 139 | <context ref="singleline-comment" /> |
|---|
| 140 | |
|---|
| 141 | <context id="specials" style-ref="special"> |
|---|
| 142 | <prefix>(?<![\w\.])</prefix> |
|---|
| 143 | <keyword>base</keyword> |
|---|
| 144 | <keyword>this</keyword> |
|---|
| 145 | </context> |
|---|
| 146 | |
|---|
| 147 | <context id="constants" style-ref="builtin-constant"> |
|---|
| 148 | <prefix>(?<![\w\.])</prefix> |
|---|
| 149 | <keyword>true</keyword> |
|---|
| 150 | <keyword>false</keyword> |
|---|
| 151 | <keyword>nil</keyword> |
|---|
| 152 | </context> |
|---|
| 153 | |
|---|
| 154 | <context id="float" style-ref="number"> |
|---|
| 155 | <match>\%{def:float}</match> |
|---|
| 156 | </context> |
|---|
| 157 | |
|---|
| 158 | <context id="decimal" style-ref="number"> |
|---|
| 159 | <match>(?<![\w\.])([1-9][0-9]*|0)[lL]?(?![\w\.])</match> |
|---|
| 160 | </context> |
|---|
| 161 | |
|---|
| 162 | <context id="octal" style-ref="number"> |
|---|
| 163 | <match>(?<![\w\.])0[0-7]+[lL]?(?![\w\.])</match> |
|---|
| 164 | </context> |
|---|
| 165 | |
|---|
| 166 | <context id="hex" style-ref="number"> |
|---|
| 167 | <match>(?<![\w\.])0[xX][0-9A-Fa-f]+[lL]?(?![\w\.])</match> |
|---|
| 168 | </context> |
|---|
| 169 | |
|---|
| 170 | <context id="integer" style-ref="number"> |
|---|
| 171 | <match extended="true"> |
|---|
| 172 | (?<![\w\.]) |
|---|
| 173 | [1-9][\d_]* |
|---|
| 174 | </match> |
|---|
| 175 | </context> |
|---|
| 176 | |
|---|
| 177 | <context id="namespace-handler" style-ref="namespace"> |
|---|
| 178 | <keyword>use</keyword> |
|---|
| 179 | <keyword>import</keyword> |
|---|
| 180 | </context> |
|---|
| 181 | |
|---|
| 182 | <context id="simple-type"> |
|---|
| 183 | <match extended="true"> |
|---|
| 184 | \b(as)\s+ |
|---|
| 185 | ((?:out|inout|vari)\s+)? |
|---|
| 186 | ((?:\%{type-identifier}\.?)+\??) |
|---|
| 187 | (?!<) # generic openers should not be handled here, they are part of "generic-type" |
|---|
| 188 | </match> |
|---|
| 189 | <include> |
|---|
| 190 | <context sub-pattern="1" style-ref="keyword" /> |
|---|
| 191 | <context sub-pattern="2" style-ref="keyword" /> |
|---|
| 192 | <context sub-pattern="3" style-ref="language-type" /> |
|---|
| 193 | </include> |
|---|
| 194 | </context> |
|---|
| 195 | |
|---|
| 196 | <context id="typecasting"> |
|---|
| 197 | <match extended="true"> |
|---|
| 198 | \b(to)\s+ |
|---|
| 199 | ((?:\%{type-identifier}\.?)*\??) |
|---|
| 200 | (?!<) # generic openers should not be handled as with "simple-type" |
|---|
| 201 | </match> |
|---|
| 202 | <include> |
|---|
| 203 | <context sub-pattern="1" style-ref="keyword" /> |
|---|
| 204 | <context sub-pattern="2" style-ref="language-type" /> |
|---|
| 205 | </include> |
|---|
| 206 | </context> |
|---|
| 207 | |
|---|
| 208 | <context id="generic-part" extend-parent="false"> |
|---|
| 209 | <match>(of)\s+(\%{type-identifier})(?!<)</match> |
|---|
| 210 | <include> |
|---|
| 211 | <context sub-pattern="1" style-ref="keyword" /> |
|---|
| 212 | <context sub-pattern="2" style-ref="language-type" /> |
|---|
| 213 | </include> |
|---|
| 214 | </context> |
|---|
| 215 | |
|---|
| 216 | <context id="generic-type" extend-parent="false" style-inside="true"> |
|---|
| 217 | <start>((?:out|inout|vari|to)\s+)?(\%{type-identifier})<</start> |
|---|
| 218 | <end>>(?!>)</end> |
|---|
| 219 | <include> |
|---|
| 220 | <context sub-pattern="1" where="start" style-ref="keyword" /> |
|---|
| 221 | <context sub-pattern="2" where="start" style-ref="language-type" /> |
|---|
| 222 | <context ref="generic-part" /> |
|---|
| 223 | <context ref="generic-type" /> |
|---|
| 224 | <context style-ref="keyword" extend-parent="false"> |
|---|
| 225 | <match>,\s*(\%{type-identifier})</match> |
|---|
| 226 | <include> |
|---|
| 227 | <context sub-pattern="1" style-ref="language-type" /> |
|---|
| 228 | </include> |
|---|
| 229 | </context> |
|---|
| 230 | </include> |
|---|
| 231 | </context> |
|---|
| 232 | |
|---|
| 233 | <context id="initialization"> |
|---|
| 234 | <start extended="true"> |
|---|
| 235 | (?<![\w\.]|(?:def|cue|sig|pro|get|set)\s) |
|---|
| 236 | (\%{type-identifier}) |
|---|
| 237 | (\() # opening paren |
|---|
| 238 | </start> |
|---|
| 239 | <end>\)(?!\))</end> |
|---|
| 240 | <include> |
|---|
| 241 | <context sub-pattern="1" where="start" style-ref="language-type" /> |
|---|
| 242 | <context ref="initialization" /> |
|---|
| 243 | <context ref="double-quoted-string" /> |
|---|
| 244 | <context ref="single-quoted-string" /> |
|---|
| 245 | <context ref="specials" /> |
|---|
| 246 | <context ref="constants" /> |
|---|
| 247 | <context ref="float" /> |
|---|
| 248 | <context ref="decimal" /> |
|---|
| 249 | <context ref="octal" /> |
|---|
| 250 | <context ref="hex" /> |
|---|
| 251 | <context ref="simple-type" /> |
|---|
| 252 | <context ref="generic-type" /> |
|---|
| 253 | </include> |
|---|
| 254 | </context> |
|---|
| 255 | |
|---|
| 256 | <context id="access-modifiers" style-ref="access-modifier"> |
|---|
| 257 | <keyword>abstract</keyword> |
|---|
| 258 | <keyword>internal</keyword> |
|---|
| 259 | <keyword>new</keyword> |
|---|
| 260 | <keyword>nonvirtual</keyword> |
|---|
| 261 | <keyword>override</keyword> |
|---|
| 262 | <keyword>partial</keyword> |
|---|
| 263 | <keyword>private</keyword> |
|---|
| 264 | <keyword>protected</keyword> |
|---|
| 265 | <keyword>public</keyword> |
|---|
| 266 | <keyword>readonly</keyword> |
|---|
| 267 | <keyword>shared</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>adds</keyword> |
|---|
| 281 | <keyword>all</keyword> |
|---|
| 282 | <keyword>and</keyword> |
|---|
| 283 | <keyword>any</keyword> |
|---|
| 284 | <keyword>as</keyword> |
|---|
| 285 | <keyword>assert</keyword> |
|---|
| 286 | <keyword>base</keyword> |
|---|
| 287 | <keyword>body</keyword> |
|---|
| 288 | <keyword>branch</keyword> |
|---|
| 289 | <keyword>break</keyword> |
|---|
| 290 | <keyword>callable</keyword> |
|---|
| 291 | <keyword>catch</keyword> |
|---|
| 292 | <keyword>class</keyword> |
|---|
| 293 | <keyword>const</keyword> |
|---|
| 294 | <keyword>continue</keyword> |
|---|
| 295 | <keyword>cue</keyword> |
|---|
| 296 | <keyword>def</keyword> |
|---|
| 297 | <keyword>do</keyword> |
|---|
| 298 | <keyword>each</keyword> |
|---|
| 299 | <keyword>else</keyword> |
|---|
| 300 | <keyword>end</keyword> |
|---|
| 301 | <keyword>ensure</keyword> |
|---|
| 302 | <keyword>enum</keyword> |
|---|
| 303 | <keyword>event</keyword> |
|---|
| 304 | <keyword>every</keyword> |
|---|
| 305 | <keyword>except</keyword> |
|---|
| 306 | <keyword>expect</keyword> |
|---|
| 307 | <keyword>extend</keyword> |
|---|
| 308 | <keyword>finally</keyword> |
|---|
| 309 | <keyword>for</keyword> |
|---|
| 310 | <keyword>from</keyword> |
|---|
| 311 | <keyword>get</keyword> |
|---|
| 312 | <keyword>has</keyword> |
|---|
| 313 | <keyword>if</keyword> |
|---|
| 314 | <keyword>ignore</keyword> |
|---|
| 315 | <keyword>implements</keyword> |
|---|
| 316 | <keyword>implies</keyword> |
|---|
| 317 | <keyword>in</keyword> |
|---|
| 318 | <keyword>inherits</keyword> |
|---|
| 319 | <keyword>inlined</keyword> |
|---|
| 320 | <keyword>inout</keyword> |
|---|
| 321 | <keyword>interface</keyword> |
|---|
| 322 | <keyword>invariant</keyword> |
|---|
| 323 | <keyword>is</keyword> |
|---|
| 324 | <keyword>listen</keyword> |
|---|
| 325 | <keyword>lock</keyword> |
|---|
| 326 | <keyword>mixin</keyword> |
|---|
| 327 | <keyword>must</keyword> |
|---|
| 328 | <keyword>namespace</keyword> |
|---|
| 329 | <keyword>not</keyword> |
|---|
| 330 | <keyword>objc</keyword> |
|---|
| 331 | <keyword>of</keyword> |
|---|
| 332 | <keyword>old</keyword> |
|---|
| 333 | <keyword>on</keyword> |
|---|
| 334 | <keyword>or</keyword> |
|---|
| 335 | <keyword>out</keyword> |
|---|
| 336 | <keyword>par</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>result</keyword> |
|---|
| 346 | <keyword>return</keyword> |
|---|
| 347 | <keyword>same</keyword> |
|---|
| 348 | <keyword>set</keyword> |
|---|
| 349 | <keyword>sig</keyword> |
|---|
| 350 | <keyword>stop</keyword> |
|---|
| 351 | <keyword>struct</keyword> |
|---|
| 352 | <keyword>success</keyword> |
|---|
| 353 | <keyword>test</keyword> |
|---|
| 354 | <keyword>this</keyword> |
|---|
| 355 | <keyword>throw</keyword> |
|---|
| 356 | <keyword>to</keyword> |
|---|
| 357 | <keyword>trace</keyword> |
|---|
| 358 | <keyword>try</keyword> |
|---|
| 359 | <keyword>using</keyword> |
|---|
| 360 | <keyword>value</keyword> |
|---|
| 361 | <keyword>var</keyword> |
|---|
| 362 | <keyword>vari</keyword> |
|---|
| 363 | <keyword>where</keyword> |
|---|
| 364 | <keyword>while</keyword> |
|---|
| 365 | <keyword>yield</keyword> |
|---|
| 366 | </context> |
|---|
| 367 | </include> |
|---|
| 368 | </context> |
|---|
| 369 | </definitions> |
|---|
| 370 | </language> |
|---|