239 lines
10 KiB
XML
239 lines
10 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<language id="c" _name="C" version="2.0" _section="Sources">
|
|
<metadata>
|
|
<property name="mimetypes">text/x-c;text/x-csrc</property>
|
|
<property name="globs">*.c</property>
|
|
<property name="line-comment-start">//</property>
|
|
<property name="block-comment-start">/*</property>
|
|
<property name="block-comment-end">*/</property>
|
|
</metadata>
|
|
|
|
<styles>
|
|
<style id="comment" _name="Comment" map-to="def:comment"/>
|
|
<style id="error" _name="Error" map-to="def:error"/>
|
|
<style id="string" _name="String" map-to="def:string"/>
|
|
<style id="escape" _name="Escape" map-to="def:escape"/>
|
|
<style id="preprocessor" _name="Preprocessor"/>
|
|
<style id="common-defines" _name="Common defines" map-to="c:preprocessor"/>
|
|
<style id="included-file" _name="Included File" map-to="c:preprocessor"/>
|
|
<style id="char" _name="Character" map-to="def:character"/>
|
|
<style id="keyword" _name="Keyword" map-to="def:keyword"/>
|
|
<style id="data-type" _name="Data Type" map-to="def:data-type"/>
|
|
<style id="printf" _name="printf conversion" map-to="def:character"/>
|
|
<style id="escaped-character" _name="Escaped Character" map-to="def:escape"/>
|
|
<style id="floating-point" _name="Float" map-to="def:floating-point"/>
|
|
<style id="decimal" _name="Decimal" map-to="def:decimal"/>
|
|
<style id="octal" _name="Octal" map-to="def:base-n-integer"/>
|
|
<style id="hexadecimal" _name="Hex" map-to="def:base-n-integer"/>
|
|
</styles>
|
|
|
|
<definitions>
|
|
<!-- TODO: what about scanf ? -->
|
|
<!-- man 3 printf -->
|
|
<context id="printf" style-ref="printf" extend-parent="false">
|
|
<match extended="true">
|
|
\%\%|
|
|
\%([1-9][0-9]*\$)?
|
|
[#0\-\ \+\'I]*
|
|
(\-?[1-9][0-9]*)?
|
|
(\.\-?[1-9][0-9]*)?
|
|
(hh|ll|[hlLqjzt])?
|
|
[diouxXeEfFgGaAcsCSpnm]
|
|
</match>
|
|
</context>
|
|
|
|
<!-- http://en.wikipedia.org/wiki/C_syntax#Strings -->
|
|
<define-regex id="escaped-character" extended="true">
|
|
\\( # leading backslash
|
|
[\\\"\'nrtfav\?e] | # escaped character
|
|
[0-7]{1,3} | # one, two, or three octal digits
|
|
x[0-9A-Fa-f]{0,2} # 'x' followed by zero, one, or two hex digits
|
|
)
|
|
</define-regex>
|
|
|
|
<context id="c">
|
|
<include>
|
|
|
|
<!-- gtk-doc -->
|
|
<context ref="gtk-doc:inline-docs"/>
|
|
|
|
<!-- Comments -->
|
|
<context id="comment" style-ref="comment" end-at-line-end="true">
|
|
<start>\/\/</start>
|
|
<include>
|
|
<context ref="def:in-line-comment"/>
|
|
</include>
|
|
</context>
|
|
|
|
<context id="comment-multiline" style-ref="comment">
|
|
<start>\/\*</start>
|
|
<end>\*\/</end>
|
|
<include>
|
|
<context ref="def:in-comment"/>
|
|
</include>
|
|
</context>
|
|
|
|
<context id="close-comment-outside-comment" style-ref="error">
|
|
<match>\*\/(?!\*)</match>
|
|
</context>
|
|
|
|
<!-- Preprocessor -->
|
|
<define-regex id="preproc-start">^\s*#\s*</define-regex>
|
|
|
|
<context id="if0-comment" style-ref="comment">
|
|
<start>\%{preproc-start}if\s*0\b</start>
|
|
<end>\%{preproc-start}(endif|else|elif)\b</end>
|
|
<include>
|
|
<context id="if-in-if0">
|
|
<start>\%{preproc-start}if(n?def)?\b</start>
|
|
<end>\%{preproc-start}endif\b</end>
|
|
<include>
|
|
<context ref="if-in-if0"/>
|
|
<context ref="def:in-comment"/>
|
|
</include>
|
|
</context>
|
|
<context ref="def:in-comment"/>
|
|
</include>
|
|
</context>
|
|
|
|
<context id="include" style-ref="preprocessor">
|
|
<match extended="true">
|
|
\%{preproc-start}
|
|
(include|import)\s*
|
|
(".*?"|<.*>)
|
|
</match>
|
|
<include>
|
|
<context id="included-file" sub-pattern="1" style-ref="included-file"/>
|
|
</include>
|
|
</context>
|
|
|
|
<context id="preprocessor" style-ref="preprocessor" end-at-line-end="true">
|
|
<start extended="true">
|
|
\%{preproc-start}
|
|
(define|undef|error|pragma|ident|if(n?def)?|else|elif|endif|line|warning)
|
|
\b
|
|
</start>
|
|
<include>
|
|
<context ref="def:line-continue" ignore-style="true"/>
|
|
<context ref="comment"/>
|
|
<context ref="comment-multiline"/>
|
|
</include>
|
|
</context>
|
|
|
|
<context id="string" style-ref="string" end-at-line-end="true">
|
|
<start>"</start>
|
|
<end>"</end>
|
|
<include>
|
|
<context ref="printf"/>
|
|
<context id="escaped-character" style-ref="escaped-character">
|
|
<match>\%{escaped-character}</match>
|
|
</context>
|
|
<context ref="def:line-continue"/>
|
|
</include>
|
|
</context>
|
|
|
|
<context id="char" style-ref="char">
|
|
<match>'(\%{escaped-character}|.)'</match>
|
|
</context>
|
|
|
|
<!-- http://www.lysator.liu.se/c/ANSI-C-grammar-l.html -->
|
|
<context id="float" style-ref="floating-point">
|
|
<match extended="true">
|
|
(?<![\w\.])
|
|
((\.[0-9]+ | [0-9]+\.[0-9]*) ([Ee][+-]?[0-9]*)? |
|
|
([0-9]+[Ee][+-]?[0-9]*))
|
|
[fFlL]?
|
|
(?![\w\.])
|
|
</match>
|
|
</context>
|
|
|
|
<context id="hexadecimal" style-ref="hexadecimal">
|
|
<match extended="true">
|
|
(?<![\w\.])
|
|
0[xX][a-fA-F0-9]+[uUlL]*
|
|
(?![\w\.])
|
|
</match>
|
|
</context>
|
|
|
|
<context id="octal" style-ref="octal">
|
|
<match extended="true">
|
|
(?<![\w\.])
|
|
0[0-7]+[uUlL]*
|
|
(?![\w\.])
|
|
</match>
|
|
</context>
|
|
|
|
<context id="decimal" style-ref="decimal">
|
|
<match extended="true">
|
|
(?<![\w\.])
|
|
[0-9]+[uUlL]*
|
|
(?![\w\.])
|
|
</match>
|
|
</context>
|
|
|
|
<!-- Keywords -->
|
|
<context id="keywords" style-ref="keyword">
|
|
<keyword>asm</keyword>
|
|
<keyword>break</keyword>
|
|
<keyword>case</keyword>
|
|
<keyword>continue</keyword>
|
|
<keyword>default</keyword>
|
|
<keyword>do</keyword>
|
|
<keyword>else</keyword>
|
|
<keyword>enum</keyword>
|
|
<keyword>for</keyword>
|
|
<keyword>fortran</keyword>
|
|
<keyword>goto</keyword>
|
|
<keyword>if</keyword>
|
|
<keyword>return</keyword>
|
|
<keyword>sizeof</keyword>
|
|
<keyword>struct</keyword>
|
|
<keyword>switch</keyword>
|
|
<keyword>typedef</keyword>
|
|
<keyword>union</keyword>
|
|
<keyword>while</keyword>
|
|
</context>
|
|
|
|
<context id="types" style-ref="data-type">
|
|
<keyword>_Bool</keyword>
|
|
<keyword>_Complex</keyword>
|
|
<keyword>_Imaginary</keyword>
|
|
<keyword>auto</keyword>
|
|
<keyword>char</keyword>
|
|
<keyword>const</keyword>
|
|
<keyword>double</keyword>
|
|
<keyword>extern</keyword>
|
|
<keyword>float</keyword>
|
|
<keyword>int</keyword>
|
|
<keyword>inline</keyword>
|
|
<keyword>long</keyword>
|
|
<keyword>register</keyword>
|
|
<keyword>restrict</keyword>
|
|
<keyword>short</keyword>
|
|
<keyword>signed</keyword>
|
|
<keyword>size_t</keyword>
|
|
<keyword>static</keyword>
|
|
<keyword>unsigned</keyword>
|
|
<keyword>void</keyword>
|
|
<keyword>volatile</keyword>
|
|
</context>
|
|
|
|
<context id="common-defines" style-ref="common-defines">
|
|
<keyword>NULL</keyword>
|
|
<keyword>TRUE</keyword>
|
|
<keyword>FALSE</keyword>
|
|
<keyword>MAX</keyword>
|
|
<keyword>MIN</keyword>
|
|
<keyword>__LINE__</keyword>
|
|
<keyword>__DATA__</keyword>
|
|
<keyword>__FILE__</keyword>
|
|
<keyword>__func__</keyword>
|
|
<keyword>__TIME__</keyword>
|
|
<keyword>__STDC__</keyword>
|
|
</context>
|
|
|
|
</include>
|
|
</context>
|
|
</definitions>
|
|
</language>
|