@@ -59,12 +59,8 @@ comments:
5959
6060scopes :
6161 ' translation_unit' : ' source.c'
62- ' comment' : ' comment.block'
63-
64- ' identifier' : [
65- {match : ' ^[A-Z\\ d_]+$' , scopes : ' constant.other' }
66- ]
6762
63+ # Keyword
6864 ' "#if"' : ' keyword.control.directive'
6965 ' "#ifdef"' : ' keyword.control.directive'
7066 ' "#ifndef"' : ' keyword.control.directive'
@@ -74,112 +70,213 @@ scopes:
7470 ' "#define"' : ' keyword.control.directive'
7571 ' "#include"' : ' keyword.control.directive'
7672 ' preproc_directive' : ' keyword.control.directive'
73+ ' "__attribute__"' : ' keyword.control.directive'
7774
78- ' "if"' : ' keyword.control'
79- ' "else"' : ' keyword.control'
80- ' "do"' : ' keyword.control'
81- ' "for"' : ' keyword.control'
82- ' "while"' : ' keyword.control'
83- ' "break"' : ' keyword.control'
84- ' "continue"' : ' keyword.control'
85- ' "return"' : ' keyword.control'
86- ' "switch"' : ' keyword.control'
87- ' "case"' : ' keyword.control'
88- ' "default"' : ' keyword.control'
89- ' "goto"' : ' keyword.control'
90-
91- ' "struct"' : ' keyword.control'
92- ' "enum"' : ' keyword.control'
93- ' "union"' : ' keyword.control'
94- ' "typedef"' : ' keyword.control'
95-
96- ' preproc_function_def > identifier:nth-child(1)' : ' entity.name.function.preprocessor'
97- ' preproc_arg' : ' meta.preprocessor.macro'
75+ ' "if"' : ' keyword.control.condition'
76+ ' "else"' : ' keyword.control.condition'
77+ ' "switch"' : ' keyword.control.condition'
78+ ' "case"' : ' keyword.control.condition'
79+ ' "default"' : ' keyword.control.condition'
80+ ' "do"' : ' keyword.control.loop'
81+ ' "for"' : ' keyword.control.loop'
82+ ' "while"' : ' keyword.control.loop'
83+ ' "break"' : ' keyword.control.jump'
84+ ' "continue"' : ' keyword.control.jump'
85+ ' "return"' : ' keyword.control.jump'
86+ ' "goto"' : ' keyword.control.jump'
9887
99- '''
100- call_expression > identifier,
101- call_expression > field_expression > field_identifier,
102- function_declarator > identifier
103- ''' : ' entity.name.function'
88+ ' "sizeof"' : ' keyword.operator.sizeof'
10489
105- ' statement_identifier' : ' constant.variable'
90+ ' "+"' : ' keyword.operator.arithmetic.symbol'
91+ ' "-"' : ' keyword.operator.arithmetic.symbol'
92+ ' binary_expression > "*"' : ' keyword.operator.arithmetic.symbol'
93+ ' "/"' : ' keyword.operator.arithmetic.symbol'
94+ ' "%"' : ' keyword.operator.arithmetic.symbol'
95+ ' "++"' : ' keyword.operator.arithmetic.symbol'
96+ ' "--"' : ' keyword.operator.arithmetic.symbol'
10697
107- ' field_identifier' : ' variable.other.member'
98+ ' binary_expression > "&"' : ' keyword.operator.bitwise.symbol'
99+ ' "|"' : ' keyword.operator.bitwise.symbol'
100+ ' "^"' : ' keyword.operator.bitwise.symbol'
101+ ' "~"' : ' keyword.operator.bitwise.symbol'
102+ ' "<<"' : ' keyword.operator.bitwise.shift.symbol'
103+ ' ">>"' : ' keyword.operator.bitwise.shift.symbol'
108104
109- ' type_identifier' : ' support.storage.type'
110- ' primitive_type' : ' support.storage.type'
111- ' "signed"' : ' support.storage.type'
112- ' "unsigned"' : ' support.storage.type'
113- ' "short"' : ' support.storage.type'
114- ' "long"' : ' support.storage.type'
105+ ' "="' : ' keyword.operator.assignment.symbol'
106+ ' "+="' : ' keyword.operator.assignment.compound.symbol'
107+ ' "-="' : ' keyword.operator.assignment.compound.symbol'
108+ ' "*="' : ' keyword.operator.assignment.compound.symbol'
109+ ' "/="' : ' keyword.operator.assignment.compound.symbol'
110+ ' "%="' : ' keyword.operator.assignment.compound.symbol'
111+ ' "<<="' : ' keyword.operator.assignment.compound.symbol'
112+ ' ">>="' : ' keyword.operator.assignment.compound.symbol'
113+ ' "&="' : ' keyword.operator.assignment.compound.symbol'
114+ ' "|="' : ' keyword.operator.assignment.compound.symbol'
115+ ' "^="' : ' keyword.operator.assignment.compound.symbol'
115116
116- ' char_literal' : ' string.quoted.single'
117- ' string_literal' : ' string.quoted.double'
118- ' system_lib_string' : ' string.quoted.other'
119- ' escape_sequence' : ' constant.character.escape'
117+ ' "=="' : ' keyword.operator.comparison.symbol'
118+ ' "!="' : ' keyword.operator.comparison.symbol'
119+ ' "<"' : ' keyword.operator.comparison.symbol'
120+ ' ">"' : ' keyword.operator.comparison.symbol'
121+ ' "<="' : ' keyword.operator.comparison.symbol'
122+ ' ">="' : ' keyword.operator.comparison.symbol'
120123
121- ' number_literal' : ' constant.numeric.decimal'
122- ' null' : ' constant.language.null'
123- ' true' : ' constant.language.boolean'
124- ' false' : ' constant.language.boolean'
124+ ' "!"' : ' keyword.operator.logical.symbol'
125+ ' "&&"' : ' keyword.operator.logical.symbol'
126+ ' "||"' : ' keyword.operator.logical.symbol'
127+
128+ ' "&"' : ' keyword.operator.pointer.reference.symbol'
129+ ' "*"' : ' keyword.operator.pointer.dereference.symbol'
130+
131+ ' "?"' : ' keyword.operator.ternary.symbol'
132+ ' conditional_expression > ":"' : ' keyword.operator.ternary.symbol'
133+
134+ # Storage
135+ ' "typedef"' : ' storage.declaration.datatype'
136+ ' "struct"' : ' storage.declaration.structure'
137+ ' "enum"' : ' storage.declaration.enumeration'
138+ ' "union"' : ' storage.declaration.union'
125139
126- ' auto' : ' storage.modifier'
127140 ' "extern"' : ' storage.modifier'
128- ' "register"' : ' storage.modifier'
129141 ' "static"' : ' storage.modifier'
142+ ' "register"' : ' storage.modifier'
130143 ' "inline"' : ' storage.modifier'
131144 ' "const"' : ' storage.modifier'
132145 ' "volatile"' : ' storage.modifier'
133146 ' "restrict"' : ' storage.modifier'
134147 ' "_Atomic"' : ' storage.modifier'
148+ ' auto' : ' storage.modifier'
135149 ' function_specifier' : ' storage.modifier'
136150
137- ' ";"' : ' punctuation.terminator.statement'
138- ' "["' : ' punctuation.definition.begin.bracket.square'
139- ' "]"' : ' punctuation.definition.end.bracket.square'
140- ' ","' : ' punctuation.separator.delimiter'
141- ' char_literal > "\' "' : ' punctuation.definition.string'
151+ ' "unsigned"' : ' storage.type.fundamental'
152+ ' "signed"' : ' storage.type.fundamental'
153+ ' "short"' : ' storage.type.fundamental'
154+ ' "long"' : ' storage.type.fundamental'
155+ ' primitive_type' : ' storage.type.fundamental'
156+
157+ # Entity
158+ ' type_identifier' : ' entity.type'
159+
160+ ' identifier' : [
161+ {
162+ match : ' ^[A-Z\\ d_]+$' ,
163+ scopes : ' entity.variable.immutable'
164+ },
165+ ' entity.variable'
166+ ]
167+
168+ ' field_identifier' : ' entity.variable.member'
169+
170+ ' statement_identifier' : ' entity.label'
171+
172+ '''
173+ preproc_function_def > identifier:nth-child(1),
174+ function_declarator > identifier
175+ ''' : ' entity.function'
176+
177+ '''
178+ call_expression > identifier,
179+ call_expression > field_expression > field_identifier
180+ ''' : ' entity.function.call'
181+
182+ # String
183+ ' string_literal' : ' string.quoted'
184+ ' system_lib_string' : ' string.quoted'
185+
186+ # Constant
187+ ' char_literal' : ' constant.character'
188+ ' escape_sequence' : ' constant.character.escape'
189+ ' preproc_include > string_literal > escape_sequence' : ' ' # No escape characters in include directive
190+
191+ ' number_literal' : ' constant.numeric.decimal'
192+
193+ ' null' : ' constant.language.null'
194+ ' true' : ' constant.language.boolean.true'
195+ ' false' : ' constant.language.boolean.false'
196+
197+ # Comment
198+ ' comment' : ' comment.block'
199+
200+ # Punctuation
201+ ' ":"' : ' punctuation.definition'
202+ ' "["' : ' punctuation.definition'
203+ ' "]"' : ' punctuation.definition'
204+ ' "{"' : ' punctuation.definition'
205+ ' "}"' : ' punctuation.definition'
206+ ' "("' : ' punctuation.definition'
207+ ' ")"' : ' punctuation.definition'
208+ ' ","' : ' punctuation.separator'
209+ ' ";"' : ' punctuation.terminator'
210+ ' "."' : ' punctuation.accessor.member'
211+ ' "->"' : ' punctuation.accessor.member'
212+ ' "..."' : ' punctuation.definition.variadic'
213+ ' char_literal > "\' "' : ' punctuation.definition.constant.character'
142214 ' string_literal > "\\ ""' : ' punctuation.definition.string'
143- ' "{"' : ' punctuation.section.block.begin.bracket.curly'
144- ' "}"' : ' punctuation.section.block.end.bracket.curly'
145- ' "("' : ' punctuation.section.parens.begin.bracket.round'
146- ' ")"' : ' punctuation.section.parens.end.bracket.round'
147215
148- ' "sizeof"' : ' keyword.operator.sizeof'
149- ' "."' : ' keyword.operator.member'
150- ' "->"' : ' keyword.operator.member'
151- ' "*"' : ' keyword.operator'
152- ' "-"' : ' keyword.operator'
153- ' "+"' : ' keyword.operator'
154- ' "/"' : ' keyword.operator'
155- ' "%"' : ' keyword.operator'
156- ' "++"' : ' keyword.operator'
157- ' "--"' : ' keyword.operator'
158- ' "=="' : ' keyword.operator'
159- ' "!"' : ' keyword.operator'
160- ' "!="' : ' keyword.operator'
161- ' "<"' : ' keyword.operator'
162- ' ">"' : ' keyword.operator'
163- ' ">="' : ' keyword.operator'
164- ' "<="' : ' keyword.operator'
165- ' "&&"' : ' keyword.operator'
166- ' "||"' : ' keyword.operator'
167- ' "&"' : ' keyword.operator'
168- ' "|"' : ' keyword.operator'
169- ' "^"' : ' keyword.operator'
170- ' "~"' : ' keyword.operator'
171- ' "<<"' : ' keyword.operator'
172- ' ">>"' : ' keyword.operator'
173- ' "="' : ' keyword.operator'
174- ' "+="' : ' keyword.operator'
175- ' "-="' : ' keyword.operator'
176- ' "*="' : ' keyword.operator'
177- ' "/="' : ' keyword.operator'
178- ' "%="' : ' keyword.operator'
179- ' "<<="' : ' keyword.operator'
180- ' ">>="' : ' keyword.operator'
181- ' "&="' : ' keyword.operator'
182- ' "^="' : ' keyword.operator'
183- ' "|="' : ' keyword.operator'
184- ' "?"' : ' keyword.operator'
185- ' ":"' : ' keyword.operator'
216+ ' array_declarator > "["' : ' punctuation.definition.collection.array'
217+ ' array_declarator > "]"' : ' punctuation.definition.collection.array'
218+ ' abstract_array_declarator > "["' : ' punctuation.definition.collection.array'
219+ ' abstract_array_declarator > "]"' : ' punctuation.definition.collection.array'
220+
221+ ' subscript_expression > "["' : ' punctuation.accessor.subscript'
222+ ' subscript_expression > "]"' : ' punctuation.accessor.subscript'
223+ ' subscript_designator > "["' : ' punctuation.accessor.subscript'
224+ ' subscript_designator > "]"' : ' punctuation.accessor.subscript'
225+
226+ ' compound_statement > "{"' : ' punctuation.definition.statement'
227+ ' compound_statement > "}"' : ' punctuation.definition.statement'
228+
229+ ' function_definition > compound_statement > "{"' : ' punctuation.definition.body.function'
230+ ' function_definition > compound_statement > "}"' : ' punctuation.definition.body.function'
231+
232+ ' enumerator_list > "{"' : ' punctuation.definition.body.enumeration'
233+ ' enumerator_list > "}"' : ' punctuation.definition.body.enumeration'
234+
235+ ' union_specifier > field_declaration_list > "{"' : ' punctuation.definition.body.union'
236+ ' union_specifier > field_declaration_list > "}"' : ' punctuation.definition.body.union'
237+
238+ ' struct_specifier > field_declaration_list > "{"' : ' punctuation.definition.body.structure'
239+ ' struct_specifier > field_declaration_list > "}"' : ' punctuation.definition.body.structure'
240+
241+ ' preproc_params > "("' : ' punctuation.definition.parameters'
242+ ' preproc_params > ")"' : ' punctuation.definition.parameters'
243+
244+ ' parameter_list > "("' : ' punctuation.definition.parameters'
245+ ' parameter_list > ")"' : ' punctuation.definition.parameters'
246+ ' argument_list > "("' : ' punctuation.definition.arguments'
247+ ' argument_list > ")"' : ' punctuation.definition.arguments'
248+
249+ ' sizeof_expression > "("' : ' punctuation.definition.arguments'
250+ ' sizeof_expression > ")"' : ' punctuation.definition.arguments'
251+ ' sizeof_expression > parenthesized_expression > "("' : ' punctuation.definition.arguments'
252+ ' sizeof_expression > parenthesized_expression > ")"' : ' punctuation.definition.arguments'
253+
254+ ' attribute_specifier > "("' : ' punctuation.definition.arguments'
255+ ' attribute_specifier > ")"' : ' punctuation.definition.arguments'
256+
257+ ' cast_expression > "("' : ' punctuation.definition.cast'
258+ ' cast_expression > ")"' : ' punctuation.definition.cast'
259+
260+ ' compound_literal_expression > "("' : ' punctuation.definition.expression'
261+ ' compound_literal_expression > ")"' : ' punctuation.definition.expression'
262+
263+ ' parenthesized_expression > "("' : ' punctuation.definition.expression'
264+ ' parenthesized_expression > ")"' : ' punctuation.definition.expression'
265+
266+ ' for_statement > "("' : ' punctuation.definition.expression'
267+ ' for_statement > ")"' : ' punctuation.definition.expression'
268+
269+ ' ERROR > ":"' : ' punctuation.definition.invalid.illegal'
270+ ' ERROR > "["' : ' punctuation.definition.invalid.illegal'
271+ ' ERROR > "]"' : ' punctuation.definition.invalid.illegal'
272+ ' ERROR > "{"' : ' punctuation.definition.invalid.illegal'
273+ ' ERROR > "}"' : ' punctuation.definition.invalid.illegal'
274+ ' ERROR > "("' : ' punctuation.definition.invalid.illegal'
275+ ' ERROR > ")"' : ' punctuation.definition.invalid.illegal'
276+ ' ERROR > ","' : ' punctuation.separator.invalid.illegal'
277+ ' ERROR > ";"' : ' punctuation.terminator.invalid.illegal'
278+ ' ERROR > "."' : ' punctuation.accessor.member.invalid.illegal'
279+ ' ERROR > "->"' : ' punctuation.accessor.member.invalid.illegal'
280+ ' ERROR > "..."' : ' punctuation.definition.variadic.invalid.illegal'
281+ ' ERROR > "\' "' : ' punctuation.definition.constant.character.invalid.illegal'
282+ ' ERROR > "\\ ""' : ' punctuation.definition.string.invalid.illegal'
0 commit comments