mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-15 20:18:12 +00:00
This is a re-do of #7888 Outside a call, the grammar scoped a name as a type or a variable by its capitalization. A theme could not distinguish a type from a value with the same spelling, or a parameter, a member, or an implemented interface from any other name. Pointer member access `->` was scoped as a result arrow, which scoped `Lookup` in `regions->Lookup(x)` as a type. `entity.name.type` now applies only in a type position (after `:`, `->`, `as`, `adapt`, or `require`, or in an `impl`) and to the name a nominal declaration declares. A qualifier, in a declared name like `fn N.Base(T: type).F()` or in a type, is `entity.name.scope-resolution` nested in `entity.name.type`. As in the parser, a name is a qualifier when its parameter lists are followed by `.`. Parameters, `let` bindings, choice alternatives, members, implemented interfaces, primitive types, `import`, and the strings naming a builtin or a library have their own scopes, and brackets use the C++ grammar's scopes. A `->` written directly after its operand is member access; no result arrow in the repository is written that way. The sample palette renders each scope that depends on context differently, and `tmlanguage.py` now supports nested captures. In 17 of the 19 themes measured, the VS Code built-ins plus One Dark Pro, Night Owl, Tokyo Night, and Nord, 13% to 27% of the characters in hand-written Carbon change color or style. A theme loses a color where `.` is now punctuation, where word operators like `as` are no longer control-flow keywords, or where a name outside a type position is no longer a type. Assisted-by: Claude Code
1060 lines
41 KiB
JSON
1060 lines
41 KiB
JSON
{
|
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
|
"uuid": "4568a54d-9a79-41ac-a36b-05916252763b",
|
|
"name": "carbon",
|
|
"scopeName": "source.carbon",
|
|
"foldingStartMarker": "\\{\\s*$",
|
|
"foldingStopMarker": "^\\s*\\}",
|
|
"fileTypes": ["carbon"],
|
|
"patterns": [
|
|
{ "include": "#comments" },
|
|
{ "include": "#cpp-inline" },
|
|
{ "include": "#strings" },
|
|
{ "include": "#builtin-functions" },
|
|
{ "include": "#choice-definitions" },
|
|
{ "include": "#declarations" },
|
|
{ "include": "#inheritance" },
|
|
{ "include": "#type-annotation" },
|
|
{ "include": "#keywords" },
|
|
{ "include": "#literals" },
|
|
{ "include": "#numbers" },
|
|
{ "include": "#operators" },
|
|
{ "include": "#identifiers" },
|
|
{ "include": "#punctuation" }
|
|
],
|
|
"repository": {
|
|
"comments": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Toolchain directives. The comment scope sits on a capture rather than on the rule, to leave the leading indentation outside it.",
|
|
"match": "^\\s*((//)(@(?:dump-sem-ir-(?:begin|end)|include-in-dumps)))$",
|
|
"captures": {
|
|
"1": { "name": "comment.line.double-slash.carbon" },
|
|
"2": { "name": "punctuation.definition.comment.carbon" },
|
|
"3": { "name": "keyword.other.directive.carbon" }
|
|
}
|
|
},
|
|
{
|
|
"name": "comment.line.double-slash.carbon",
|
|
"match": "(//).*$",
|
|
"captures": {
|
|
"1": { "name": "punctuation.definition.comment.carbon" }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"cpp-inline": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Inline C++, block form.",
|
|
"begin": "\\b(?:(import)\\s+(Cpp)\\s+(inline)|(inline)\\s+(Cpp))\\s*(''')([^\\s'\\\"#]*)(?:[ \\t]*((//)(?:[ \\t][^\\n]*)?)$)?",
|
|
"end": "(''')\\s*(;)?",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.control.import.carbon" },
|
|
"2": { "name": "support.class.carbon" },
|
|
"3": { "name": "storage.type.carbon" },
|
|
"4": { "name": "storage.type.carbon" },
|
|
"5": { "name": "support.class.carbon" },
|
|
"6": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"7": { "name": "entity.name.tag.language.carbon" },
|
|
"8": { "name": "comment.line.double-slash.carbon" },
|
|
"9": { "name": "punctuation.definition.comment.carbon" }
|
|
},
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.definition.string.end.carbon" },
|
|
"2": { "name": "punctuation.terminator.statement.carbon" }
|
|
},
|
|
"contentName": "meta.embedded.block.cpp",
|
|
"patterns": [{ "include": "source.cpp" }]
|
|
},
|
|
{
|
|
"comment": "Inline C++, single-line form.",
|
|
"begin": "\\b(?:(import)\\s+(Cpp)\\s+(inline)|(inline)\\s+(Cpp))\\s*(\")",
|
|
"end": "(\")\\s*(;)?",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.control.import.carbon" },
|
|
"2": { "name": "support.class.carbon" },
|
|
"3": { "name": "storage.type.carbon" },
|
|
"4": { "name": "storage.type.carbon" },
|
|
"5": { "name": "support.class.carbon" },
|
|
"6": { "name": "punctuation.definition.string.begin.carbon" }
|
|
},
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.definition.string.end.carbon" },
|
|
"2": { "name": "punctuation.terminator.statement.carbon" }
|
|
},
|
|
"contentName": "meta.embedded.inline.cpp",
|
|
"patterns": [{ "include": "source.cpp" }]
|
|
}
|
|
]
|
|
},
|
|
"strings": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Block string literal, with an optional file type indicator, raw at `###` level.",
|
|
"name": "string.quoted.triple.carbon",
|
|
"begin": "(#{3,})(''')([^\\s'\\\"#]*)(?:[ \\t]*((//)(?:[ \\t][^\\n]*)?)$)?",
|
|
"end": "(''')\\1",
|
|
"beginCaptures": {
|
|
"1": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"2": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"3": { "name": "entity.name.tag.language.carbon" },
|
|
"4": { "name": "comment.line.double-slash.carbon" },
|
|
"5": { "name": "punctuation.definition.comment.carbon" }
|
|
},
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.definition.string.end.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#string-escapes-raw" }]
|
|
},
|
|
{
|
|
"comment": "Block string literal, with an optional file type indicator, raw at `##` level.",
|
|
"name": "string.quoted.triple.carbon",
|
|
"begin": "(##)(''')([^\\s'\\\"#]*)(?:[ \\t]*((//)(?:[ \\t][^\\n]*)?)$)?",
|
|
"end": "('''##)",
|
|
"beginCaptures": {
|
|
"1": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"2": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"3": { "name": "entity.name.tag.language.carbon" },
|
|
"4": { "name": "comment.line.double-slash.carbon" },
|
|
"5": { "name": "punctuation.definition.comment.carbon" }
|
|
},
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.definition.string.end.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#string-escapes-2" }]
|
|
},
|
|
{
|
|
"comment": "Block string literal, with an optional file type indicator, raw at `#` level.",
|
|
"name": "string.quoted.triple.carbon",
|
|
"begin": "(#)(''')([^\\s'\\\"#]*)(?:[ \\t]*((//)(?:[ \\t][^\\n]*)?)$)?",
|
|
"end": "('''#)",
|
|
"beginCaptures": {
|
|
"1": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"2": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"3": { "name": "entity.name.tag.language.carbon" },
|
|
"4": { "name": "comment.line.double-slash.carbon" },
|
|
"5": { "name": "punctuation.definition.comment.carbon" }
|
|
},
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.definition.string.end.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#string-escapes-1" }]
|
|
},
|
|
{
|
|
"comment": "Block string literal, with an optional file type indicator.",
|
|
"name": "string.quoted.triple.carbon",
|
|
"begin": "(''')([^\\s'\\\"#]*)(?:[ \\t]*((//)(?:[ \\t][^\\n]*)?)$)?",
|
|
"end": "(''')",
|
|
"beginCaptures": {
|
|
"1": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"2": { "name": "entity.name.tag.language.carbon" },
|
|
"3": { "name": "comment.line.double-slash.carbon" },
|
|
"4": { "name": "punctuation.definition.comment.carbon" }
|
|
},
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.definition.string.end.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#string-escapes" }]
|
|
},
|
|
{
|
|
"comment": "A `\"\"\"` block is always an error, but highlighting it as a block string keeps the rest of the file readable.",
|
|
"name": "string.quoted.triple.carbon",
|
|
"begin": "(\"\"\")([^\\s'\\\"#]*)(?:[ \\t]*((//)(?:[ \\t][^\\n]*)?)$)?",
|
|
"end": "(\"\"\")",
|
|
"beginCaptures": {
|
|
"1": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"2": { "name": "entity.name.tag.language.carbon" },
|
|
"3": { "name": "comment.line.double-slash.carbon" },
|
|
"4": { "name": "punctuation.definition.comment.carbon" }
|
|
},
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.definition.string.end.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#string-escapes" }]
|
|
},
|
|
{
|
|
"comment": "Single-line string literal, raw at `###` level.",
|
|
"name": "string.quoted.double.carbon",
|
|
"begin": "(#{3,})(\")",
|
|
"end": "(\")\\1|$",
|
|
"beginCaptures": {
|
|
"1": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"2": { "name": "punctuation.definition.string.begin.carbon" }
|
|
},
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.definition.string.end.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#string-escapes-raw" }]
|
|
},
|
|
{
|
|
"comment": "Single-line string literal, raw at `##` level.",
|
|
"name": "string.quoted.double.carbon",
|
|
"begin": "(##)(\")",
|
|
"end": "(\"##)|$",
|
|
"beginCaptures": {
|
|
"1": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"2": { "name": "punctuation.definition.string.begin.carbon" }
|
|
},
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.definition.string.end.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#string-escapes-2" }]
|
|
},
|
|
{
|
|
"comment": "Single-line string literal, raw at `#` level.",
|
|
"name": "string.quoted.double.carbon",
|
|
"begin": "(#)(\")",
|
|
"end": "(\"#)|$",
|
|
"beginCaptures": {
|
|
"1": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"2": { "name": "punctuation.definition.string.begin.carbon" }
|
|
},
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.definition.string.end.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#string-escapes-1" }]
|
|
},
|
|
{
|
|
"comment": "Single-line string literal.",
|
|
"name": "string.quoted.double.carbon",
|
|
"begin": "(\")",
|
|
"end": "(\")|$",
|
|
"beginCaptures": {
|
|
"1": { "name": "punctuation.definition.string.begin.carbon" }
|
|
},
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.definition.string.end.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#string-escapes" }]
|
|
},
|
|
{
|
|
"comment": "Character literal.",
|
|
"name": "string.quoted.single.carbon",
|
|
"begin": "(')",
|
|
"end": "(')|$",
|
|
"beginCaptures": {
|
|
"1": { "name": "punctuation.definition.string.begin.carbon" }
|
|
},
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.definition.string.end.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#string-escapes" }]
|
|
}
|
|
]
|
|
},
|
|
"string-escapes": {
|
|
"patterns": [
|
|
{
|
|
"name": "constant.character.escape.carbon",
|
|
"match": "\\\\(?:[tnr0'\\\"\\\\]|x[0-9A-F]{2}|u\\{[0-9A-F]+\\})"
|
|
}
|
|
]
|
|
},
|
|
"string-escapes-1": {
|
|
"patterns": [
|
|
{
|
|
"name": "constant.character.escape.carbon",
|
|
"match": "\\\\#(?:[tnr0'\\\"\\\\]|x[0-9A-F]{2}|u\\{[0-9A-F]+\\})"
|
|
}
|
|
]
|
|
},
|
|
"string-escapes-2": {
|
|
"patterns": [
|
|
{
|
|
"name": "constant.character.escape.carbon",
|
|
"match": "\\\\##(?:[tnr0'\\\"\\\\]|x[0-9A-F]{2}|u\\{[0-9A-F]+\\})"
|
|
}
|
|
]
|
|
},
|
|
"string-escapes-raw": {
|
|
"patterns": [
|
|
{
|
|
"name": "constant.character.escape.carbon",
|
|
"match": "\\\\#{3,}(?:[tnr0'\\\"\\\\]|x[0-9A-F]{2}|u\\{[0-9A-F]+\\})"
|
|
}
|
|
]
|
|
},
|
|
"builtin-functions": {
|
|
"patterns": [
|
|
{
|
|
"comment": "A builtin function declaration (`fn ... = \"...\"`), scoping the string contents as `support.function.builtin`.",
|
|
"begin": "\\b(fn)\\b(?=[^\"/;]*=\\s*\")",
|
|
"beginCaptures": {
|
|
"1": { "name": "storage.type.carbon" }
|
|
},
|
|
"end": "(?=;)|$",
|
|
"patterns": [
|
|
{
|
|
"match": "(=)\\s*((\")([^\"\\\\\\n]*)(\"))",
|
|
"captures": {
|
|
"1": { "name": "keyword.operator.carbon" },
|
|
"2": { "name": "string.quoted.double.carbon" },
|
|
"3": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"4": { "name": "support.function.builtin.carbon" },
|
|
"5": { "name": "punctuation.definition.string.end.carbon" }
|
|
}
|
|
},
|
|
{ "include": "#declarations" },
|
|
{ "include": "#comments" },
|
|
{ "include": "#strings" },
|
|
{ "include": "#type-annotation" },
|
|
{ "include": "#keywords" },
|
|
{ "include": "#literals" },
|
|
{ "include": "#numbers" },
|
|
{ "include": "#operators" },
|
|
{ "include": "#identifiers" },
|
|
{ "include": "#punctuation" }
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"declarations": {
|
|
"patterns": [
|
|
{
|
|
"comment": "The name a function declaration declares, after any qualifiers, or the `destroy` keyword.",
|
|
"begin": "(?<=\\bfn)\\s+(?=(?:r#)?[A-Za-z_])",
|
|
"end": "(?:(destroy)|((?:r#)?[A-Za-z_][A-Za-z0-9_]*))\\b(?!\\s*(?:\\[[^\\[\\]]*\\]\\s*)?(?:\\([^()]*(?:\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*)?\\.)|(?=[^\\sA-Za-z_])|$",
|
|
"endCaptures": {
|
|
"1": { "name": "keyword.other.carbon" },
|
|
"2": { "name": "entity.name.function.definition.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#declared-name-qualifier" }]
|
|
},
|
|
{
|
|
"comment": "The name a class declaration declares, given `entity.name.type.class` for themes that color classes apart from other types.",
|
|
"begin": "(?<=\\bclass)\\s+(?=(?:r#)?[A-Za-z_])",
|
|
"end": "((?:r#)?[A-Za-z_][A-Za-z0-9_]*)\\b(?!\\s*(?:\\[[^\\[\\]]*\\]\\s*)?(?:\\([^()]*(?:\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*)?\\.)|(?=[^\\sA-Za-z_])|$",
|
|
"endCaptures": {
|
|
"1": { "name": "entity.name.type.class.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#declared-name-qualifier" }]
|
|
},
|
|
{
|
|
"comment": "The name the other nominal type declarations declare.",
|
|
"begin": "(?:(?<=\\balias)|(?<=\\bconstraint)|(?<=\\binterface))\\s+(?=(?:r#)?[A-Za-z_])",
|
|
"end": "((?:r#)?[A-Za-z_][A-Za-z0-9_]*)\\b(?!\\s*(?:\\[[^\\[\\]]*\\]\\s*)?(?:\\([^()]*(?:\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*)?\\.)|(?=[^\\sA-Za-z_])|$",
|
|
"endCaptures": {
|
|
"1": { "name": "entity.name.type.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#declared-name-qualifier" }]
|
|
},
|
|
{
|
|
"comment": "`let` and `var` bindings, with optional modifiers before the name. `_` and `self` are left to `#literals`.",
|
|
"match": "\\b(let)\\s+((?:(?:generic|ref|template|unused|var)\\s+)*)(?!_\\s*:)(r#)?([A-Za-z_][A-Za-z0-9_]*)(?=\\s*:(?![=!?]))",
|
|
"captures": {
|
|
"1": { "name": "storage.type.carbon" },
|
|
"2": { "name": "storage.modifier.carbon" },
|
|
"3": { "name": "punctuation.definition.raw-identifier.carbon" },
|
|
"4": { "name": "variable.other.constant.carbon" }
|
|
}
|
|
},
|
|
{
|
|
"match": "\\b(var)\\s+((?:(?:generic|ref|template|unused)\\s+)*)(?!(?:_|self)\\s*:)(r#)?([A-Za-z_][A-Za-z0-9_]*)(?=\\s*:(?![=!?]))",
|
|
"captures": {
|
|
"1": { "name": "storage.type.carbon" },
|
|
"2": { "name": "storage.modifier.carbon" },
|
|
"3": { "name": "punctuation.definition.raw-identifier.carbon" },
|
|
"4": { "name": "variable.other.carbon" }
|
|
}
|
|
},
|
|
{
|
|
"comment": "Package, namespace, and import names, excluding keywords (`library`, `inline`) and `Core` and `Cpp`.",
|
|
"match": "\\b(import)\\s+(?!(?:library|inline|Core|Cpp)\\b)((?:r#)?[A-Za-z_][A-Za-z0-9_]*)",
|
|
"captures": {
|
|
"1": { "name": "keyword.control.import.carbon" },
|
|
"2": { "name": "entity.name.namespace.carbon" }
|
|
}
|
|
},
|
|
{
|
|
"match": "\\b(package|namespace)\\s+(?!(?:library|Core|Cpp)\\b)((?:r#)?[A-Za-z_][A-Za-z0-9_]*)",
|
|
"captures": {
|
|
"1": { "name": "storage.type.carbon" },
|
|
"2": { "name": "entity.name.namespace.carbon" }
|
|
}
|
|
},
|
|
{
|
|
"comment": "A library name, written as a string, with `entity.name.namespace.library` nested inside the string scope.",
|
|
"match": "\\b(library)\\s+((\")((?:\\\\.|[^\"\\\\\\n])*)(\"))",
|
|
"captures": {
|
|
"1": { "name": "storage.type.carbon" },
|
|
"2": { "name": "string.quoted.double.carbon" },
|
|
"3": { "name": "punctuation.definition.string.begin.carbon" },
|
|
"4": { "name": "entity.name.namespace.library.carbon" },
|
|
"5": { "name": "punctuation.definition.string.end.carbon" }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"declared-name-qualifier": {
|
|
"patterns": [
|
|
{
|
|
"comment": "One qualifier on a declared name, such as `N.` or `Base(T: type).`, matched when followed by `.` after any parameter lists. `entity.name.scope-resolution` is nested inside `entity.name.type` so themes without a scope-resolution rule fall back to the type color.",
|
|
"begin": "(((?:r#)?[A-Za-z_][A-Za-z0-9_]*))\\b(?=\\s*(?:\\[[^\\[\\]]*\\]\\s*)?(?:\\([^()]*(?:\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*)?\\.)",
|
|
"beginCaptures": {
|
|
"1": { "name": "entity.name.type.carbon" },
|
|
"2": { "name": "entity.name.scope-resolution.carbon" }
|
|
},
|
|
"end": "(\\.)",
|
|
"endCaptures": {
|
|
"1": { "name": "punctuation.separator.dot-access.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#type-body" }]
|
|
}
|
|
]
|
|
},
|
|
"type-annotation": {
|
|
"patterns": [
|
|
{
|
|
"comment": "A type expression, from the token that introduces it to the first token that cannot continue one.",
|
|
"name": "meta.type.annotation.carbon",
|
|
"begin": "(:!)|(:\\?)|(:(?![=!?]))|((?<![A-Za-z0-9_)\\]}])\\->\\?)|((?<![A-Za-z0-9_)\\]}])\\->(?!\\?))|\\b(as)\\b|\\b(adapt)\\b|\\b(require)\\b",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.operator.type.annotation.symbolic.carbon" },
|
|
"2": { "name": "keyword.operator.type.annotation.form.carbon" },
|
|
"3": { "name": "keyword.operator.type.annotation.carbon" },
|
|
"4": { "name": "keyword.operator.function-result.form.carbon" },
|
|
"5": { "name": "keyword.operator.function-result.carbon" },
|
|
"6": { "name": "keyword.operator.expression.as.carbon" },
|
|
"7": { "name": "storage.type.carbon" },
|
|
"8": { "name": "storage.type.carbon" }
|
|
},
|
|
"end": "(?=[,;={}\\)\\]]|[-+/%!<>|^~?@\\\\]|//|\\b(?:in|and|or|not|as|impls)\\b|$)",
|
|
"patterns": [{ "include": "#type-body" }]
|
|
}
|
|
]
|
|
},
|
|
"type-body": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Argument and grouping parentheses, which nest rather than ending the type.",
|
|
"begin": "\\(",
|
|
"end": "(\\))|$",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.section.parens.begin.bracket.round.carbon"
|
|
}
|
|
},
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "punctuation.section.parens.end.bracket.round.carbon"
|
|
}
|
|
},
|
|
"patterns": [{ "include": "#type-body" }]
|
|
},
|
|
{
|
|
"begin": "\\[",
|
|
"end": "(\\])|$",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.section.brackets.begin.bracket.square.carbon"
|
|
}
|
|
},
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "punctuation.section.brackets.end.bracket.square.carbon"
|
|
}
|
|
},
|
|
"patterns": [{ "include": "#type-body" }]
|
|
},
|
|
{
|
|
"comment": "A `where` clause switches to expression scoping so `=` does not end the enclosing type as an initializer, and ends at a `)` or `]` it did not open.",
|
|
"begin": "\\bwhere\\b",
|
|
"beginCaptures": {
|
|
"0": { "name": "keyword.other.where.carbon" }
|
|
},
|
|
"end": "(?=[;{}\\)\\]]|$)",
|
|
"patterns": [
|
|
{ "include": "#expression-parens" },
|
|
{ "include": "$self" }
|
|
]
|
|
},
|
|
{ "include": "#impls-clause" },
|
|
{ "include": "#comments" },
|
|
{ "include": "#strings" },
|
|
{
|
|
"comment": "`typeof` takes an expression operand, switching out of `#type-body`.",
|
|
"begin": "\\b(typeof)\\s*(\\()",
|
|
"end": "(\\))|$",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.operator.expression.typeof.carbon" },
|
|
"2": {
|
|
"name": "punctuation.section.parens.begin.bracket.round.carbon"
|
|
}
|
|
},
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "punctuation.section.parens.end.bracket.round.carbon"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{ "include": "#expression-parens" },
|
|
{ "include": "$self" }
|
|
]
|
|
},
|
|
{ "include": "#keywords" },
|
|
{ "include": "#literals" },
|
|
{ "include": "#numbers" },
|
|
{
|
|
"comment": "Pointer `*`, written directly after the pointee type.",
|
|
"name": "keyword.operator.type.pointer.carbon",
|
|
"match": "(?<=[A-Za-z0-9_)\\]*])\\*(?!=)"
|
|
},
|
|
{ "include": "#operators" },
|
|
{ "include": "#bindings" },
|
|
{
|
|
"comment": "A qualifier in a type, which `#declared-name-qualifier` scopes the same way on a declared name.",
|
|
"name": "entity.name.type.carbon",
|
|
"match": "(?:(?<=[A-Za-z0-9_)\\]]\\.)|(?<!\\.))\\b((?:r#)?[A-Za-z_][A-Za-z0-9_]*)\\b(?=\\s*(?:\\[[^\\[\\]]*\\]\\s*)?(?:\\([^()]*(?:\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*)?\\.)",
|
|
"captures": {
|
|
"1": { "name": "entity.name.scope-resolution.carbon" }
|
|
}
|
|
},
|
|
{
|
|
"comment": "Unqualified names and qualified member names in a type context. A `.` with no preceding qualifier (such as a struct field `.x`) is left to `#identifiers`.",
|
|
"name": "entity.name.type.carbon",
|
|
"match": "(?:(?<=[A-Za-z0-9_)\\]]\\.)|(?<!\\.))\\b(r#)?[A-Za-z_][A-Za-z0-9_]*\\b",
|
|
"captures": {
|
|
"1": { "name": "punctuation.definition.raw-identifier.carbon" }
|
|
}
|
|
},
|
|
{ "include": "#identifiers" },
|
|
{ "include": "#punctuation" }
|
|
]
|
|
},
|
|
"inheritance": {
|
|
"patterns": [
|
|
{
|
|
"comment": "An `impl` declaration (when `impl` does not precede another declaration keyword), scoping the type before `as` with `#type-body` and the interface after `as` with `#inheritance-body`.",
|
|
"begin": "\\b(impl)\\b(?!\\s*(?:adapt|alias|base|choice|class|constraint|export|fn|impl|import|interface|let|library|match_first|namespace|observe|package|require|var)\\b)",
|
|
"beginCaptures": {
|
|
"1": { "name": "storage.type.carbon" }
|
|
},
|
|
"end": "(?=[;{]|$)",
|
|
"patterns": [
|
|
{
|
|
"name": "meta.inheritance-clause.carbon",
|
|
"begin": "\\b(as)\\b",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.operator.expression.as.carbon" }
|
|
},
|
|
"end": "(?=[,;={}\\)\\]]|[-+/%!<>|^~?@\\\\]|//|\\b(?:in|and|or|not|as|impls)\\b|$)",
|
|
"patterns": [{ "include": "#inheritance-body" }]
|
|
},
|
|
{ "include": "#type-body" }
|
|
],
|
|
"name": "meta.type.annotation.carbon"
|
|
},
|
|
{
|
|
"comment": "A `base:` declaration, excluding `.base` member access and `base class`.",
|
|
"name": "meta.inheritance-clause.carbon",
|
|
"begin": "(?<!\\.)\\b(base)\\s*(:)(?![=!?])",
|
|
"beginCaptures": {
|
|
"1": { "name": "storage.type.carbon" },
|
|
"2": { "name": "keyword.operator.type.annotation.carbon" }
|
|
},
|
|
"end": "(?=[,;={}\\)\\]]|[-+/%!<>|^~?@\\\\]|//|\\b(?:in|and|or|not|as|impls)\\b|$)",
|
|
"patterns": [{ "include": "#inheritance-body" }]
|
|
},
|
|
{ "include": "#impls-clause" }
|
|
]
|
|
},
|
|
"impls-clause": {
|
|
"patterns": [
|
|
{
|
|
"name": "meta.inheritance-clause.carbon",
|
|
"begin": "\\b(impls)\\b",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.operator.expression.impls.carbon" }
|
|
},
|
|
"end": "(?=[,;={}\\)\\]]|[-+/%!<>|^~?@\\\\]|//|\\b(?:in|and|or|not|as|impls)\\b|$)",
|
|
"patterns": [{ "include": "#inheritance-body" }]
|
|
}
|
|
]
|
|
},
|
|
"inheritance-body": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Only the interface itself is scoped as `entity.other.inherited-class`; its argument list switches to expression scoping.",
|
|
"begin": "(?<=[A-Za-z0-9_\\]])\\(",
|
|
"end": "(\\))|$",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.section.parens.begin.bracket.round.carbon"
|
|
}
|
|
},
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "punctuation.section.parens.end.bracket.round.carbon"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{ "include": "#expression-parens" },
|
|
{ "include": "$self" }
|
|
]
|
|
},
|
|
{
|
|
"comment": "Grouping parentheses around an interface name stay in `#inheritance-body`.",
|
|
"begin": "\\(",
|
|
"end": "(\\))|$",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.section.parens.begin.bracket.round.carbon"
|
|
}
|
|
},
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "punctuation.section.parens.end.bracket.round.carbon"
|
|
}
|
|
},
|
|
"patterns": [{ "include": "#inheritance-body" }]
|
|
},
|
|
{
|
|
"comment": "A `where` clause switches to expression scoping and ends at a `)` or `]` it did not open.",
|
|
"begin": "\\b(where)\\b",
|
|
"beginCaptures": {
|
|
"1": { "name": "keyword.other.where.carbon" }
|
|
},
|
|
"end": "(?=[;{}\\)\\]]|$)",
|
|
"patterns": [
|
|
{ "include": "#expression-parens" },
|
|
{ "include": "$self" }
|
|
]
|
|
},
|
|
{ "include": "#keywords" },
|
|
{ "include": "#literals" },
|
|
{
|
|
"comment": "The final identifier of the interface or base class name; any preceding qualifiers fall through to `#type-body`.",
|
|
"name": "entity.other.inherited-class.carbon",
|
|
"match": "\\b(?:r#)?[A-Za-z_][A-Za-z0-9_]*\\b(?!\\s*\\.)"
|
|
},
|
|
{ "include": "#type-body" }
|
|
]
|
|
},
|
|
"keywords": {
|
|
"patterns": [
|
|
{
|
|
"comment": "`.base` member access, matched before `base` as an introducer.",
|
|
"name": "keyword.other.base.carbon",
|
|
"match": "(?<=\\.)\\b(base)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.control.import.carbon",
|
|
"match": "\\b(import)\\b"
|
|
},
|
|
{
|
|
"name": "storage.type.carbon",
|
|
"match": "\\b(adapt|alias|choice|class|constraint|fn|inline|interface|let|library|match_first|namespace|observe|require|var)\\b"
|
|
},
|
|
{
|
|
"comment": "`base` as an introducer (not `base class`).",
|
|
"name": "storage.type.carbon",
|
|
"match": "\\b(base)\\b(?!\\s*class\\b)"
|
|
},
|
|
{
|
|
"name": "storage.type.carbon",
|
|
"match": "\\b(export)\\b(?!\\s*import\\b)"
|
|
},
|
|
{
|
|
"name": "storage.type.carbon",
|
|
"match": "\\b(impl)\\b(?!\\s*(adapt|alias|base|choice|class|constraint|export|fn|impl|import|interface|let|library|match_first|namespace|observe|package|require|var)\\b)"
|
|
},
|
|
{
|
|
"comment": "`package` as an introducer (not `package.`).",
|
|
"name": "storage.type.carbon",
|
|
"match": "\\b(package)\\b(?!\\.)"
|
|
},
|
|
{
|
|
"name": "storage.modifier.carbon",
|
|
"match": "\\b(abstract|const|eval|extend|extern|final|generic|musteval|override|partial|private|protected|ref|runtime|static|template|unsafe|unused|val|virtual)\\b"
|
|
},
|
|
{
|
|
"comment": "`default` as a modifier (not `default =>`).",
|
|
"name": "storage.modifier.carbon",
|
|
"match": "\\b(default)\\b(?!\\s*=>)"
|
|
},
|
|
{
|
|
"name": "storage.modifier.carbon",
|
|
"match": "\\b(base)\\b(?=\\s*class\\b)"
|
|
},
|
|
{
|
|
"name": "storage.modifier.carbon",
|
|
"match": "\\b(export)\\b(?=\\s*import\\b)"
|
|
},
|
|
{
|
|
"name": "storage.modifier.carbon",
|
|
"match": "\\b(impl)\\b(?=\\s*(adapt|alias|base|choice|class|constraint|export|fn|impl|import|interface|let|library|match_first|namespace|observe|package|require|var)\\b)"
|
|
},
|
|
{
|
|
"name": "keyword.control.carbon",
|
|
"match": "\\b(break|case|continue|else|for|if|match|return|returned|then|while)\\b"
|
|
},
|
|
{
|
|
"comment": "`default` in a `match` clause.",
|
|
"name": "keyword.control.carbon",
|
|
"match": "\\b(default)\\b(?=\\s*=>)"
|
|
},
|
|
{
|
|
"name": "keyword.control.carbon",
|
|
"match": "\\b(and|or)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.operator.expression.not.carbon",
|
|
"match": "\\b(not)\\b"
|
|
},
|
|
{
|
|
"comment": "Fallback when not matched by `#type-annotation` or `#inheritance`.",
|
|
"name": "keyword.operator.expression.as.carbon",
|
|
"match": "\\b(as)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.operator.expression.impls.carbon",
|
|
"match": "\\b(impls)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.operator.expression.in.carbon",
|
|
"match": "\\b(in)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.operator.expression.like.carbon",
|
|
"match": "\\b(like)\\b"
|
|
},
|
|
{
|
|
"name": "keyword.operator.expression.typeof.carbon",
|
|
"match": "\\b(typeof)\\b"
|
|
},
|
|
{ "name": "keyword.other.where.carbon", "match": "\\b(where)\\b" },
|
|
{
|
|
"name": "keyword.other.carbon",
|
|
"match": "\\b(destroy|each|expand|forall|form|friend)\\b"
|
|
}
|
|
]
|
|
},
|
|
"literals": {
|
|
"patterns": [
|
|
{ "name": "variable.language.carbon", "match": "\\b(self|Self)\\b" },
|
|
{
|
|
"comment": "The wildcard pattern.",
|
|
"name": "variable.language.carbon",
|
|
"match": "\\b(_)\\b"
|
|
},
|
|
{
|
|
"comment": "Built-in package names.",
|
|
"name": "support.class.carbon",
|
|
"match": "\\b(Core|Cpp)\\b"
|
|
},
|
|
{
|
|
"comment": "`package` as a qualifier.",
|
|
"name": "variable.language.carbon",
|
|
"match": "\\b(package)\\b(?=\\.)"
|
|
},
|
|
{ "name": "constant.language.carbon", "match": "\\b(true|false)\\b" },
|
|
{
|
|
"name": "support.type.builtin.carbon",
|
|
"match": "\\b(array|auto|type)\\b"
|
|
},
|
|
{
|
|
"name": "support.type.primitive.carbon",
|
|
"match": "\\b(bool|char|str)\\b"
|
|
},
|
|
{
|
|
"comment": "Integer and floating-point type literals.",
|
|
"name": "support.type.primitive.carbon",
|
|
"match": "\\b[iuf][1-9][0-9]*\\b"
|
|
}
|
|
]
|
|
},
|
|
"numbers": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Each numeric rule matches a full alphanumeric word starting with a digit so a malformed suffix is not split into an identifier. Real literals exclude a leading `.` or `->` so tuple access like `t.0.1` is not matched as a real.",
|
|
"name": "constant.numeric.hex.carbon",
|
|
"match": "(?<!\\.)(?<!->)\\b(0x)[_0-9A-Za-z]*\\.[0-9A-Za-z][_0-9A-Za-z]*(?:(?<=[a-z])[-+][0-9A-Za-z][_0-9A-Za-z]*)?",
|
|
"captures": {
|
|
"1": { "name": "keyword.other.unit.hexadecimal.carbon" }
|
|
}
|
|
},
|
|
{
|
|
"name": "constant.numeric.hex.carbon",
|
|
"match": "\\b(0x)[_0-9A-Za-z]*",
|
|
"captures": {
|
|
"1": { "name": "keyword.other.unit.hexadecimal.carbon" }
|
|
}
|
|
},
|
|
{
|
|
"name": "constant.numeric.octal.carbon",
|
|
"match": "\\b(0o)[_0-9A-Za-z]*",
|
|
"captures": {
|
|
"1": { "name": "keyword.other.unit.octal.carbon" }
|
|
}
|
|
},
|
|
{
|
|
"name": "constant.numeric.binary.carbon",
|
|
"match": "\\b(0b)[_0-9A-Za-z]*",
|
|
"captures": {
|
|
"1": { "name": "keyword.other.unit.binary.carbon" }
|
|
}
|
|
},
|
|
{
|
|
"name": "constant.numeric.decimal.carbon",
|
|
"match": "(?<!\\.)(?<!->)\\b[0-9][_0-9A-Za-z]*\\.[0-9A-Za-z][_0-9A-Za-z]*(?:(?<=[a-z])[-+][0-9A-Za-z][_0-9A-Za-z]*)?"
|
|
},
|
|
{
|
|
"name": "constant.numeric.decimal.carbon",
|
|
"match": "\\b[0-9][_0-9A-Za-z]*"
|
|
},
|
|
{
|
|
"comment": "Positional parameter, as used in lambdas.",
|
|
"name": "variable.parameter.carbon",
|
|
"match": "\\$[0-9]+"
|
|
}
|
|
]
|
|
},
|
|
"operators": {
|
|
"patterns": [
|
|
{
|
|
"name": "keyword.operator.type.annotation.symbolic.carbon",
|
|
"match": ":!"
|
|
},
|
|
{
|
|
"name": "keyword.operator.type.annotation.form.carbon",
|
|
"match": ":\\?"
|
|
},
|
|
{
|
|
"name": "keyword.operator.type.annotation.carbon",
|
|
"match": ":(?![=!?])"
|
|
},
|
|
{
|
|
"comment": "`->` directly after an operand is pointer member access rather than a return type arrow.",
|
|
"name": "punctuation.separator.pointer-access.carbon",
|
|
"match": "(?<=[A-Za-z0-9_)\\]}])\\->(?!\\?)"
|
|
},
|
|
{
|
|
"name": "keyword.operator.function-result.form.carbon",
|
|
"match": "\\->\\?"
|
|
},
|
|
{
|
|
"name": "keyword.operator.function-result.carbon",
|
|
"match": "\\->(?!\\?)"
|
|
},
|
|
{ "name": "keyword.operator.arrow.fat.carbon", "match": "=>" },
|
|
{
|
|
"name": "keyword.operator.carbon",
|
|
"match": "<=>|<<=|>>=|==|!=|<=|>=|<<|>>|\\+\\+|--|\\+=|-=|\\*=|/=|%=|&=|\\|=|\\^=|~=|:=|<-|<>|[-+*/%&|^~!<>=@?\\\\]"
|
|
}
|
|
]
|
|
},
|
|
"identifiers": {
|
|
"patterns": [
|
|
{ "include": "#bindings" },
|
|
{
|
|
"comment": "Raw identifiers.",
|
|
"name": "variable.other.carbon",
|
|
"match": "\\b(r#)([A-Za-z_][A-Za-z0-9_]*)",
|
|
"captures": {
|
|
"1": { "name": "punctuation.definition.raw-identifier.carbon" }
|
|
}
|
|
},
|
|
{
|
|
"comment": "Member function call.",
|
|
"name": "entity.name.function.member.carbon",
|
|
"match": "(?:(?<=\\.)|(?<=\\->))[A-Za-z_][A-Za-z0-9_]*(?=\\s*\\()"
|
|
},
|
|
{
|
|
"comment": "Member access via `.` or `->`.",
|
|
"name": "variable.other.property.carbon",
|
|
"match": "(?:(?<=\\.)|(?<=\\->))[A-Za-z_][A-Za-z0-9_]*\\b"
|
|
},
|
|
{
|
|
"comment": "Function call.",
|
|
"name": "entity.name.function.call.carbon",
|
|
"match": "\\b[A-Za-z_][A-Za-z0-9_]*(?=\\s*\\()"
|
|
},
|
|
{
|
|
"name": "variable.other.carbon",
|
|
"match": "\\b[A-Za-z_][A-Za-z0-9_]*\\b"
|
|
}
|
|
]
|
|
},
|
|
"punctuation": {
|
|
"patterns": [
|
|
{
|
|
"name": "punctuation.section.parens.begin.bracket.round.carbon",
|
|
"match": "\\("
|
|
},
|
|
{
|
|
"name": "punctuation.section.parens.end.bracket.round.carbon",
|
|
"match": "\\)"
|
|
},
|
|
{
|
|
"name": "punctuation.section.block.begin.bracket.curly.carbon",
|
|
"match": "\\{"
|
|
},
|
|
{
|
|
"name": "punctuation.section.block.end.bracket.curly.carbon",
|
|
"match": "\\}"
|
|
},
|
|
{
|
|
"name": "punctuation.section.brackets.begin.bracket.square.carbon",
|
|
"match": "\\["
|
|
},
|
|
{
|
|
"name": "punctuation.section.brackets.end.bracket.square.carbon",
|
|
"match": "\\]"
|
|
},
|
|
{ "name": "punctuation.separator.dot-access.carbon", "match": "\\." },
|
|
{ "name": "punctuation.separator.comma.carbon", "match": "," },
|
|
{ "name": "punctuation.terminator.statement.carbon", "match": ";" }
|
|
]
|
|
},
|
|
"choice-definitions": {
|
|
"patterns": [
|
|
{
|
|
"comment": "A `choice` declaration, scoping names in its body as enum members and closing immediately if there is no body.",
|
|
"begin": "\\b(choice)\\b",
|
|
"beginCaptures": {
|
|
"1": { "name": "storage.type.carbon" }
|
|
},
|
|
"end": "(?<=\\})|(?=[^\\s({])",
|
|
"patterns": [
|
|
{
|
|
"begin": "(?<=\\bchoice)\\s+(?=(?:r#)?[A-Za-z_])",
|
|
"end": "((?:r#)?[A-Za-z_][A-Za-z0-9_]*)\\b(?!\\s*(?:\\[[^\\[\\]]*\\]\\s*)?(?:\\([^()]*(?:\\([^()]*(?:\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*)?\\.)|(?=[^\\sA-Za-z_])|$",
|
|
"endCaptures": {
|
|
"1": { "name": "entity.name.type.carbon" }
|
|
},
|
|
"patterns": [{ "include": "#declared-name-qualifier" }]
|
|
},
|
|
{ "include": "#comments" },
|
|
{
|
|
"comment": "Choice parameters.",
|
|
"begin": "\\(",
|
|
"end": "(\\))|$",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.section.parens.begin.bracket.round.carbon"
|
|
}
|
|
},
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "punctuation.section.parens.end.bracket.round.carbon"
|
|
}
|
|
},
|
|
"patterns": [{ "include": "#choice-parameters" }]
|
|
},
|
|
{
|
|
"comment": "Choice body.",
|
|
"begin": "\\{",
|
|
"end": "(\\})|(?=[;=])",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.section.block.begin.bracket.curly.carbon"
|
|
}
|
|
},
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "punctuation.section.block.end.bracket.curly.carbon"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{ "include": "#comments" },
|
|
{
|
|
"comment": "Alternative parameters.",
|
|
"begin": "\\(",
|
|
"end": "(\\))|$",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.section.parens.begin.bracket.round.carbon"
|
|
}
|
|
},
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "punctuation.section.parens.end.bracket.round.carbon"
|
|
}
|
|
},
|
|
"patterns": [{ "include": "#choice-parameters" }]
|
|
},
|
|
{
|
|
"comment": "Invalid implicit parameter list on an alternative, matched so its contents are not scoped as enum members.",
|
|
"begin": "\\[",
|
|
"end": "(\\])|$",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.section.brackets.begin.bracket.square.carbon"
|
|
}
|
|
},
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "punctuation.section.brackets.end.bracket.square.carbon"
|
|
}
|
|
},
|
|
"patterns": [{ "include": "#choice-parameters" }]
|
|
},
|
|
{ "include": "#keywords" },
|
|
{ "include": "#literals" },
|
|
{
|
|
"name": "variable.other.enummember.carbon",
|
|
"match": "\\b(?:r#)?[A-Za-z_][A-Za-z0-9_]*\\b"
|
|
},
|
|
{ "include": "#numbers" },
|
|
{ "include": "#operators" },
|
|
{ "include": "#punctuation" }
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"choice-parameters": {
|
|
"patterns": [
|
|
{ "include": "#comments" },
|
|
{ "include": "#strings" },
|
|
{ "include": "#inheritance" },
|
|
{ "include": "#type-annotation" },
|
|
{ "include": "#keywords" },
|
|
{ "include": "#literals" },
|
|
{ "include": "#numbers" },
|
|
{ "include": "#operators" },
|
|
{ "include": "#identifiers" },
|
|
{ "include": "#punctuation" }
|
|
]
|
|
},
|
|
"bindings": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Parameter bindings (`name: Type` when not preceded by `let` or `var`), with `variable.parameter` nested inside `variable.other`.",
|
|
"name": "variable.other.carbon",
|
|
"match": "(?<!\\.)(?<!->)\\b(r#)?([A-Za-z_][A-Za-z0-9_]*)(?=\\s*:(?![=!?]))",
|
|
"captures": {
|
|
"1": { "name": "punctuation.definition.raw-identifier.carbon" },
|
|
"2": { "name": "variable.parameter.carbon" }
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"expression-parens": {
|
|
"patterns": [
|
|
{
|
|
"comment": "Parentheses nested in an expression that sits inside a type, so that only the matching `)` ends the expression.",
|
|
"begin": "\\(",
|
|
"end": "(\\))|$",
|
|
"beginCaptures": {
|
|
"0": {
|
|
"name": "punctuation.section.parens.begin.bracket.round.carbon"
|
|
}
|
|
},
|
|
"endCaptures": {
|
|
"1": {
|
|
"name": "punctuation.section.parens.end.bracket.round.carbon"
|
|
}
|
|
},
|
|
"patterns": [
|
|
{ "include": "#expression-parens" },
|
|
{ "include": "$self" }
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|