c.xml 27 KB

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