<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd"
[
    <!ENTITY int "(?:[0-9](?:'?[0-9]+)*)">
    <!ENTITY hex_int "(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f]+)*)">
    <!ENTITY exp_float "(?:[eE][+-]?&int;)">
    <!ENTITY exp_hexfloat "(?:[pP][-+]?&int;)">

    <!ENTITY ispphash "(?:#|&#37;\:|\?\?=)">
    <!ENTITY pphash "&ispphash;\s*">
]>
<language name="C" section="Sources"
          version="7" kateversion="5.0"
          indenter="cstyle"
          extensions="*.c;*.C;*.h"
          mimetype="text/x-csrc;text/x-c++src;text/x-chdr"
          priority="5">
<!--

    Fixes by Sebastian Pipping (webmaster@hartwork.org)

    NOTE: Keep in sync with C++ highlighter! (cpp.xml)

    Version 6: add more versatile numbers highlighting, taken from isocpp.xml
-->
  <highlighting>
    <list name="controlflow">
      <item>break</item>
      <item>case</item>
      <item>continue</item>
      <item>default</item>
      <item>do</item>
      <item>else</item>
      <item>for</item>
      <item>goto</item>
      <item>if</item>
      <item>return</item>
      <item>switch</item>
      <item>while</item>
    </list>
    <list name="keywords">
      <item>enum</item>
      <item>extern</item>
      <item>inline</item>
      <item>sizeof</item>
      <item>struct</item>
      <item>typedef</item>
      <item>union</item>
      <item>_Alignas</item>
      <item>_Alignof</item>
      <item>_Atomic</item>
      <item>_Noreturn</item>
      <item>_Static_assert</item>
      <item>_Thread_local</item>
    </list>
    <list name="types">
      <item>auto</item>
      <item>char</item>
      <item>const</item>
      <item>double</item>
      <item>float</item>
      <item>int</item>
      <item>long</item>
      <item>register</item>
      <item>restrict</item>
      <item>short</item>
      <item>signed</item>
      <item>static</item>
      <item>unsigned</item>
      <item>void</item>
      <item>volatile</item>
      <item>int8_t</item>
      <item>int16_t</item>
      <item>int32_t</item>
      <item>int64_t</item>
      <item>uint8_t</item>
      <item>uint16_t</item>
      <item>uint32_t</item>
      <item>uint64_t</item>
      <item>int_least8_t</item>
      <item>int_least16_t</item>
      <item>int_least32_t</item>
      <item>int_least64_t</item>
      <item>uint_least8_t</item>
      <item>uint_least16_t</item>
      <item>uint_least32_t</item>
      <item>uint_least64_t</item>
      <item>int_fast8_t</item>
      <item>int_fast16_t</item>
      <item>int_fast32_t</item>
      <item>int_fast64_t</item>
      <item>uint_fast8_t</item>
      <item>uint_fast16_t</item>
      <item>uint_fast32_t</item>
      <item>uint_fast64_t</item>
      <item>size_t</item>
      <item>ssize_t</item>
      <item>wchar_t</item>
      <item>intptr_t</item>
      <item>uintptr_t</item>
      <item>intmax_t</item>
      <item>uintmax_t</item>
      <item>ptrdiff_t</item>
      <item>sig_atomic_t</item>
      <item>wint_t</item>
      <item>_Bool</item>
      <item>bool</item>
      <item>_Complex</item>
      <item>complex</item>
      <item>_Imaginary</item>
      <item>imaginary</item>
      <item>_Generic</item>
      <item>va_list</item>
      <item>FILE</item>
      <item>fpos_t</item>
      <item>time_t</item>
      <item>max_align_t</item>
    </list>
    <contexts>
      <context attribute="Normal Text" lineEndContext="#stay" name="Normal">
        <DetectSpaces />
	<RegExpr attribute="Preprocessor" context="Outscoped" String="&pphash;if\s+0\s*$" beginRegion="PP" firstNonSpace="true" />
        <RegExpr context="AfterHash" String="&ispphash;" firstNonSpace="true" lookAhead="true" />
        <StringDetect attribute="Region Marker" context="Region Marker" String="//BEGIN" beginRegion="Region1" firstNonSpace="true" />
        <StringDetect attribute="Region Marker" context="Region Marker" String="//END" endRegion="Region1" firstNonSpace="true" />
        <keyword attribute="Control Flow" context="#stay" String="controlflow"/>
        <keyword attribute="Keyword" context="#stay" String="keywords"/>
        <keyword attribute="Data Type" context="#stay" String="types"/>
        <DetectIdentifier />
        <DetectChar attribute="Symbol" context="#stay" char="{" beginRegion="Brace1" />
        <DetectChar attribute="Symbol" context="#stay" char="}" endRegion="Brace1" />
        <Detect2Chars attribute="Symbol" context="#stay" char="&lt;" char1="%" beginRegion="Brace1" /> <!-- Digraph: { -->
        <Detect2Chars attribute="Symbol" context="#stay" char="%" char1="&gt;" endRegion="Brace1" /> <!-- Digraph: } -->

        <!-- Match numbers -->
        <RegExpr attribute="Decimal" context="Number" String="\.?[0-9]" lookAhead="true" />

        <HlCChar attribute="Char" context="#stay"/>
        <DetectChar attribute="String" context="String" char="&quot;"/>
        <IncludeRules context="##Doxygen" />
        <Detect2Chars attribute="Comment" context="Commentar 1" char="/" char1="/"/>
        <Detect2Chars attribute="Comment" context="Commentar 2" char="/" char1="*" beginRegion="Comment"/>
        <AnyChar attribute="Symbol" context="#stay" String=":!%&amp;()+,-/.*&lt;=&gt;?[]|~^&#59;"/>
      </context>

      <context attribute="String" lineEndContext="#pop" name="String">
        <LineContinue attribute="String" context="#stay"/>
        <HlCStringChar attribute="String Char" context="#stay"/>
        <DetectChar attribute="String" context="#pop" char="&quot;"/>
      </context>

      <context attribute="Region Marker" lineEndContext="#pop" name="Region Marker">
      </context>

      <context attribute="Comment" lineEndContext="#pop" name="Commentar 1">
        <LineContinue attribute="Comment" context="#stay"/>
        <IncludeRules context="##Alerts" />
      </context>

      <context attribute="Comment" lineEndContext="#stay" name="Commentar 2">
        <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="Comment"/>
        <IncludeRules context="##Alerts" />
      </context>

      <context attribute="Error" lineEndContext="#pop" name="AfterHash">
        <RegExpr attribute="Preprocessor" context="Include" String="&pphash;(?:include|include_next)" insensitive="true" firstNonSpace="true" />

        <!-- define, elif, else, endif, error, if, ifdef, ifndef, line, pragma, undef, warning -->
        <RegExpr attribute="Preprocessor" context="Preprocessor" String="&pphash;if(?:def|ndef)?(?=\s+\S)" insensitive="true" beginRegion="PP" firstNonSpace="true" />
        <RegExpr attribute="Preprocessor" context="Preprocessor" String="&pphash;endif" insensitive="true" endRegion="PP" firstNonSpace="true" />
        <RegExpr attribute="Preprocessor" context="Define" String="&pphash;define.*((?=\\))" insensitive="true" firstNonSpace="true" />

        <!-- folding for apple style #pragma mark - label -->
        <RegExpr attribute="Preprocessor" context="Preprocessor" String="&pphash;pragma\s+mark\s+-\s*$" insensitive="true" firstNonSpace="true" endRegion="pragma_mark" />
        <RegExpr attribute="Preprocessor" context="Preprocessor" String="&pphash;pragma\s+mark" insensitive="true" firstNonSpace="true" endRegion="pragma_mark" beginRegion="pragma_mark" />

        <RegExpr attribute="Preprocessor" context="Preprocessor" String="&pphash;(?:el(?:se|if)|define|undef|line|error|warning|pragma)" insensitive="true" firstNonSpace="true" />
        <RegExpr attribute="Preprocessor" context="Preprocessor" String="&ispphash;\s+[0-9]+" insensitive="true" firstNonSpace="true" />
      </context>

      <context attribute="Preprocessor" lineEndContext="#pop" name="Include">
        <LineContinue attribute="Preprocessor" context="#stay"/>
        <RangeDetect attribute="Prep. Lib" context="#stay" char="&quot;" char1="&quot;"/>
        <RangeDetect attribute="Prep. Lib" context="#stay" char="&lt;" char1="&gt;"/>
        <IncludeRules context="Preprocessor" />
      </context>

      <context attribute="Preprocessor" lineEndContext="#pop" name="Preprocessor">
        <LineContinue attribute="Preprocessor" context="#stay"/>
        <IncludeRules context="##Doxygen" />
        <Detect2Chars attribute="Comment" context="Commentar/Preprocessor" char="/" char1="*" beginRegion="Comment2" />
        <Detect2Chars attribute="Comment" context="Commentar 1" char="/" char1="/" />
      </context>

      <context attribute="Preprocessor" lineEndContext="#pop" name="Define">
        <LineContinue attribute="Preprocessor" context="#stay"/>
      </context>

      <context attribute="Comment" lineEndContext="#stay" name="Commentar/Preprocessor">
        <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="Comment2" />
      </context>

      <context attribute="Comment" lineEndContext="#stay" name="Outscoped" >
        <DetectSpaces />
        <IncludeRules context="##Alerts" />
        <DetectIdentifier />
        <DetectChar attribute="String" context="String" char="&quot;"/>
        <IncludeRules context="##Doxygen" />
        <Detect2Chars attribute="Comment" context="Commentar 1" char="/" char1="/"/>
        <Detect2Chars attribute="Comment" context="Commentar 2" char="/" char1="*" beginRegion="Comment"/>
        <RegExpr attribute="Comment" context="Outscoped intern" String="&pphash;if" beginRegion="PP" firstNonSpace="true" />
        <RegExpr attribute="Preprocessor" context="#pop" String="&pphash;el(?:se|if)" firstNonSpace="true" />
        <RegExpr attribute="Preprocessor" context="#pop" String="&pphash;endif" endRegion="PP" firstNonSpace="true" />
      </context>

      <context attribute="Comment" lineEndContext="#stay" name="Outscoped intern">
        <DetectSpaces />
        <IncludeRules context="##Alerts" />
        <DetectIdentifier />
        <DetectChar attribute="String" context="String" char="&quot;"/>
        <IncludeRules context="##Doxygen" />
        <Detect2Chars attribute="Comment" context="Commentar 1" char="/" char1="/"/>
        <Detect2Chars attribute="Comment" context="Commentar 2" char="/" char1="*" beginRegion="Comment"/>
        <RegExpr attribute="Comment" context="Outscoped intern" String="&pphash;if" beginRegion="PP" firstNonSpace="true" />
        <RegExpr attribute="Comment" context="#pop" String="&pphash;endif" endRegion="PP" firstNonSpace="true" />
      </context>

      <context name="Number" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
        <RegExpr attribute="Float" context="FloatSuffix" String="\.&int;&exp_float;?|&int;(?:&exp_float;|\.&int;?&exp_float;?)|0[xX](?:\.&hex_int;&exp_hexfloat;?|&hex_int;(?:&exp_hexfloat;|\.&hex_int;?&exp_hexfloat;?))" />
        <IncludeRules context="Integer" />
      </context>

      <context name="Integer" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
        <RegExpr attribute="Hex" context="IntSuffix" String="0[xX]&hex_int;" />
        <RegExpr attribute="Binary" context="IntSuffix" String="0[Bb][01](?:'?[01]+)*" />
        <RegExpr attribute="Octal" context="IntSuffix" String="0(?:'?[0-7]+)+" />
        <RegExpr attribute="Decimal" context="IntSuffix" String="0(?![xXbB0-9])|[1-9](?:'?[0-9]+)*" />
        <RegExpr attribute="Error" context="#pop" String="[._0-9A-Za-z']+" />
      </context>

      <context name="IntSuffix" attribute="Error" lineEndContext="#pop#pop" fallthrough="true" fallthroughContext="NumericSuffixError">
        <DetectChar attribute="Error" context="#stay" char="'" />
        <AnyChar attribute="Error" context="#pop!IntSuffixPattern" String="uUlLimunshyd_" lookAhead="true" />
      </context>

      <context name="IntSuffixPattern" attribute="Error" lineEndContext="#pop#pop" fallthrough="true" fallthroughContext="NumericSuffixError">
        <RegExpr attribute="Standard Suffix" context="NumericSuffixError" String="[Uu][Ll]{0,2}|[Ll]{0,2}[Uu]?" />
      </context>

      <context name="FloatSuffix" attribute="Error" lineEndContext="#pop#pop" fallthrough="true" fallthroughContext="NumericSuffixError">
        <AnyChar attribute="Standard Suffix" context="NumericSuffixError" String="fFlL" />
      </context>

      <context name="NumericSuffixError" attribute="Error" lineEndContext="#pop#pop#pop" fallthrough="true" fallthroughContext="#pop#pop#pop">
        <RegExpr attribute="Error" context="#pop#pop#pop" String="\.[_0-9A-Za-z]*|[_0-9A-Za-z]+" />
      </context>
    </contexts>
    <itemDatas>
      <itemData name="Normal Text"  defStyleNum="dsNormal" spellChecking="false"/>
      <itemData name="Control Flow" defStyleNum="dsControlFlow" spellChecking="false"/>
      <itemData name="Keyword"      defStyleNum="dsKeyword" spellChecking="false"/>
      <itemData name="Data Type"    defStyleNum="dsDataType" spellChecking="false"/>
      <itemData name="Decimal"      defStyleNum="dsDecVal" spellChecking="false"/>
      <itemData name="Octal"        defStyleNum="dsBaseN" spellChecking="false"/>
      <itemData name="Hex"          defStyleNum="dsBaseN" spellChecking="false"/>
      <itemData name="Binary"       defStyleNum="dsBaseN" spellChecking="false"/>
      <itemData name="Float"        defStyleNum="dsFloat" spellChecking="false"/>
      <itemData name="Standard Suffix" defStyleNum="dsBuiltIn" spellChecking="false" />
      <itemData name="Char"         defStyleNum="dsChar" spellChecking="false"/>
      <itemData name="String"       defStyleNum="dsString"/>
      <itemData name="String Char"  defStyleNum="dsSpecialChar"/>
      <itemData name="Comment"      defStyleNum="dsComment"/>
      <itemData name="Symbol"       defStyleNum="dsNormal" spellChecking="false"/>
      <itemData name="Preprocessor" defStyleNum="dsPreprocessor" spellChecking="false"/>
      <itemData name="Prep. Lib"    defStyleNum="dsImport" spellChecking="false"/>
      <itemData name="Region Marker" defStyleNum="dsRegionMarker" spellChecking="false"/>
      <itemData name="Error"        defStyleNum="dsError" spellChecking="false"/>
    </itemDatas>
  </highlighting>
  <general>
    <comments>
      <comment name="singleLine" start="//" />
      <comment name="multiLine" start="/*" end="*/" />
    </comments>
    <keywords casesensitive="1" additionalDeliminator="'&quot;" />
  </general>
</language>
