Skip to content

Commit 6367beb

Browse files
committed
Update c/c++ grammar (May27)
1 parent 99aa1bc commit 6367beb

4 files changed

Lines changed: 22 additions & 18 deletions

File tree

extensions/cpp/syntaxes/c++.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
"hxx",
1515
"h++",
1616
"inl",
17+
"ino",
1718
"ipp",
1819
"tcc",
1920
"tpp"
2021
],
21-
"firstLineMatch": "-\\*-\\s*([Mm]ode: )?C\\+\\+;?\\s*-\\*-",
22+
"firstLineMatch": "(?i)-\\*-[^*]*(Mode:\\s*)?C\\+\\+(\\s*;.*?)?\\s*-\\*-",
2223
"name": "C++",
2324
"patterns": [
2425
{
@@ -28,7 +29,7 @@
2829
"include": "source.c"
2930
},
3031
{
31-
"match": "\\b(friend|explicit|virtual)\\b",
32+
"match": "\\b(friend|explicit|virtual|override|final|noexcept)\\b",
3233
"name": "storage.modifier.cpp"
3334
},
3435
{
@@ -65,15 +66,15 @@
6566
"name": "keyword.operator.cast.cpp"
6667
},
6768
{
68-
"match": "\\b(and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq)\\b",
69+
"match": "\\b(and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq|alignof|alignas)\\b",
6970
"name": "keyword.operator.cpp"
7071
},
7172
{
72-
"match": "\\b(class|decltype|wchar_t)\\b",
73+
"match": "\\b(class|decltype|wchar_t|char16_t|char32_t)\\b",
7374
"name": "storage.type.cpp"
7475
},
7576
{
76-
"match": "\\b(constexpr|export|mutable|typename)\\b",
77+
"match": "\\b(constexpr|export|mutable|typename|thread_local)\\b",
7778
"name": "storage.modifier.cpp"
7879
},
7980
{

extensions/cpp/syntaxes/c.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"c",
55
"h"
66
],
7-
"firstLineMatch": "-\\*-\\s*([Mm]ode: )?C;?\\s*-\\*-",
7+
"firstLineMatch": "(?i)-\\*-[^*]*(Mode:\\s*)?C(\\s*;.*?)?\\s*-\\*-",
88
"name": "C",
99
"patterns": [
1010
{
@@ -58,7 +58,7 @@
5858
"include": "#strings"
5959
},
6060
{
61-
"begin": "(?x)\n^\\s* ((\\#)\\s*define) \\s+ # define\n((?<id>[a-zA-Z_][a-zA-Z0-9_]*)) # macro name\n(?:\n (\\()\n (\n \\s* \\g<id> \\s* # first argument\n ((,) \\s* \\g<id> \\s*)* # additional arguments\n (?:\\.\\.\\.)? # varargs ellipsis?\n )\n (\\))\n)?",
61+
"begin": "(?x)\n^\\s* ((\\#)\\s*define) \\s+ # define\n((?<id>[a-zA-Z_$][\\w$]*)) # macro name\n(?:\n (\\()\n (\n \\s* \\g<id> \\s* # first argument\n ((,) \\s* \\g<id> \\s*)* # additional arguments\n (?:\\.\\.\\.)? # varargs ellipsis?\n )\n (\\))\n)?",
6262
"beginCaptures": {
6363
"1": {
6464
"name": "keyword.control.directive.define.c"
@@ -258,7 +258,7 @@
258258
"include": "#parens"
259259
},
260260
{
261-
"match": "\\b(const|override|final|noexcept)\\b",
261+
"match": "\\b(const)\\b",
262262
"name": "storage.modifier.c"
263263
},
264264
{
@@ -273,14 +273,17 @@
273273
"repository": {
274274
"access": {
275275
"captures": {
276-
"1": {
277-
"name": "punctuation.separator.variable-access.c"
278-
},
279276
"2": {
280-
"name": "variable.other.dot-access.c"
277+
"name": "punctuation.separator.dot-access.c"
278+
},
279+
"3": {
280+
"name": "punctuation.separator.pointer-access.c"
281+
},
282+
"4": {
283+
"name": "variable.other.member.c"
281284
}
282285
},
283-
"match": "(\\.)([a-zA-Z_][a-zA-Z_0-9]*)\\b(?!\\s*\\()"
286+
"match": "((\\.)|(->))([a-zA-Z_][a-zA-Z_0-9]*)\\b(?!\\s*\\()"
284287
},
285288
"block": {
286289
"patterns": [
@@ -470,7 +473,7 @@
470473
"numbers": {
471474
"patterns": [
472475
{
473-
"match": "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b",
476+
"match": "\\b((0(x|X)[0-9a-fA-F]*)|(0(b|B)[01]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b",
474477
"name": "constant.numeric.c"
475478
}
476479
]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@
749749
},
750750
{
751751
"c": ".",
752-
"t": "block.c.function.meta.punctuation.separator.variable-access",
752+
"t": "block.c.dot-access.function.meta.punctuation.separator",
753753
"r": {
754754
"dark_plus": ".vs-dark .token rgb(212, 212, 212)",
755755
"light_plus": ".vs .token rgb(0, 0, 0)",
@@ -760,7 +760,7 @@
760760
},
761761
{
762762
"c": "x",
763-
"t": "block.c.dot-access.function.meta.other.variable",
763+
"t": "block.c.function.member.meta.other.variable",
764764
"r": {
765765
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.variable rgb(156, 220, 254)",
766766
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.variable rgb(0, 16, 128)",

extensions/objective-c/test/colorize-results/test_m.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,7 +2245,7 @@
22452245
},
22462246
{
22472247
"c": ".",
2248-
"t": "block.c.function-with-body.implementation.meta.objc.punctuation.scope.separator.variable-access",
2248+
"t": "block.c.dot-access.function-with-body.implementation.meta.objc.punctuation.scope.separator",
22492249
"r": {
22502250
"dark_plus": ".vs-dark .token rgb(212, 212, 212)",
22512251
"light_plus": ".vs .token rgb(0, 0, 0)",
@@ -2256,7 +2256,7 @@
22562256
},
22572257
{
22582258
"c": "gestureRecognizers",
2259-
"t": "block.c.dot-access.function-with-body.implementation.meta.objc.other.scope.variable",
2259+
"t": "block.c.function-with-body.implementation.member.meta.objc.other.scope.variable",
22602260
"r": {
22612261
"dark_plus": ".vs-dark.vscode-theme-defaults-themes-dark_plus-json .token.variable rgb(156, 220, 254)",
22622262
"light_plus": ".vs.vscode-theme-defaults-themes-light_plus-json .token.variable rgb(0, 16, 128)",

0 commit comments

Comments
 (0)