c.syntax 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. # Syntax rules for the C (and partially C++) programming languages.
  2. #
  3. # Rewritten and extended with defines by Morthimer McMare
  4. # <mailto:morthimer_second@list.ru>
  5. #
  6. # Tab size: 4.
  7. # Feel free to improve the highlighting file.
  8. #
  9. # Date:
  10. # Initial 2024.04.24;
  11. # Updated 2024.06.26 (first public release. Classic Midnight Commander C-syntax theme set by default, added keywords from the C23 standard).
  12. #
  13. # For the default (blue) background.
  14. # The colors almost match the original "c.syntax" file, slightly extending it:
  15. define _punctuation yellow
  16. define _punct_operator brightcyan
  17. define _punct_semicolon brightmagenta
  18. define _punct_bracket brightcyan
  19. define _punct_sqbracket brightcyan
  20. define _punct_field yellow
  21. define _punct_comma brightcyan
  22. define _punct_ternary brightcyan
  23. define _punct_bitwise brightmagenta
  24. define _label cyan
  25. define _preproc brightred
  26. define _preproc_str red
  27. define _preproc_nl_esc red
  28. define _preproc_indent brightmagenta
  29. define _keyword yellow
  30. define _datatype yellow
  31. define _datatype_void yellow
  32. define _datatype_mod yellow
  33. define _datatype_scope yellow
  34. define _const lightgray
  35. define _num_integer lightgray
  36. define _num_hex lightgray
  37. define _num_oct lightgray
  38. define _num_float lightgray
  39. define _string green
  40. define _string_specsymb brightgreen
  41. define _string_escchar brightgreen
  42. define _char brightgreen
  43. define _comment brown
  44. define _comment_word black brown
  45. define _comment_exmark black yellow
  46. define _comment_qnmark black brown
  47. # I think this highlighting is easier for the eyes for the black background themes. Can be also used with the blue background:
  48. #define _punctuation yellow
  49. #define _punct_operator brightmagenta
  50. #define _punct_semicolon brightmagenta
  51. #define _punct_bracket yellow
  52. #define _punct_sqbracket brown
  53. #define _punct_field yellow
  54. #define _punct_comma yellow
  55. #define _punct_ternary white
  56. #define _punct_bitwise yellow
  57. #define _label brightcyan
  58. #define _preproc lightgray
  59. #define _preproc_str white
  60. #define _preproc_nl_esc white
  61. #define _preproc_indent lightgray
  62. #define _keyword brightcyan
  63. #define _datatype brightcyan
  64. #define _datatype_void brightcyan
  65. #define _datatype_mod brightcyan
  66. #define _datatype_scope brightblue
  67. #define _const lightgray
  68. #define _num_integer red
  69. #define _num_hex red
  70. #define _num_oct red
  71. #define _num_float magenta
  72. #define _string brightgreen
  73. #define _string_specsymb brightcyan
  74. #define _string_escchar brightcyan
  75. #define _char brightgreen
  76. #define _comment gray
  77. #define _comment_word black gray
  78. #define _comment_exmark black yellow
  79. #define _comment_qnmark black brown
  80. context default
  81. keyword whole asm _keyword
  82. keyword whole break _keyword
  83. keyword whole case _keyword
  84. keyword whole const _keyword
  85. keyword whole continue _keyword
  86. keyword whole do _keyword
  87. keyword whole else _keyword
  88. keyword whole enum _keyword
  89. keyword whole for _keyword
  90. keyword whole goto _keyword
  91. keyword whole if _keyword
  92. keyword whole inline _keyword
  93. keyword whole restrict _keyword
  94. keyword whole return _keyword
  95. keyword whole sizeof _keyword
  96. keyword whole struct _keyword
  97. keyword whole switch _keyword
  98. keyword whole typedef _keyword
  99. keyword whole union _keyword
  100. keyword whole volatile _keyword
  101. keyword whole while _keyword
  102. # C11/C23 extensions:
  103. keyword whole alignas _keyword
  104. keyword whole alignof _keyword
  105. keyword whole constexpr _keyword
  106. keyword whole typeof _keyword
  107. keyword whole typeof_unqual _keyword
  108. keyword whole static_assert _keyword
  109. keyword whole thread_local _keyword
  110. keyword whole _Alignas _keyword
  111. keyword whole _Alignof _keyword
  112. keyword whole _Atomic _keyword
  113. keyword whole _Bool _keyword
  114. keyword whole _Complex _keyword
  115. keyword whole _Decimal32 _keyword
  116. keyword whole _Decimal64 _keyword
  117. keyword whole _Decimal128 _keyword
  118. keyword whole _Generic _keyword
  119. keyword whole _Imaginary _keyword
  120. keyword whole _Noreturn _keyword
  121. keyword whole _Static_assert _keyword
  122. keyword whole _Thread_local _keyword
  123. keyword whole auto _datatype_scope
  124. keyword whole extern _datatype_scope
  125. keyword whole register _datatype_scope
  126. keyword whole static _datatype_scope
  127. keyword whole void _datatype_void
  128. keyword whole int _datatype
  129. keyword whole char _datatype
  130. keyword whole float _datatype
  131. keyword whole double _datatype
  132. keyword whole wchar_t _datatype
  133. keyword whole short _datatype_mod
  134. keyword whole long _datatype_mod
  135. keyword whole signed _datatype_mod
  136. keyword whole unsigned _datatype_mod
  137. keyword whole wchar_t _datatype
  138. keyword whole ... _keyword
  139. keyword NULL _const
  140. # Since C23:
  141. keyword true _const
  142. keyword false _const
  143. keyword nullptr _const
  144. keyword linestart \{\s\t\}\[\s\t\]#*\n _preproc_indent
  145. keyword whole linestart \[\s\t\]\{ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz\}\[0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz\]: _label
  146. keyword whole \[\s\t\]default _keyword
  147. # Comments:
  148. keyword /\* _comment
  149. keyword \*/ _comment
  150. keyword // _comment
  151. # Characters:
  152. keyword '\\\{"abtnvfr\}' _char
  153. keyword '\\\{0123\}\{01234567\}\{01234567\}' _char
  154. keyword '\\'' _char
  155. keyword '\\\\' _char
  156. keyword '\\0' _char
  157. keyword '\{\s!"#$%&()\*\+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~嵗╯丰戍貝物洎悖停眾斯須號獄播噶擱藏霰匸�帊昅恘倳眑婭笫崷窙嗲睧颬睼麧緗鴇膹擨闀貘覷鏷禴矙𡜍𦶠�\}' _char
  158. # Punctuation characters, sorted by ASCII code:
  159. keyword ! _punctuation
  160. keyword % _punctuation
  161. keyword && _punctuation
  162. # Note: the '&' symbol uses both in the reference/address and in the bitwise operation.
  163. keyword & _punct_bitwise
  164. keyword ( _punct_bracket
  165. keyword ) _punct_bracket
  166. keyword \* _punctuation
  167. keyword \+ _punctuation
  168. keyword , _punct_comma
  169. keyword . _punct_field
  170. keyword -> _punct_field
  171. keyword - _punctuation
  172. keyword / _punctuation
  173. keyword : _punct_ternary
  174. keyword ; _punct_semicolon
  175. keyword < _punctuation
  176. keyword = _punctuation
  177. keyword > _punctuation
  178. keyword ? _punct_ternary
  179. keyword [ _punct_sqbracket
  180. keyword ] _punct_sqbracket
  181. keyword ^ _punct_bitwise
  182. keyword { _punct_operator
  183. keyword || _punctuation
  184. keyword | _punct_bitwise
  185. keyword } _punct_operator
  186. keyword ~ _punct_bitwise
  187. # Numbers:
  188. wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.
  189. keyword whole 0x\{0123456789abcdefABCDEF_\}\[0123456789abcdefABCDEF_\] _num_hex
  190. keyword whole 0\{01234567_\}\[01234567_\] _num_oct
  191. keyword whole 0 _num_integer
  192. keyword whole 0\{lu\} _num_integer
  193. keyword whole \{123456789_\}\[0123456789_\] _num_integer
  194. keyword whole \{123456789_\}\[0123456789_\]\{lu\} _num_integer
  195. # Float-point values:
  196. keyword whole \[0123456789_\]\.\{0123456789_\}\[0123456789_\] _num_float
  197. keyword whole \{0123456789_\}\[0123456789_\]\.\[0123456789_\] _num_float
  198. keyword whole \{0123456789_\}\[0123456789_\]\{eE\}\{0123456789_\}\[0123456789_\] _num_float
  199. keyword whole \{0123456789_\}\[0123456789_\]\{eE\}\{\-\+\}\{0123456789_\}\[0123456789_\] _num_float
  200. keyword whole \{0123456789_\}\[0123456789_\]\.\{0123456789_\}\[0123456789_\]\{eE\}\{0123456789_\}\[0123456789_\] _num_float
  201. keyword whole \{0123456789_\}\[0123456789_\]\.\{0123456789_\}\[0123456789_\]\{eE\}\{\-\+\}\{0123456789_\}\[0123456789_\] _num_float
  202. # Explicit float (not double):
  203. keyword whole \[0123456789_\]\.\{0123456789_\}\[0123456789_\]f _num_float
  204. keyword whole \{0123456789_\}\[0123456789_\]\.\[0123456789_\]f _num_float
  205. keyword whole \{0123456789_\}\[0123456789_\]\{eE\}\{0123456789_\}\[0123456789_\]f _num_float
  206. keyword whole \{0123456789_\}\[0123456789_\]\{eE\}\{\-\+\}\{0123456789_\}\[0123456789_\]f _num_float
  207. keyword whole \{0123456789_\}\[0123456789_\]\.\{0123456789_\}\[0123456789_\]\{eE\}\{0123456789_\}\[0123456789_\]f _num_float
  208. keyword whole \{0123456789_\}\[0123456789_\]\.\{0123456789_\}\[0123456789_\]\{eE\}\{\-\+\}\{0123456789_\}\[0123456789_\]f _num_float
  209. context exclusive /\* \*/ _comment
  210. keyword whole BUG _comment_word
  211. keyword whole FixMe _comment_word
  212. keyword whole FIXME _comment_word
  213. keyword whole Note _comment_word
  214. keyword whole NOTE _comment_word
  215. keyword whole ToDo _comment_word
  216. keyword whole TODO _comment_word
  217. keyword !!\[!\] _comment_exmark
  218. keyword ??\[?\] _comment_qnmark
  219. spellcheck
  220. context exclusive // \n _comment
  221. keyword whole BUG: _comment_word
  222. keyword whole FixMe: _comment_word
  223. keyword whole FIXME: _comment_word
  224. keyword whole Note: _comment_word
  225. keyword whole NOTE: _comment_word
  226. keyword whole ToDo: _comment_word
  227. keyword whole TODO: _comment_word
  228. keyword !!\[!\] _comment_exmark
  229. keyword ??\[?\] _comment_qnmark
  230. spellcheck
  231. context linestart # \n _preproc
  232. keyword \\\n _preproc_nl_esc
  233. keyword /\**\*/ _comment
  234. keyword //*\n _comment
  235. keyword "+" _preproc_str
  236. keyword <+> _preproc_str
  237. context " " _string
  238. spellcheck
  239. keyword \\" _string_escchar
  240. keyword %% _string_specsymb
  241. keyword %\[#0\s-\+,\]\[0123456789\*\]\[.\]\[0123456789\*\]\[L\]\{eEfgGoxX\} _string_specsymb
  242. keyword %\[0\s-\+,\]\[0123456789\*\]\[.\]\[0123456789\*\]\[hl\]\{diuxX\} _string_specsymb
  243. keyword %\[hl\]n _string_specsymb
  244. keyword %\[-\]\[0123456789\*\]\[.\]\[0123456789\*\]s _string_specsymb
  245. keyword %[*] _string_specsymb
  246. keyword %c _string_specsymb
  247. keyword %p _string_specsymb
  248. keyword \\\{0123\}\{01234567\}\{01234567\} _string_specsymb
  249. keyword \\\\ _string_escchar
  250. keyword \\' _string_escchar
  251. keyword \\\{abtnvfr\} _string_escchar