c.xml 27 KB

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