c.xml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE language
  3. [
  4. <!ENTITY int "(?:[0-9](?:'?[0-9]++)*+)">
  5. <!ENTITY hex_int "(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f]++)*+)">
  6. <!ENTITY exp_float "(?:[eE][+-]?&int;)">
  7. <!ENTITY exp_hexfloat "(?:[pP][-+]?&int;)">
  8. <!ENTITY symbols ":!&#37;&amp;()+,-/.*&lt;=&gt;?[]|~^;">
  9. <!-- printf-like format strings conversion specifiers -->
  10. <!ENTITY printf_like "&#37;[-+ #0]*+(?:[0-9]++|\*)?(?:\.(?:[0-9]++|\*))?(?:(?:hh|ll|[hljzt]|wf?(?:8|16|32|64))?[dioxXubn]|(?:DD|[lLHD])?[fFeEaAgG]|l?[cs]|[p&#37;])">
  11. <!ENTITY ispphash "(?:#|&#37;\:|\?\?=)">
  12. <!ENTITY pphash "&ispphash;\s*">
  13. ]>
  14. <language name="C" section="Sources"
  15. version="18" kateversion="5.79"
  16. indenter="cstyle"
  17. extensions="*.c;*.C;*.h"
  18. mimetype="text/x-csrc;text/x-c++src;text/x-chdr"
  19. priority="5">
  20. <!--
  21. Fixes by Sebastian Pipping (webmaster@hartwork.org)
  22. NOTE: Keep in sync with C++ highlighter! (cpp.xml)
  23. Version 6: add more versatile numbers highlighting, taken from isocpp.xml
  24. -->
  25. <highlighting>
  26. <list name="controlflow">
  27. <item>break</item>
  28. <item>case</item>
  29. <item>continue</item>
  30. <item>default</item>
  31. <item>do</item>
  32. <item>else</item>
  33. <item>for</item>
  34. <item>goto</item>
  35. <item>if</item>
  36. <item>return</item>
  37. <item>switch</item>
  38. <item>while</item>
  39. </list>
  40. <list name="keywords">
  41. <item>alignas</item> <!-- C23 -->
  42. <item>alignof</item> <!-- C23 -->
  43. <item>auto</item>
  44. <item>constexpr</item> <!-- C23 -->
  45. <item>enum</item>
  46. <item>extern</item>
  47. <item>false</item> <!-- C23 -->
  48. <item>inline</item>
  49. <item>nullptr</item> <!-- C23 -->
  50. <item>sizeof</item>
  51. <item>static_assert</item> <!-- C23 -->
  52. <item>struct</item>
  53. <item>true</item> <!-- C23 -->
  54. <item>typedef</item>
  55. <item>typeof</item> <!-- C23 -->
  56. <item>typeof_unqual</item> <!-- C23 -->
  57. <item>union</item>
  58. <item>_Alignas</item>
  59. <item>_Alignof</item>
  60. <item>_Atomic</item>
  61. <item>_Noreturn</item>
  62. <item>_Static_assert</item>
  63. <item>_Thread_local</item>
  64. </list>
  65. <!-- https://en.cppreference.com/w/c/language/attributes -->
  66. <list name="attributes">
  67. <item>noreturn</item>
  68. <item>deprecated</item>
  69. <item>fallthrough</item>
  70. <item>nodiscard</item>
  71. <item>maybe_unused</item>
  72. <item>unsequenced</item>
  73. <item>reproducible</item>
  74. </list>
  75. <list name="types">
  76. <item>bool</item> <!-- C23 -->
  77. <item>char</item>
  78. <item>char16_t</item>
  79. <item>char32_t</item>
  80. <item>double</item>
  81. <item>float</item>
  82. <item>int</item>
  83. <item>long</item>
  84. <item>short</item>
  85. <item>signed</item>
  86. <item>unsigned</item>
  87. <item>void</item>
  88. <item>int8_t</item>
  89. <item>int16_t</item>
  90. <item>int32_t</item>
  91. <item>int64_t</item>
  92. <item>uint8</item>
  93. <item>uint16</item>
  94. <item>uint8_t</item>
  95. <item>uint16_t</item>
  96. <item>uint32_t</item>
  97. <item>uint64_t</item>
  98. <item>int_least8_t</item>
  99. <item>int_least16_t</item>
  100. <item>int_least32_t</item>
  101. <item>int_least64_t</item>
  102. <item>uint_least8_t</item>
  103. <item>uint_least16_t</item>
  104. <item>uint_least32_t</item>
  105. <item>uint_least64_t</item>
  106. <item>int_fast8_t</item>
  107. <item>int_fast16_t</item>
  108. <item>int_fast32_t</item>
  109. <item>int_fast64_t</item>
  110. <item>uint_fast8_t</item>
  111. <item>uint_fast16_t</item>
  112. <item>uint_fast32_t</item>
  113. <item>uint_fast64_t</item>
  114. <item>size_t</item>
  115. <item>ssize_t</item>
  116. <item>wchar_t</item>
  117. <item>intptr_t</item>
  118. <item>uintptr_t</item>
  119. <item>intmax_t</item>
  120. <item>uintmax_t</item>
  121. <item>ptrdiff_t</item>
  122. <item>sig_atomic_t</item>
  123. <item>wint_t</item>
  124. <item>_BitInt</item> <!-- C23 -->
  125. <item>_Bool</item>
  126. <item>bool</item>
  127. <item>_Decimal32</item> <!-- C23 -->
  128. <item>_Decimal64</item> <!-- C23 -->
  129. <item>_Decimal128</item> <!-- C23 -->
  130. <item>_Complex</item>
  131. <item>complex</item>
  132. <item>_Imaginary</item>
  133. <item>imaginary</item>
  134. <item>_Generic</item>
  135. <item>va_list</item>
  136. <item>FILE</item>
  137. <item>fpos_t</item>
  138. <item>time_t</item>
  139. <item>max_align_t</item>
  140. <!-- modifiers -->
  141. <item>const</item>
  142. <item>register</item>
  143. <item>restrict</item>
  144. <item>static</item>
  145. <item>thread_local</item> <!-- C23 -->
  146. <item>volatile</item>
  147. </list>
  148. <list name="preprocessor">
  149. <item>if</item>
  150. <item>ifdef</item>
  151. <item>ifndef</item>
  152. <item>elif</item>
  153. <item>elifdef</item> <!-- C23 -->
  154. <item>elifndef</item> <!-- C23 -->
  155. <item>else</item>
  156. <item>endif</item>
  157. <item>define</item>
  158. <item>include</item>
  159. <item>error</item>
  160. <item>line</item>
  161. <item>pragma</item>
  162. <item>undef</item>
  163. <item>warning</item>
  164. <item>embed</item>
  165. </list>
  166. <contexts>
  167. <context attribute="Normal Text" lineEndContext="#stay" name="Normal">
  168. <DetectSpaces />
  169. <!-- Match symbols (partial for fast path) -->
  170. <AnyChar attribute="Symbol" context="#stay" String=":()]+-*=&gt;!|&amp;~^,;" />
  171. <IncludeRules context="match keywords" />
  172. <AnyChar context="SelectString" String="UuL&quot;'" lookAhead="1"/>
  173. <DetectIdentifier />
  174. <DetectChar attribute="Symbol" context="#stay" char="{" beginRegion="Brace1" />
  175. <DetectChar attribute="Symbol" context="#stay" char="}" endRegion="Brace1" />
  176. <Detect2Chars attribute="Symbol" context="#stay" char="&lt;" char1="%" beginRegion="Brace1" /> <!-- Digraph: { -->
  177. <Detect2Chars attribute="Symbol" context="#stay" char="%" char1="&gt;" endRegion="Brace1" /> <!-- Digraph: } -->
  178. <!-- Detect attributes -->
  179. <Detect2Chars attribute="Symbol" context="Attribute" char="[" char1="[" />
  180. <StringDetect attribute="Symbol" context="Attribute" String="&lt;:&lt;:" /> <!-- Digraph: [[ -->
  181. <!-- Match numbers -->
  182. <RegExpr context="Number" String="\.?[0-9]" lookAhead="1" />
  183. <IncludeRules context="FindComments" />
  184. <RegExpr context="AfterHash" String="&ispphash;|" firstNonSpace="1" lookAhead="1" />
  185. <AnyChar attribute="Symbol" context="#stay" String="&symbols;"/>
  186. </context>
  187. <context name="match keywords" attribute="Normal Text" lineEndContext="#pop">
  188. <keyword attribute="Control Flow" context="#stay" String="controlflow"/>
  189. <keyword attribute="Keyword" context="#stay" String="keywords"/>
  190. <keyword attribute="Data Type" context="#stay" String="types"/>
  191. </context>
  192. <context name="SelectStringPP" attribute="Preprocessor" lineEndContext="#pop">
  193. <IncludeRules context="SelectString"/>
  194. </context>
  195. <context name="SelectString" attribute="Normal Text" lineEndContext="#pop">
  196. <DetectChar attribute="String" context="#pop!String8" char="&quot;"/>
  197. <DetectChar attribute="Char" context="#pop!Char8" char="'"/>
  198. <Detect2Chars context="#pop!SelectStringPrefix" char="U" char1="&quot;" lookAhead="1"/>
  199. <Detect2Chars context="#pop!SelectStringPrefix" char="u" char1="&quot;" lookAhead="1"/>
  200. <Detect2Chars context="#pop!SelectStringPrefix" char="L" char1="&quot;" lookAhead="1"/>
  201. <StringDetect context="#pop!SelectStringPrefix" String="u8&quot;" lookAhead="1"/>
  202. <Detect2Chars context="#pop!SelectCharPrefix" char="U" char1="'" lookAhead="1"/>
  203. <Detect2Chars context="#pop!SelectCharPrefix" char="u" char1="'" lookAhead="1"/>
  204. <Detect2Chars context="#pop!SelectCharPrefix" char="L" char1="'" lookAhead="1"/>
  205. <StringDetect context="#pop!SelectCharPrefix" String="u8'" lookAhead="1"/>
  206. <!-- match identifier -->
  207. <keyword attribute="Data Type" context="#pop" String="types"/>
  208. <DetectIdentifier context="#pop"/>
  209. </context>
  210. <context name="SelectStringPrefix" attribute="String" lineEndContext="#pop">
  211. <Detect2Chars attribute="String Literal Prefix" context="#pop!StringPrefix8" char="u" char1="8"/>
  212. <AnyChar attribute="String Literal Prefix" context="#pop!StringPrefix16" String="uL"/>
  213. <DetectChar attribute="String Literal Prefix" context="#pop!StringPrefix32" char="U"/>
  214. </context>
  215. <context name="StringPrefix8" attribute="String" lineEndContext="#pop">
  216. <DetectChar attribute="String" context="#pop!String8" char="&quot;"/>
  217. </context>
  218. <context name="StringPrefix16" attribute="String" lineEndContext="#pop">
  219. <DetectChar attribute="String" context="#pop!String16" char="&quot;"/>
  220. </context>
  221. <context name="StringPrefix32" attribute="String" lineEndContext="#pop">
  222. <DetectChar attribute="String" context="#pop!String32" char="&quot;"/>
  223. </context>
  224. <context name="SelectCharPrefix" attribute="String" lineEndContext="#pop">
  225. <Detect2Chars attribute="Char Literal Prefix" context="#pop!CharPrefix8" char="u" char1="8"/>
  226. <AnyChar attribute="Char Literal Prefix" context="#pop!CharPrefix16" String="uL"/>
  227. <DetectChar attribute="Char Literal Prefix" context="#pop!CharPrefix32" char="U"/>
  228. </context>
  229. <context name="CharPrefix8" attribute="Char" lineEndContext="#pop">
  230. <DetectChar attribute="Char" context="#pop!Char8" char="'"/>
  231. </context>
  232. <context name="CharPrefix16" attribute="Char" lineEndContext="#pop">
  233. <DetectChar attribute="Char" context="#pop!Char16" char="'"/>
  234. </context>
  235. <context name="CharPrefix32" attribute="Char" lineEndContext="#pop">
  236. <DetectChar attribute="Char" context="#pop!Char32" char="'"/>
  237. </context>
  238. <context name="String8" attribute="String" lineEndContext="#pop">
  239. <IncludeRules context="string normal char" />
  240. <Detect2Chars context="String8EscapeX" char="\" char1="x" lookAhead="1"/>
  241. <IncludeRules context="string special char" />
  242. </context>
  243. <context name="String8EscapeX" attribute="String" lineEndContext="#pop">
  244. <HlCStringChar attribute="String Char" context="#pop!StringNoHex"/>
  245. <Detect2Chars context="#pop" attribute="Error" char="\" char1="x"/>
  246. </context>
  247. <context name="String16" attribute="String" lineEndContext="#pop">
  248. <IncludeRules context="string normal char" />
  249. <Detect2Chars context="String16EscapeX" char="\" char1="x" lookAhead="1"/>
  250. <IncludeRules context="string special char" />
  251. </context>
  252. <context name="String16EscapeX" attribute="String" lineEndContext="#pop">
  253. <RegExpr attribute="String Char" context="#pop!StringNoHex" String="\\x[0-9A-Fa-f]{1,4}" />
  254. <Detect2Chars context="#pop" attribute="Error" char="\" char1="x"/>
  255. </context>
  256. <context name="String32" attribute="String" lineEndContext="#pop">
  257. <IncludeRules context="string normal char" />
  258. <Detect2Chars context="String32EscapeX" char="\" char1="x" lookAhead="1"/>
  259. <IncludeRules context="string special char" />
  260. </context>
  261. <context name="String32EscapeX" attribute="String" lineEndContext="#pop">
  262. <RegExpr attribute="String Char" context="#pop!StringNoHex" String="\\x[0-9A-Fa-f]{1,8}" />
  263. <Detect2Chars context="#pop" attribute="Error" char="\" char1="x"/>
  264. </context>
  265. <context name="StringNoHex" attribute="Error" lineEndContext="#pop" fallthroughContext="#pop">
  266. <RegExpr attribute="Error" context="#pop" String="[0-9A-Fa-f]{1,}" />
  267. </context>
  268. <context name="Char8" attribute="Char" lineEndContext="#pop" fallthroughContext="CharClose">
  269. <HlCStringChar attribute="String Char" context="CharClose"/>
  270. <IncludeRules context="FindSingleChar"/>
  271. </context>
  272. <context name="Char16" attribute="Char" lineEndContext="#pop" fallthroughContext="CharClose">
  273. <RegExpr attribute="String Char" context="CharClose" String="\\(?:[tnvbrfa'&quot;\\?]|[0-7]{1,3}|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4})|" />
  274. <IncludeRules context="FindSingleChar"/>
  275. </context>
  276. <context name="Char32" attribute="Char" lineEndContext="#pop" fallthroughContext="CharClose">
  277. <RegExpr attribute="String Char" context="CharClose" String="\\(?:[tnvbrfa'&quot;\\?]|[0-7]{1,3}|x[0-9A-Fa-f]{1,8}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})|" />
  278. <IncludeRules context="FindSingleChar"/>
  279. </context>
  280. <context name="FindSingleChar" attribute="Char" lineEndContext="#pop">
  281. <DetectChar attribute="Error" context="#pop" char="'" />
  282. <RegExpr attribute="Char" context="CharClose" String="." />
  283. </context>
  284. <context name="CharClose" attribute="Error" lineEndContext="#pop#pop">
  285. <DetectChar attribute="Char" context="#pop#pop" char="'" />
  286. </context>
  287. <context name="FindComments" attribute="Normal Text" lineEndContext="#pop">
  288. <Detect2Chars attribute="Comment" context="MatchComment" char="/" char1="/" lookAhead="true" />
  289. <Detect2Chars attribute="Comment" context="MatchComment" char="/" char1="*" lookAhead="true" />
  290. </context>
  291. <context name="MatchComment" attribute="Normal Text" lineEndContext="#pop" fallthroughContext="#pop">
  292. <StringDetect attribute="Region Marker" context="#pop!Region Marker" String="//BEGIN" beginRegion="Region1" firstNonSpace="true" />
  293. <StringDetect attribute="Region Marker" context="#pop!Region Marker" String="//END" endRegion="Region1" firstNonSpace="true" />
  294. <IncludeRules context="##Doxygen" />
  295. <Detect2Chars attribute="Comment" context="#pop!Commentar 1" char="/" char1="/" />
  296. <Detect2Chars attribute="Comment" context="#pop!Commentar 2" char="/" char1="*" beginRegion="Comment" />
  297. </context>
  298. <context attribute="Region Marker" lineEndContext="#pop" name="Region Marker">
  299. </context>
  300. <context attribute="Comment" lineEndContext="#pop" name="Commentar 1">
  301. <LineContinue attribute="Comment" context="#stay"/>
  302. <IncludeRules context="##Comments" />
  303. </context>
  304. <context attribute="Comment" lineEndContext="#stay" name="Commentar 2">
  305. <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="Comment"/>
  306. <IncludeRules context="##Comments" />
  307. </context>
  308. <context name="string special char" attribute="String" lineEndContext="#pop">
  309. <HlCStringChar attribute="String Char"/>
  310. <RegExpr attribute="String Char" String="\\(?:u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})|&printf_like;"/>
  311. <DetectChar attribute="String" char="%"/>
  312. <RegExpr attribute="Error" String="\\(?:u[^&quot;]{0,3}|U[^&quot;]{0,7}|.)"/>
  313. <LineContinue attribute="Symbol"/>
  314. </context>
  315. <context name="string normal char" attribute="String" lineEndContext="#pop">
  316. <!-- fast way, can be replaced by a `UntilChars` rule if it exists -->
  317. <!-- % -> printf format -->
  318. <RegExpr attribute="String" context="#stay" String="[^%\\&quot;]+" />
  319. <DetectChar attribute="String" context="#pop" char="&quot;" />
  320. </context>
  321. <context attribute="Error" lineEndContext="#pop" name="AfterHash" fallthroughContext="#pop!LineError">
  322. <RegExpr attribute="Preprocessor" context="#pop!PreprocessorCmd" String="&pphash;(?=.)|" firstNonSpace="true" />
  323. </context>
  324. <context name="LineError" attribute="Error" lineEndContext="#pop">
  325. <LineContinue attribute="Error" context="#stay" />
  326. <RegExpr attribute="Error" context="#stay" String="[^\\]+" />
  327. </context>
  328. <context attribute="Error" lineEndContext="#pop" name="PreprocessorCmd" fallthroughContext="#pop!LineError">
  329. <WordDetect attribute="Preprocessor" context="#pop!Include" String="include" insensitive="true" />
  330. <WordDetect attribute="Preprocessor" context="#pop!Preprocessor" String="ifdef" beginRegion="PP" lookAhead="true" insensitive="true" />
  331. <WordDetect attribute="Preprocessor" context="#pop!Preprocessor" String="ifndef" beginRegion="PP" lookAhead="true" insensitive="true" />
  332. <RegExpr attribute="Preprocessor" context="#pop!Outscoped" String="if\s+0\s*$|" beginRegion="PP" />
  333. <WordDetect attribute="Preprocessor" context="#pop!Preprocessor" String="if" beginRegion="PP" lookAhead="true" insensitive="true" />
  334. <WordDetect attribute="Preprocessor" context="#pop!Preprocessor" String="elif" endRegion="PP" beginRegion="PP" lookAhead="true" insensitive="true" />
  335. <WordDetect attribute="Preprocessor" context="#pop!Preprocessor" String="else" endRegion="PP" beginRegion="PP" insensitive="true" />
  336. <WordDetect attribute="Preprocessor" context="#pop!Preprocessor" String="endif" endRegion="PP" insensitive="true" />
  337. <WordDetect attribute="Preprocessor" context="#pop!Preprocessor" String="elifdef" endRegion="PP" beginRegion="PP" lookAhead="true" insensitive="true" />
  338. <WordDetect attribute="Preprocessor" context="#pop!Preprocessor" String="elifndef" endRegion="PP" beginRegion="PP" lookAhead="true" insensitive="true" />
  339. <WordDetect attribute="Preprocessor" context="#pop!Define" String="define"/>
  340. <!-- folding for apple style #pragma mark - label -->
  341. <RegExpr attribute="Preprocessor" context="#pop" String="&pphash;pragma\s+mark\s+-\s*|" insensitive="true" endRegion="pragma_mark" />
  342. <RegExpr attribute="Preprocessor" context="Preprocessor" String="&pphash;pragma\s+mark|" insensitive="true" endRegion="pragma_mark" beginRegion="pragma_mark" />
  343. <keyword attribute="Preprocessor" context="#pop!Preprocessor" String="preprocessor" />
  344. <!-- GCC extension -->
  345. <WordDetect attribute="Preprocessor" context="#pop!Include" String="include_next" />
  346. <Int attribute="Preprocessor" context="#pop!Preprocessor"/>
  347. </context>
  348. <context attribute="Preprocessor" lineEndContext="#pop" name="Include">
  349. <DetectSpaces />
  350. <RangeDetect attribute="Prep. Lib" context="#stay" char="&quot;" char1="&quot;"/>
  351. <RangeDetect attribute="Prep. Lib" context="#stay" char="&lt;" char1="&gt;"/>
  352. <IncludeRules context="Preprocessor" />
  353. <DetectIdentifier/>
  354. </context>
  355. <context attribute="Preprocessor" lineEndContext="#pop" name="Preprocessor">
  356. <LineContinue attribute="Symbol" context="#stay"/>
  357. <IncludeRules context="FindComments" />
  358. </context>
  359. <context name="Define" attribute="Preprocessor" lineEndContext="#pop">
  360. <DetectSpaces/>
  361. <IncludeRules context="InPreprocessor" />
  362. <Detect2Chars attribute="Error" context="#pop!LineError" char="/" char1="/" />
  363. <Detect2Chars attribute="Comment" context="MatchComment" char="/" char1="*" lookAhead="true" />
  364. <IncludeRules context="GNUMacros##GCCExtensions" />
  365. <DetectIdentifier attribute="Preprocessor" context="#pop!In Define"/>
  366. </context>
  367. <context name="In Define" attribute="Preprocessor" lineEndContext="#pop">
  368. <DetectSpaces/>
  369. <LineContinue attribute="Symbol" context="#stay" />
  370. <!-- Match symbols (partial for fast path) -->
  371. <AnyChar attribute="Symbol" context="#stay" String="#:(){}]+-*%=&gt;!|&amp;~^,;" />
  372. <IncludeRules context="match keywords" />
  373. <AnyChar context="SelectStringPP" String="UuLR&quot;'" lookAhead="1"/>
  374. <DetectIdentifier />
  375. <!-- Detect attributes -->
  376. <Detect2Chars attribute="Symbol" context="Attribute In PP" char="[" char1="[" />
  377. <StringDetect attribute="Symbol" context="Attribute In PP" String="&lt;:&lt;:" /> <!-- Digraph: [[ -->
  378. <!-- Match numbers -->
  379. <RegExpr context="Number" String="\.?\d" lookAhead="1" />
  380. <IncludeRules context="FindComments" />
  381. <AnyChar attribute="Symbol" context="#stay" String="#&symbols;"/>
  382. </context>
  383. <context name="Attribute In PP" attribute="Attribute" lineEndContext="#pop">
  384. <IncludeRules context="InPreprocessor" />
  385. <IncludeRules context="Attribute" />
  386. </context>
  387. <context name="InPreprocessor" attribute="Normal Text" lineEndContext="#pop">
  388. <LineContinue attribute="Symbol" context="#stay" />
  389. <DetectChar attribute="Error" context="#stay" char="\" />
  390. </context>
  391. <context attribute="Comment" lineEndContext="#stay" name="Outscoped" >
  392. <DetectSpaces />
  393. <IncludeRules context="##Comments" />
  394. <DetectIdentifier />
  395. <DetectChar attribute="String" context="String8" char="&quot;"/>
  396. <IncludeRules context="FindComments" />
  397. <RegExpr attribute="Comment" context="Outscoped intern" String="&pphash;if|" beginRegion="PP" firstNonSpace="true" />
  398. <RegExpr attribute="Preprocessor" context="#pop" String="&pphash;el(?:se|if(n?def)?)|" firstNonSpace="true" />
  399. <RegExpr attribute="Preprocessor" context="#pop" String="&pphash;endif|" endRegion="PP" firstNonSpace="true" />
  400. </context>
  401. <context attribute="Comment" lineEndContext="#stay" name="Outscoped intern">
  402. <DetectSpaces />
  403. <IncludeRules context="##Comments" />
  404. <DetectIdentifier />
  405. <DetectChar attribute="String" context="String8" char="&quot;"/>
  406. <IncludeRules context="FindComments" />
  407. <RegExpr attribute="Comment" context="Outscoped intern" String="&pphash;if|" beginRegion="PP" firstNonSpace="true" />
  408. <RegExpr attribute="Comment" context="#pop" String="&pphash;endif|" endRegion="PP" firstNonSpace="true" />
  409. </context>
  410. <context name="Number" attribute="Normal Text" lineEndContext="#pop" fallthroughContext="#pop">
  411. <WordDetect attribute="Decimal" context="IntSuffix" String="0" weakDeliminator="."/>
  412. <RegExpr attribute="Float" context="FloatSuffix" String="\.&int;&exp_float;?|0[xX](?:\.&hex_int;&exp_hexfloat;?|&hex_int;(?:&exp_hexfloat;|\.&hex_int;?&exp_hexfloat;?))|&int;(?:&exp_float;|\.&int;?&exp_float;?)" />
  413. <IncludeRules context="Integer" />
  414. </context>
  415. <context name="Integer" attribute="Normal Text" lineEndContext="#pop">
  416. <DetectChar context="#pop!IntStartsWith0" char="0" lookAhead="1"/>
  417. <RegExpr attribute="Decimal" context="IntSuffix" String="&int;" />
  418. <RegExpr attribute="Error" context="#pop" String="[._0-9A-Za-z']++" />
  419. </context>
  420. <context name="IntStartsWith0" attribute="Normal Text" lineEndContext="#pop">
  421. <RegExpr attribute="Hex" context="IntSuffix" String="0[xX]&hex_int;" />
  422. <RegExpr attribute="Binary" context="IntSuffix" String="0[Bb][01](?:'?[01]++)*+" />
  423. <RegExpr attribute="Octal" context="IntSuffix" String="0(?:'?[0-7]++)++" />
  424. <DetectChar attribute="Decimal" context="IntSuffix" char="0"/>
  425. </context>
  426. <context name="IntSuffix" attribute="Error" lineEndContext="#pop#pop" fallthroughContext="NumericSuffixError">
  427. <DetectChar attribute="Error" context="#stay" char="'" />
  428. <!-- https://en.cppreference.com/w/c/language/integer_constant#The_type_of_the_integer_constant -->
  429. <RegExpr attribute="Standard Suffix" context="NumericSuffixError" String="([Uu](LL?|ll?|wb|WB)?|(LL?|ll?|wb|WB)[Uu]?)\b"/>
  430. </context>
  431. <context name="FloatSuffix" attribute="Error" lineEndContext="#pop#pop" fallthroughContext="NumericSuffixError">
  432. <DetectChar attribute="Error" context="#stay" char="'" />
  433. <!-- https://en.cppreference.com/w/c/language/floating_constant#Suffixes -->
  434. <AnyChar attribute="Standard Suffix" context="NumericSuffixError" String="fFlL"/>
  435. <Detect2Chars attribute="Standard Suffix" context="NumericSuffixError" char="d" char1="f"/>
  436. <Detect2Chars attribute="Standard Suffix" context="NumericSuffixError" char="D" char1="F"/>
  437. <Detect2Chars attribute="Standard Suffix" context="NumericSuffixError" char="d" char1="d"/>
  438. <Detect2Chars attribute="Standard Suffix" context="NumericSuffixError" char="D" char1="D"/>
  439. <Detect2Chars attribute="Standard Suffix" context="NumericSuffixError" char="d" char1="l"/>
  440. <Detect2Chars attribute="Standard Suffix" context="NumericSuffixError" char="D" char1="L"/>
  441. </context>
  442. <context name="NumericSuffixError" attribute="Error" lineEndContext="#pop#pop#pop" fallthroughContext="#pop#pop#pop">
  443. <AnyChar attribute="Error" String=".'0123456789"/>
  444. <DetectIdentifier attribute="Error"/>
  445. </context>
  446. <context name="Attribute" attribute="Attribute" lineEndContext="#stay">
  447. <DetectSpaces/>
  448. <keyword attribute="Standard Attribute" context="#stay" String="attributes" />
  449. <Detect2Chars attribute="Symbol" context="#pop" char="]" char1="]" />
  450. <StringDetect attribute="Symbol" context="#pop" String=":&gt;:&gt;" /> <!-- Digraph: ]] -->
  451. <AnyChar attribute="Symbol" context="#stay" String="&symbols;" />
  452. <!-- Attributes may contain some text: [[deprecated("Reason text")]] -->
  453. <DetectChar attribute="String" context="String8" char="&quot;" />
  454. <AnyChar attribute="Decimal" context="Integer" String="0123456789" lookAhead="true" />
  455. <IncludeRules context="DetectGccAttributes##GCCExtensions" />
  456. <DetectIdentifier />
  457. </context>
  458. </contexts>
  459. <itemDatas>
  460. <itemData name="Normal Text" defStyleNum="dsNormal" spellChecking="false"/>
  461. <itemData name="Control Flow" defStyleNum="dsControlFlow" spellChecking="false"/>
  462. <itemData name="Keyword" defStyleNum="dsKeyword" spellChecking="false"/>
  463. <itemData name="Data Type" defStyleNum="dsDataType" spellChecking="false"/>
  464. <itemData name="Attribute" defStyleNum="dsAttribute" spellChecking="false"/>
  465. <itemData name="Standard Attribute" defStyleNum="dsAttribute" spellChecking="false"/>
  466. <itemData name="Decimal" defStyleNum="dsDecVal" spellChecking="false"/>
  467. <itemData name="Octal" defStyleNum="dsBaseN" spellChecking="false"/>
  468. <itemData name="Hex" defStyleNum="dsBaseN" spellChecking="false"/>
  469. <itemData name="Binary" defStyleNum="dsBaseN" spellChecking="false"/>
  470. <itemData name="Float" defStyleNum="dsFloat" spellChecking="false"/>
  471. <itemData name="Standard Suffix" defStyleNum="dsBuiltIn" spellChecking="false" />
  472. <itemData name="Char" defStyleNum="dsChar" spellChecking="false"/>
  473. <itemData name="Char Literal Prefix" defStyleNum="dsChar" spellChecking="false" />
  474. <itemData name="String" defStyleNum="dsString"/>
  475. <itemData name="String Char" defStyleNum="dsSpecialChar" spellChecking="false"/>
  476. <itemData name="String Literal Prefix" defStyleNum="dsString" spellChecking="true" />
  477. <itemData name="Comment" defStyleNum="dsComment"/>
  478. <itemData name="Symbol" defStyleNum="dsOperator" spellChecking="false"/>
  479. <itemData name="Preprocessor" defStyleNum="dsPreprocessor" spellChecking="false"/>
  480. <itemData name="Prep. Lib" defStyleNum="dsImport" spellChecking="false"/>
  481. <itemData name="Region Marker" defStyleNum="dsRegionMarker" spellChecking="false"/>
  482. <itemData name="Error" defStyleNum="dsError" spellChecking="false"/>
  483. </itemDatas>
  484. </highlighting>
  485. <general>
  486. <comments>
  487. <comment name="singleLine" start="//" position="afterwhitespace" />
  488. <comment name="multiLine" start="/*" end="*/" region="Comment" />
  489. </comments>
  490. <keywords casesensitive="1" additionalDeliminator="#'&quot;" />
  491. </general>
  492. </language>
  493. <!-- kate: replace-tabs on; tab-width 2; indent-width 2; -->