1<?xml version="1.0" encoding="UTF-8"?> 2<!-- 3 4 This file is part of GtkSourceView 5 6 Authors: Marco Barisione, Emanuele Aina 7 Copyright (C) 2005-2007 Marco Barisione <barisione@gmail.com> 8 Copyright (C) 2005-2007 Emanuele Aina 9 10 GtkSourceView is free software; you can redistribute it and/or 11 modify it under the terms of the GNU Lesser General Public 12 License as published by the Free Software Foundation; either 13 version 2.1 of the License, or (at your option) any later version. 14 15 GtkSourceView is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 Lesser General Public License for more details. 19 20 You should have received a copy of the GNU Lesser General Public License 21 along with this library; if not, see <http://www.gnu.org/licenses/>. 22 23--> 24<language id="c" name="C" version="2.0" _section="Source"> 25 <metadata> 26 <property name="mimetypes">text/x-c;text/x-csrc;image/x-xpixmap</property> 27 <property name="globs">*.c</property> 28 <property name="line-comment-start">//</property> 29 <property name="block-comment-start">/*</property> 30 <property name="block-comment-end">*/</property> 31 </metadata> 32 33 <styles> 34 <style id="comment" name="Comment" map-to="def:comment"/> 35 <style id="string" name="String" map-to="def:string"/> 36 <style id="preprocessor" name="Preprocessor" map-to="def:preprocessor"/> 37 <style id="common-defines" name="Common Defines" map-to="def:special-constant"/> 38 <style id="included-file" name="Included File" map-to="def:string"/> 39 <style id="char" name="Character" map-to="def:character"/> 40 <style id="keyword" name="Keyword" map-to="def:keyword"/> 41 <style id="operator" name="Operator" map-to="def:operator"/> 42 <style id="type" name="Data Type" map-to="def:type"/> 43 <style id="storage-class" name="Storage Class" map-to="def:type"/> 44 <style id="printf" name="printf Conversion" map-to="def:special-char"/> 45 <style id="escaped-character" name="Escaped Character" map-to="def:special-char"/> 46 <style id="floating-point" name="Floating point number" map-to="def:floating-point"/> 47 <style id="decimal" name="Decimal number" map-to="def:decimal"/> 48 <style id="octal" name="Octal number" map-to="def:base-n-integer"/> 49 <style id="hexadecimal" name="Hexadecimal number" map-to="def:base-n-integer"/> 50 <style id="boolean" name="Boolean value" map-to="def:boolean"/> 51 <style id="standard-stream" name="Standard stream" map-to="def:constant"/> 52 <style id="signal-name" name="Signal name" map-to="def:constant"/> 53 <style id="error" name="Error" map-to="def:error"/> 54 </styles> 55 56 <definitions> 57 58 <!--regexs--> 59 <define-regex id="preproc-start">^\s*#\s*</define-regex> 60 <define-regex id="escaped-character" extended="true"> 61 \\( # leading backslash 62 [\\\"\'nrbtfav\?] | # escaped character 63 [0-7]{1,3} | # one, two, or three octal digits 64 x[0-9A-Fa-f]+ # 'x' followed by hex digits 65 ) 66 </define-regex> 67 68 <!--contexts NOT used on the main context--> 69 <!-- TODO: what about scanf ? --> 70 <!-- man 3 printf --> 71 <context id="printf" style-ref="printf" extend-parent="false"> 72 <match extended="true"> 73 \%\%|\% 74 (?:[1-9][0-9]*\$)? # argument 75 [#0\-\ \+\'I]* # flags 76 (?:[1-9][0-9]*|\*)? # width 77 (?:\.\-?(?:[0-9]+|\*))? # precision 78 (?:hh|ll|[hlLqjzt])? # length modifier 79 [diouxXeEfFgGaAcsCSpnm] # conversion specifier 80 </match> 81 </context> 82 83 <!--contexts used on the main context--> 84 <!-- Preprocessor --> 85 <context id="if0-comment" style-ref="comment"> 86 <start>\%{preproc-start}if\b\s*0\b</start> 87 <end>\%{preproc-start}(endif|else|elif)\b</end> 88 <include> 89 <context id="if-in-if0"> 90 <start>\%{preproc-start}if(n?def)?\b</start> 91 <end>\%{preproc-start}endif\b</end> 92 <include> 93 <context ref="if-in-if0"/> 94 <context ref="def:in-comment"/> 95 </include> 96 </context> 97 <context ref="def:in-comment"/> 98 </include> 99 </context> 100 101 <context id="include" style-ref="preprocessor"> 102 <match extended="true"> 103 \%{preproc-start} 104 (include|import)\s* 105 (".*?"|<.*>) 106 </match> 107 <include> 108 <context id="included-file" sub-pattern="2" style-ref="included-file" class="path"/> 109 </include> 110 </context> 111 112 <context id="preprocessor" style-ref="preprocessor" end-at-line-end="true"> 113 <start extended="true"> 114 \%{preproc-start} 115 (define|undef|error|pragma|ident|if(n?def)?|else|elif|endif|line|warning) 116 \b 117 </start> 118 <include> 119 <context ref="def:line-continue" ignore-style="true"/> 120 <context ref="string" ignore-style="true"/> 121 <context ref="def:c-like-comment"/> 122 <context ref="def:c-like-comment-multiline"/> 123 </include> 124 </context> 125 126 <context id="string" style-ref="string" end-at-line-end="true" class="string" class-disabled="no-spell-check"> 127 <start>L?"</start> 128 <end>"</end> 129 <include> 130 <context ref="printf"/> 131 <context id="escaped-character" style-ref="escaped-character"> 132 <match>\%{escaped-character}</match> 133 </context> 134 <context ref="def:line-continue"/> 135 </include> 136 </context> 137 138 <context id="char" style-ref="char" class="string"> 139 <match>L?'(\%{escaped-character}|.)'</match> 140 </context> 141 142 <!-- http://www.lysator.liu.se/c/ANSI-C-grammar-l.html --> 143 <context id="float" style-ref="floating-point"> 144 <match extended="true"> 145 (?<![\w\.]) 146 ((\.[0-9]+ | [0-9]+\.[0-9]*) ([Ee][+-]?[0-9]*)? | 147 ([0-9]+[Ee][+-]?[0-9]*)) 148 [fFlL]? 149 (?![\w\.]) 150 </match> 151 </context> 152 153 <context id="hexadecimal" style-ref="hexadecimal"> 154 <match extended="true"> 155 (?<![\w\.]) 156 0[xX][a-fA-F0-9]+[uUlL]* 157 (?![\w\.]) 158 </match> 159 </context> 160 161 <context id="invalid-hexadecimal" style-ref="error"> 162 <match extended="true"> 163 (?<![\w\.]) 164 0[xX][a-fA-F0-9]*[g-zG-Z][a-zA-Z0-9]*[uUlL]* 165 (?![\w\.]) 166 </match> 167 </context> 168 169 <context id="octal" style-ref="octal"> 170 <match extended="true"> 171 (?<![\w\.]) 172 0[0-7]+[uUlL]* 173 (?![\w\.]) 174 </match> 175 </context> 176 177 <context id="invalid-octal" style-ref="error"> 178 <match extended="true"> 179 (?<![\w\.]) 180 0[0-7]*[89][0-9]*[uUlL]* 181 (?![\w\.]) 182 </match> 183 </context> 184 185 <context id="decimal" style-ref="decimal"> 186 <match extended="true"> 187 (?<![\w\.]) 188 (0|[1-9][0-9]*)[uUlL]* 189 (?![\w\.]) 190 </match> 191 </context> 192 193 <context id="keywords" style-ref="keyword"> 194 <keyword>asm</keyword> 195 <keyword>break</keyword> 196 <keyword>case</keyword> 197 <keyword>continue</keyword> 198 <keyword>default</keyword> 199 <keyword>do</keyword> 200 <keyword>else</keyword> 201 <keyword>enum</keyword> 202 <keyword>for</keyword> 203 <keyword>fortran</keyword> 204 <keyword>goto</keyword> 205 <keyword>if</keyword> 206 <keyword>return</keyword> 207 <keyword>struct</keyword> 208 <keyword>switch</keyword> 209 <keyword>typedef</keyword> 210 <keyword>union</keyword> 211 <keyword>while</keyword> 212 </context> 213 214 <context id="operators" style-ref="operator"> 215 <keyword>(_A|a)lignof</keyword> 216 <keyword>_Generic</keyword> 217 <keyword>offsetof</keyword> 218 <keyword>(_S|s)tatic_assert</keyword> 219 <keyword>sizeof</keyword> 220 <keyword>typeof</keyword> 221 </context> 222 223 <context id="types" style-ref="type"> 224 <keyword>_Bool</keyword> 225 <keyword>_Complex</keyword> 226 <keyword>_Imaginary</keyword> 227 <keyword>bool</keyword> 228 <keyword>char</keyword> 229 <keyword>char(16|32)_t</keyword> 230 <keyword>double(_t)?</keyword> 231 <keyword>float(_t)?</keyword> 232 <keyword>int</keyword> 233 <keyword>(u)?int(_least|_fast)?(8|16|32|64)_t</keyword> 234 <keyword>(u)?intmax_t</keyword> 235 <keyword>(u)?intptr_t</keyword> 236 <keyword>long</keyword> 237 <keyword>ptrdiff_t</keyword> 238 <keyword>off(64)?_t</keyword> 239 <keyword>short</keyword> 240 <keyword>signed</keyword> 241 <keyword>size_t</keyword> 242 <keyword>ssize_t</keyword> 243 <keyword>unsigned</keyword> 244 <keyword>void</keyword> 245 <keyword>wchar_t</keyword> 246 <keyword>wint_t</keyword> 247 </context> 248 249 <context id="storage-class" style-ref="storage-class"> 250 <keyword>(_A|a)lignas</keyword> 251 <keyword>_Atomic</keyword> 252 <keyword>(_N|n)oreturn</keyword> 253 <keyword>(_T|t)hread_local</keyword> 254 <keyword>auto</keyword> 255 <keyword>const</keyword> 256 <keyword>extern</keyword> 257 <keyword>inline</keyword> 258 <keyword>register</keyword> 259 <keyword>restrict</keyword> 260 <keyword>static</keyword> 261 <keyword>volatile</keyword> 262 </context> 263 264 <!-- C99 booleans --> 265 <context id="boolean" style-ref="boolean"> 266 <keyword>true</keyword> 267 <keyword>false</keyword> 268 </context> 269 270 <context id="common-defines" style-ref="common-defines"> 271 <keyword>NULL</keyword> 272 <keyword>MAX</keyword> 273 <keyword>MIN</keyword> 274 <keyword>TRUE</keyword> 275 <keyword>FALSE</keyword> 276 <keyword>__LINE__</keyword> 277 <keyword>__DATA__</keyword> 278 <keyword>__FILE__</keyword> 279 <keyword>__func__</keyword> 280 <keyword>__TIME__</keyword> 281 <keyword>__STDC__</keyword> 282 </context> 283 284 <context id="standard-streams" style-ref="standard-stream"> 285 <keyword>stdin</keyword> 286 <keyword>stdout</keyword> 287 <keyword>stderr</keyword> 288 </context> 289 290 <context id="signals" style-ref="signal-name"> 291 <keyword>SIGABRT</keyword> 292 <keyword>SIGALRM</keyword> 293 <keyword>SIGCHLD</keyword> 294 <keyword>SIGCONT</keyword> 295 <keyword>SIGFPE</keyword> 296 <keyword>SIGHUP</keyword> 297 <keyword>SIGILL</keyword> 298 <keyword>SIGINT</keyword> 299 <keyword>SIGKILL</keyword> 300 <keyword>SIGPIPE</keyword> 301 <keyword>SIGQUIT</keyword> 302 <keyword>SIGSEGV</keyword> 303 <keyword>SIGSTOP</keyword> 304 <keyword>SIGTERM</keyword> 305 <keyword>SIGTRAP</keyword> 306 <keyword>SIGTSTP</keyword> 307 <keyword>SIGTTIN</keyword> 308 <keyword>SIGTTOU</keyword> 309 <keyword>SIGUSR1</keyword> 310 <keyword>SIGUSR2</keyword> 311 </context> 312 313 <!--Main context--> 314 <context id="c" class="no-spell-check"> 315 <include> 316 <context ref="gtk-doc:inline-docs-section"/> 317 <context ref="def:c-like-comment" style-ref="comment"/> 318 <context ref="def:c-like-comment-multiline" style-ref="comment"/> 319 <context ref="def:c-like-close-comment-outside-comment" style-ref="comment"/> 320 <context ref="if0-comment"/> 321 <context ref="include"/> 322 <context ref="preprocessor"/> 323 <context ref="string"/> 324 <context ref="char"/> 325 <context ref="float"/> 326 <context ref="hexadecimal"/> 327 <context ref="invalid-hexadecimal"/> 328 <context ref="octal"/> 329 <context ref="invalid-octal"/> 330 <context ref="decimal"/> 331 <context ref="keywords"/> 332 <context ref="operators"/> 333 <context ref="types"/> 334 <context ref="storage-class"/> 335 <context ref="boolean"/> 336 <context ref="common-defines"/> 337 <context ref="standard-streams"/> 338 <context ref="signals"/> 339 </include> 340 </context> 341 342 </definitions> 343</language> 344