Skip to content

Commit 06d2f9c

Browse files
committed
Update C++ grammar to get macro fix
Also added a macro to the test Fixes microsoft#76430
1 parent 2c3e8a8 commit 06d2f9c

3 files changed

Lines changed: 168 additions & 1 deletion

File tree

extensions/cpp/syntaxes/cpp.tmLanguage.json

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
55
"Once accepted there, we are happy to receive an update request."
66
],
7-
"version": "https://github.com/jeff-hykin/cpp-textmate-grammar/commit/9c4f4b3291538d9f5144f02d3b6af877b84f2cb2",
7+
"version": "https://github.com/jeff-hykin/cpp-textmate-grammar/commit/19ef66475b6bb21b5ed466cbcf8cef4e1b1fa212",
88
"name": "C++",
99
"scopeName": "source.cpp",
1010
"patterns": [
@@ -57,6 +57,9 @@
5757
},
5858
"ever_present_context": {
5959
"patterns": [
60+
{
61+
"include": "#single_line_macro"
62+
},
6063
{
6164
"include": "#preprocessor_rule_enabled"
6265
},
@@ -11193,6 +11196,58 @@
1119311196
"match": "(?<!\\w)#(?:endif|else|elif)(?!\\w)",
1119411197
"name": "keyword.control.directive.$0.cpp"
1119511198
},
11199+
"single_line_macro": {
11200+
"match": "^((?:(?:(?>\\s+)|(\\/\\*)((?>(?:[^\\*]|(?>\\*+)[^\\/])*)((?>\\*+)\\/)))+?|(?:(?:(?:(?:\\b|(?<=\\W))|(?=\\W))|\\A)|\\Z)))#define.*(?<![\\\\])(?:\\n|$)",
11201+
"captures": {
11202+
"0": {
11203+
"patterns": [
11204+
{
11205+
"include": "#meta_preprocessor_macro"
11206+
},
11207+
{
11208+
"include": "#comments"
11209+
},
11210+
{
11211+
"include": "#string_context"
11212+
},
11213+
{
11214+
"include": "#number_literal"
11215+
},
11216+
{
11217+
"include": "#operators"
11218+
},
11219+
{
11220+
"include": "#semicolon"
11221+
}
11222+
]
11223+
},
11224+
"1": {
11225+
"patterns": [
11226+
{
11227+
"include": "#inline_comment"
11228+
}
11229+
]
11230+
},
11231+
"2": {
11232+
"name": "comment.block.cpp punctuation.definition.comment.begin.cpp"
11233+
},
11234+
"3": {
11235+
"name": "comment.block.cpp"
11236+
},
11237+
"4": {
11238+
"patterns": [
11239+
{
11240+
"match": "\\*\\/",
11241+
"name": "comment.block.cpp punctuation.definition.comment.end.cpp"
11242+
},
11243+
{
11244+
"match": "\\*",
11245+
"name": "comment.block.cpp"
11246+
}
11247+
]
11248+
}
11249+
}
11250+
},
1119611251
"assembly": {
1119711252
"name": "meta.asm.cpp",
1119811253
"begin": "(\\b(?:__asm__|asm)\\b)\\s*((?:volatile)?)\\s*(\\()",

extensions/cpp/test/colorize-fixtures/test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include <iostream>
33
using namespace std;
44

5+
#define EXTERN_C extern "C"
6+
57
class Rectangle {
68
int width, height;
79
public:

extensions/cpp/test/colorize-results/test_cpp.json

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,116 @@
153153
"hc_black": "default: #FFFFFF"
154154
}
155155
},
156+
{
157+
"c": "#",
158+
"t": "source.cpp source.cpp meta.preprocessor.macro.cpp keyword.control.directive.define.cpp punctuation.definition.directive.cpp",
159+
"r": {
160+
"dark_plus": "keyword.control: #C586C0",
161+
"light_plus": "keyword.control: #AF00DB",
162+
"dark_vs": "keyword.control: #569CD6",
163+
"light_vs": "keyword.control: #0000FF",
164+
"hc_black": "keyword.control: #C586C0"
165+
}
166+
},
167+
{
168+
"c": "define",
169+
"t": "source.cpp source.cpp meta.preprocessor.macro.cpp keyword.control.directive.define.cpp",
170+
"r": {
171+
"dark_plus": "keyword.control: #C586C0",
172+
"light_plus": "keyword.control: #AF00DB",
173+
"dark_vs": "keyword.control: #569CD6",
174+
"light_vs": "keyword.control: #0000FF",
175+
"hc_black": "keyword.control: #C586C0"
176+
}
177+
},
178+
{
179+
"c": " ",
180+
"t": "source.cpp source.cpp meta.preprocessor.macro.cpp",
181+
"r": {
182+
"dark_plus": "meta.preprocessor: #569CD6",
183+
"light_plus": "meta.preprocessor: #0000FF",
184+
"dark_vs": "meta.preprocessor: #569CD6",
185+
"light_vs": "meta.preprocessor: #0000FF",
186+
"hc_black": "meta.preprocessor: #569CD6"
187+
}
188+
},
189+
{
190+
"c": "EXTERN_C",
191+
"t": "source.cpp source.cpp meta.preprocessor.macro.cpp entity.name.function.preprocessor.cpp",
192+
"r": {
193+
"dark_plus": "entity.name.function: #DCDCAA",
194+
"light_plus": "entity.name.function: #795E26",
195+
"dark_vs": "meta.preprocessor: #569CD6",
196+
"light_vs": "meta.preprocessor: #0000FF",
197+
"hc_black": "entity.name.function: #DCDCAA"
198+
}
199+
},
200+
{
201+
"c": " ",
202+
"t": "source.cpp source.cpp meta.preprocessor.macro.cpp",
203+
"r": {
204+
"dark_plus": "meta.preprocessor: #569CD6",
205+
"light_plus": "meta.preprocessor: #0000FF",
206+
"dark_vs": "meta.preprocessor: #569CD6",
207+
"light_vs": "meta.preprocessor: #0000FF",
208+
"hc_black": "meta.preprocessor: #569CD6"
209+
}
210+
},
211+
{
212+
"c": "extern",
213+
"t": "source.cpp source.cpp meta.preprocessor.macro.cpp meta.block.extern.cpp meta.head.extern.cpp storage.type.extern.cpp",
214+
"r": {
215+
"dark_plus": "storage.type: #569CD6",
216+
"light_plus": "storage.type: #0000FF",
217+
"dark_vs": "storage.type: #569CD6",
218+
"light_vs": "storage.type: #0000FF",
219+
"hc_black": "storage.type: #569CD6"
220+
}
221+
},
222+
{
223+
"c": " ",
224+
"t": "source.cpp source.cpp meta.preprocessor.macro.cpp meta.block.extern.cpp meta.head.extern.cpp",
225+
"r": {
226+
"dark_plus": "meta.preprocessor: #569CD6",
227+
"light_plus": "meta.preprocessor: #0000FF",
228+
"dark_vs": "meta.preprocessor: #569CD6",
229+
"light_vs": "meta.preprocessor: #0000FF",
230+
"hc_black": "meta.preprocessor: #569CD6"
231+
}
232+
},
233+
{
234+
"c": "\"",
235+
"t": "source.cpp source.cpp meta.preprocessor.macro.cpp meta.block.extern.cpp meta.head.extern.cpp string.quoted.double.cpp punctuation.definition.string.begin.cpp",
236+
"r": {
237+
"dark_plus": "string: #CE9178",
238+
"light_plus": "string: #A31515",
239+
"dark_vs": "string: #CE9178",
240+
"light_vs": "string: #A31515",
241+
"hc_black": "string: #CE9178"
242+
}
243+
},
244+
{
245+
"c": "C",
246+
"t": "source.cpp source.cpp meta.preprocessor.macro.cpp meta.block.extern.cpp meta.head.extern.cpp string.quoted.double.cpp",
247+
"r": {
248+
"dark_plus": "string: #CE9178",
249+
"light_plus": "string: #A31515",
250+
"dark_vs": "string: #CE9178",
251+
"light_vs": "string: #A31515",
252+
"hc_black": "string: #CE9178"
253+
}
254+
},
255+
{
256+
"c": "\"",
257+
"t": "source.cpp source.cpp meta.preprocessor.macro.cpp meta.block.extern.cpp meta.head.extern.cpp string.quoted.double.cpp punctuation.definition.string.end.cpp",
258+
"r": {
259+
"dark_plus": "string: #CE9178",
260+
"light_plus": "string: #A31515",
261+
"dark_vs": "string: #CE9178",
262+
"light_vs": "string: #A31515",
263+
"hc_black": "string: #CE9178"
264+
}
265+
},
156266
{
157267
"c": "class",
158268
"t": "source.cpp source.cpp meta.block.class.cpp meta.head.class.cpp storage.type.class.cpp",

0 commit comments

Comments
 (0)