1 # Syntax rules for the C (and partially C++) programming languages.
4 # Rewritten and extended with defines by Morthimer McMare
5 # <mailto:morthimer_second@list.ru>
8 # Feel free to improve the highlighting file.
12 # Updated 2024.06.26 (first public release. Classic Midnight Commander C-syntax theme set by default, added keywords from the C23 standard).
16 # For the default (blue) background.
17 # The colors almost match the original "c.syntax" file, slightly extending it:
18 define _punctuation yellow
19 define _punct_operator brightcyan
20 define _punct_semicolon brightmagenta
21 define _punct_bracket brightcyan
22 define _punct_sqbracket brightcyan
23 define _punct_field yellow
24 define _punct_comma brightcyan
25 define _punct_ternary brightcyan
26 define _punct_bitwise brightmagenta
28 define _preproc brightred
29 define _preproc_str red
30 define _preproc_nl_esc red
31 define _preproc_indent brightmagenta
32 define _keyword yellow
33 define _datatype yellow
34 define _datatype_void yellow
35 define _datatype_mod yellow
36 define _datatype_scope yellow
37 define _const lightgray
38 define _num_integer lightgray
39 define _num_hex lightgray
40 define _num_oct lightgray
41 define _num_float lightgray
43 define _string_specsymb brightgreen
44 define _string_escchar brightgreen
45 define _char brightgreen
47 define _comment_word black brown
48 define _comment_exmark black yellow
49 define _comment_qnmark black brown
51 # I think this highlighting is easier for the eyes for the black background themes. Can be also used with the blue background:
52 #define _punctuation yellow
53 #define _punct_operator brightmagenta
54 #define _punct_semicolon brightmagenta
55 #define _punct_bracket yellow
56 #define _punct_sqbracket brown
57 #define _punct_field yellow
58 #define _punct_comma yellow
59 #define _punct_ternary white
60 #define _punct_bitwise yellow
61 #define _label brightcyan
62 #define _preproc lightgray
63 #define _preproc_str white
64 #define _preproc_nl_esc white
65 #define _preproc_indent lightgray
66 #define _keyword brightcyan
67 #define _datatype brightcyan
68 #define _datatype_void brightcyan
69 #define _datatype_mod brightcyan
70 #define _datatype_scope brightblue
71 #define _const lightgray
72 #define _num_integer red
75 #define _num_float magenta
76 #define _string brightgreen
77 #define _string_specsymb brightcyan
78 #define _string_escchar brightcyan
79 #define _char brightgreen
81 #define _comment_word black gray
82 #define _comment_exmark black yellow
83 #define _comment_qnmark black brown
87 keyword whole asm _keyword
88 keyword whole break _keyword
89 keyword whole case _keyword
90 keyword whole const _keyword
91 keyword whole continue _keyword
92 keyword whole do _keyword
93 keyword whole else _keyword
94 keyword whole enum _keyword
95 keyword whole for _keyword
96 keyword whole goto _keyword
97 keyword whole if _keyword
98 keyword whole inline _keyword
99 keyword whole restrict _keyword
100 keyword whole return _keyword
101 keyword whole sizeof _keyword
102 keyword whole struct _keyword
103 keyword whole switch _keyword
104 keyword whole typedef _keyword
105 keyword whole union _keyword
106 keyword whole volatile _keyword
107 keyword whole while _keyword
109 # C11/C23 extensions:
110 keyword whole alignas _keyword
111 keyword whole alignof _keyword
112 keyword whole constexpr _keyword
113 keyword whole typeof _keyword
114 keyword whole typeof_unqual _keyword
115 keyword whole static_assert _keyword
116 keyword whole thread_local _keyword
117 keyword whole _Alignas _keyword
118 keyword whole _Alignof _keyword
119 keyword whole _Atomic _keyword
120 keyword whole _Bool _keyword
121 keyword whole _Complex _keyword
122 keyword whole _Decimal32 _keyword
123 keyword whole _Decimal64 _keyword
124 keyword whole _Decimal128 _keyword
125 keyword whole _Generic _keyword
126 keyword whole _Imaginary _keyword
127 keyword whole _Noreturn _keyword
128 keyword whole _Static_assert _keyword
129 keyword whole _Thread_local _keyword
131 keyword whole auto _datatype_scope
132 keyword whole extern _datatype_scope
133 keyword whole register _datatype_scope
134 keyword whole static _datatype_scope
136 keyword whole void _datatype_void
137 keyword whole int _datatype
138 keyword whole char _datatype
139 keyword whole float _datatype
140 keyword whole double _datatype
141 keyword whole wchar_t _datatype
142 keyword whole short _datatype_mod
143 keyword whole long _datatype_mod
144 keyword whole signed _datatype_mod
145 keyword whole unsigned _datatype_mod
146 keyword whole wchar_t _datatype
147 keyword whole ... _keyword
153 keyword nullptr _const
155 keyword linestart \{\s\t\}\[\s\t\]#*\n _preproc_indent
156 keyword whole linestart \[\s\t\]\{ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz\}\[0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz\]: _label
157 keyword whole \[\s\t\]default _keyword
165 keyword '\\\{"abtnvfr\}' _char
166 keyword '\\\{0123\}\{01234567\}\{01234567\}' _char
170 keyword '\{\s!"#$%&()\*\+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~ ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ\}' _char
172 # Punctuation characters, sorted by ASCII code:
173 keyword ! _punctuation
174 keyword % _punctuation
175 keyword && _punctuation
176 # Note: the '&' symbol uses both in the reference/address and in the bitwise operation.
177 keyword & _punct_bitwise
178 keyword ( _punct_bracket
179 keyword ) _punct_bracket
180 keyword \* _punctuation
181 keyword \+ _punctuation
182 keyword , _punct_comma
183 keyword . _punct_field
184 keyword -> _punct_field
185 keyword - _punctuation
186 keyword / _punctuation
187 keyword : _punct_ternary
188 keyword ; _punct_semicolon
189 keyword < _punctuation
190 keyword = _punctuation
191 keyword > _punctuation
192 keyword ? _punct_ternary
193 keyword [ _punct_sqbracket
194 keyword ] _punct_sqbracket
195 keyword ^ _punct_bitwise
196 keyword { _punct_operator
197 keyword || _punctuation
198 keyword | _punct_bitwise
199 keyword } _punct_operator
200 keyword ~ _punct_bitwise
203 wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.
205 keyword whole 0x\{0123456789abcdefABCDEF_\}\[0123456789abcdefABCDEF_\] _num_hex
206 keyword whole 0\{01234567_\}\[01234567_\] _num_oct
207 keyword whole 0 _num_integer
208 keyword whole 0\{lu\} _num_integer
209 keyword whole \{123456789_\}\[0123456789_\] _num_integer
210 keyword whole \{123456789_\}\[0123456789_\]\{lu\} _num_integer
211 # Float-point values:
212 keyword whole \[0123456789_\]\.\{0123456789_\}\[0123456789_\] _num_float
213 keyword whole \{0123456789_\}\[0123456789_\]\.\[0123456789_\] _num_float
214 keyword whole \{0123456789_\}\[0123456789_\]\{eE\}\{0123456789_\}\[0123456789_\] _num_float
215 keyword whole \{0123456789_\}\[0123456789_\]\{eE\}\{\-\+\}\{0123456789_\}\[0123456789_\] _num_float
216 keyword whole \{0123456789_\}\[0123456789_\]\.\{0123456789_\}\[0123456789_\]\{eE\}\{0123456789_\}\[0123456789_\] _num_float
217 keyword whole \{0123456789_\}\[0123456789_\]\.\{0123456789_\}\[0123456789_\]\{eE\}\{\-\+\}\{0123456789_\}\[0123456789_\] _num_float
218 # Explicit float (not double):
219 keyword whole \[0123456789_\]\.\{0123456789_\}\[0123456789_\]f _num_float
220 keyword whole \{0123456789_\}\[0123456789_\]\.\[0123456789_\]f _num_float
221 keyword whole \{0123456789_\}\[0123456789_\]\{eE\}\{0123456789_\}\[0123456789_\]f _num_float
222 keyword whole \{0123456789_\}\[0123456789_\]\{eE\}\{\-\+\}\{0123456789_\}\[0123456789_\]f _num_float
223 keyword whole \{0123456789_\}\[0123456789_\]\.\{0123456789_\}\[0123456789_\]\{eE\}\{0123456789_\}\[0123456789_\]f _num_float
224 keyword whole \{0123456789_\}\[0123456789_\]\.\{0123456789_\}\[0123456789_\]\{eE\}\{\-\+\}\{0123456789_\}\[0123456789_\]f _num_float
227 context exclusive /\* \*/ _comment
228 keyword whole BUG _comment_word
229 keyword whole FixMe _comment_word
230 keyword whole FIXME _comment_word
231 keyword whole Note _comment_word
232 keyword whole NOTE _comment_word
233 keyword whole ToDo _comment_word
234 keyword whole TODO _comment_word
235 keyword !!\[!\] _comment_exmark
236 keyword ??\[?\] _comment_qnmark
239 context exclusive // \n _comment
240 keyword whole BUG: _comment_word
241 keyword whole FixMe: _comment_word
242 keyword whole FIXME: _comment_word
243 keyword whole Note: _comment_word
244 keyword whole NOTE: _comment_word
245 keyword whole ToDo: _comment_word
246 keyword whole TODO: _comment_word
247 keyword !!\[!\] _comment_exmark
248 keyword ??\[?\] _comment_qnmark
251 context linestart # \n _preproc
252 keyword \\\n _preproc_nl_esc
253 keyword /\**\*/ _comment
254 keyword //*\n _comment
255 keyword "+" _preproc_str
256 keyword <+> _preproc_str
260 keyword \\" _string_escchar
261 keyword %% _string_specsymb
262 keyword %\[#0\s-\+,\]\[0123456789\*\]\[.\]\[0123456789\*\]\[L\]\{eEfgGoxX\} _string_specsymb
263 keyword %\[0\s-\+,\]\[0123456789\*\]\[.\]\[0123456789\*\]\[hl\]\{diuxX\} _string_specsymb
264 keyword %\[hl\]n _string_specsymb
265 keyword %\[-\]\[0123456789\*\]\[.\]\[0123456789\*\]s _string_specsymb
266 keyword %[*] _string_specsymb
267 keyword %c _string_specsymb
268 keyword %p _string_specsymb
269 keyword \\\{0123\}\{01234567\}\{01234567\} _string_specsymb
270 keyword \\\\ _string_escchar
271 keyword \\' _string_escchar
272 keyword \\\{abtnvfr\} _string_escchar