|
|
@@ -13,13 +13,19 @@
|
|
|
"include": "#strings"
|
|
|
},
|
|
|
{
|
|
|
- "include": "#operators"
|
|
|
+ "include": "#types"
|
|
|
},
|
|
|
{
|
|
|
- "include": "#special-keywords"
|
|
|
+ "include": "#functions"
|
|
|
},
|
|
|
{
|
|
|
- "include": "#numbers"
|
|
|
+ "include": "#variables"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "include": "#operators"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "include": "#special-keywords"
|
|
|
},
|
|
|
{
|
|
|
"include": "#introducer-keywords"
|
|
|
@@ -43,7 +49,10 @@
|
|
|
"include": "#type-literals"
|
|
|
},
|
|
|
{
|
|
|
- "include": "#functions"
|
|
|
+ "include": "#numbers"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "include": "#parameter-bindings"
|
|
|
},
|
|
|
{
|
|
|
"include": "#customs"
|
|
|
@@ -103,15 +112,149 @@
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
+ "types": {
|
|
|
+ "name": "meta.type.carbon",
|
|
|
+ "patterns": [
|
|
|
+ {
|
|
|
+ "comment": "Matches type, constraint, and implementation declarations, and explicit casts.",
|
|
|
+ "begin": "\\b((adapt|alias|class|constraint|interface|impl)|(as|impls))\\b",
|
|
|
+ "beginCaptures": {
|
|
|
+ "2": { "name": "storage.type.carbon" },
|
|
|
+ "3": { "name": "keyword.control.carbon" }
|
|
|
+ },
|
|
|
+ "end": "(?=[;{])",
|
|
|
+ "patterns": [
|
|
|
+ { "include": "#common" },
|
|
|
+ { "include": "#parameter-bindings" },
|
|
|
+ {
|
|
|
+ "name": "support.type.carbon",
|
|
|
+ "match": "\\w+"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "comment": "Matches types in bindings.",
|
|
|
+ "begin": ":!?",
|
|
|
+ "end": "(?=([;{=]|->|in|where))",
|
|
|
+ "patterns": [
|
|
|
+ { "include": "#common" },
|
|
|
+ { "include": "#variables" },
|
|
|
+ { "include": "#parameter-bindings" },
|
|
|
+ {
|
|
|
+ "name": "support.type.carbon",
|
|
|
+ "match": "\\w+"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "comment": "Matches function return types.",
|
|
|
+ "begin": "->",
|
|
|
+ "end": "(?=([;{]|=>))",
|
|
|
+ "patterns": [
|
|
|
+ { "include": "#common" },
|
|
|
+ {
|
|
|
+ "name": "support.type.carbon",
|
|
|
+ "match": "\\w+"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "comment": "Matches types in where clause.",
|
|
|
+ "begin": "\\bwhere\\b",
|
|
|
+ "beginCaptures": {
|
|
|
+ "0": { "name": "keyword.control.carbon" }
|
|
|
+ },
|
|
|
+ "end": "(?=[;{])",
|
|
|
+ "patterns": [
|
|
|
+ { "include": "#common" },
|
|
|
+ { "include": "#variables" },
|
|
|
+ { "include": "#parameter-bindings" },
|
|
|
+ {
|
|
|
+ "name": "support.type.carbon",
|
|
|
+ "match": "\\w+"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "comment": "Matches choices.",
|
|
|
+ "begin": "\\bchoice\\b",
|
|
|
+ "beginCaptures": {
|
|
|
+ "0": { "name": "storage.type.carbon" }
|
|
|
+ },
|
|
|
+ "end": "(?=[;}])",
|
|
|
+ "patterns": [
|
|
|
+ { "include": "#common" },
|
|
|
+ { "include": "#variables" },
|
|
|
+ { "include": "#parameter-bindings" },
|
|
|
+ {
|
|
|
+ "name": "support.type.carbon",
|
|
|
+ "match": "\\w+"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "comment": "Matches the choice values.",
|
|
|
+ "begin": "\\{",
|
|
|
+ "end": "(?=})",
|
|
|
+ "patterns": [
|
|
|
+ { "include": "#common" },
|
|
|
+ {
|
|
|
+ "name": "variable.other.enummember.carbon",
|
|
|
+ "match": "\\w+"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "functions": {
|
|
|
+ "name": "meta.function.carbon",
|
|
|
+ "patterns": [
|
|
|
+ {
|
|
|
+ "comment": "Matches function declarations.",
|
|
|
+ "begin": "\\bfn\\b",
|
|
|
+ "beginCaptures": {
|
|
|
+ "0": { "name": "storage.type.carbon" }
|
|
|
+ },
|
|
|
+ "end": "(?=[\\[\\(])",
|
|
|
+ "patterns": [
|
|
|
+ { "include": "#common" },
|
|
|
+ {
|
|
|
+ "name": "support.function.carbon",
|
|
|
+ "match": "\\w+"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "variables": {
|
|
|
+ "name": "meta.variable.carbon",
|
|
|
+ "patterns": [
|
|
|
+ {
|
|
|
+ "comment": "Matches variable declarations.",
|
|
|
+ "begin": "\\b(var|let)\\b",
|
|
|
+ "beginCaptures": {
|
|
|
+ "0": { "name": "storage.type.carbon" }
|
|
|
+ },
|
|
|
+ "end": "(?=:)",
|
|
|
+ "patterns": [
|
|
|
+ { "include": "#common" },
|
|
|
+ {
|
|
|
+ "name": "support.variable.carbon",
|
|
|
+ "match": "\\w+"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
"operators": {
|
|
|
"patterns": [
|
|
|
{
|
|
|
"name": "keyword.operator.carbon",
|
|
|
- "match": "\\b(>>=|<=>|<<=|\\&=|==|!=|>=|>>|<=|<<|-=|->|--|%=|\\|=|\\+=|\\+\\+|/=|\\*=|\\&|\\^|=|>|<|-|%|.|\\||\\+|/|\\*)\\b"
|
|
|
+ "match": "\\b(>>=|<=>|<<=|\\&=|==|!=|>=|>>|<=|<<|-=|->|--|%=|\\|=|\\+=|\\+\\+|/=|\\*=|\\&|\\^|=|>|<|-|%|\\.|\\||\\+|/|\\*)\\b"
|
|
|
},
|
|
|
{
|
|
|
- "name": "keyword.operator.carbon",
|
|
|
- "match": "\\b(addr|and|as|impls|in|like|not|or|partial|template|where)\\b"
|
|
|
+ "name": "keyword.control.carbon",
|
|
|
+ "match": "\\b(and|as|impls|in|like|not|or|partial|ref|template|where)\\b"
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
@@ -155,7 +298,7 @@
|
|
|
"patterns": [
|
|
|
{
|
|
|
"name": "storage.modifier.carbon",
|
|
|
- "match": "\\b(abstract|extend|extern|final|private|protected|virtual)\\b"
|
|
|
+ "match": "\\b(abstract|const|extend|extern|final|private|protected|virtual)\\b"
|
|
|
},
|
|
|
{
|
|
|
"name": "storage.modifier.carbon",
|
|
|
@@ -215,76 +358,84 @@
|
|
|
"patterns": [
|
|
|
{
|
|
|
"name": "constant.language.carbon",
|
|
|
- "match": "\\b(bool|[iuf][1-9][0-9]*|type)\\b"
|
|
|
+ "match": "\\b(array|bool|char|str|type)\\b"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "constant.language.carbon",
|
|
|
+ "comment": "Match common numeric type literals. Language server should highlight other valid literals.",
|
|
|
+ "match": "\\b[iuf](8|16|32|64|128)\\b"
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
- "functions": {
|
|
|
+ "numbers": {
|
|
|
+ "comment": "Invalid formats are also highlighted. Language server handles error highlighting",
|
|
|
"patterns": [
|
|
|
{
|
|
|
- "name": "support.function.carbon",
|
|
|
- "match": "\\b[a-zA-Z]+\\s*\\("
|
|
|
+ "name": "constant.numeric.carbon",
|
|
|
+ "match": "0x[_0-9a-fA-F]*(\\.[_0-9a-fA-F]+(p[-+]?[0-9]+)?)?"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "constant.numeric.carbon",
|
|
|
+ "match": "0b[_01]*"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ "name": "constant.numeric.carbon",
|
|
|
+ "match": "[0-9][_0-9]*(\\.[_0-9]+(e[-+]?[0-9]+)?)?"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "parameter-bindings": {
|
|
|
+ "patterns": [
|
|
|
+ {
|
|
|
+ "comment": "Matches parameter bindings.",
|
|
|
+ "match": "\\b(\\w+)\\s*(?=:)",
|
|
|
+ "captures": {
|
|
|
+ "1": { "name": "support.variable.carbon" }
|
|
|
+ }
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
"customs": {
|
|
|
+ "comment": "For rules that should be checked last.",
|
|
|
"patterns": [
|
|
|
{
|
|
|
"name": "support.class.carbon",
|
|
|
"match": "(?<=\\b(package|Core)\\s)\\w+"
|
|
|
},
|
|
|
{
|
|
|
- "name": "support.variable.carbon",
|
|
|
- "match": "(?<=\\s*\\.)\\w+"
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "support.variable.carbon",
|
|
|
- "match": "(?<=\\bas\\s)\\w+"
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "support.variable.carbon",
|
|
|
- "match": "\\w+(?=\\s*:)"
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "support.variable.carbon",
|
|
|
- "match": "(?<=\\blet\\s)\\w+"
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "support.variable.carbon",
|
|
|
- "match": "(?<=\\bvar\\s)\\w+"
|
|
|
+ "name": "support.type.property-name.carbon",
|
|
|
+ "match": "(?<=\\bimport\\s)\\w+"
|
|
|
},
|
|
|
{
|
|
|
+ "comment": "Matches function calls.",
|
|
|
"name": "support.function.carbon",
|
|
|
- "match": "(?<=\\bfn\\s)\\w+"
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "support.other.carbon",
|
|
|
- "match": "(?<=\\bimpl\\s)\\w+"
|
|
|
+ "match": "\\b\\w+\\s*\\("
|
|
|
},
|
|
|
{
|
|
|
- "name": "support.type.property-name.carbon",
|
|
|
- "match": "(?<=\\bimport\\s)\\w+"
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "support.class.carbon",
|
|
|
- "match": "(?<=\\bclass\\s)\\w+"
|
|
|
+ "comment": "Matches unidentified words as variables.",
|
|
|
+ "name": "support.variable.carbon",
|
|
|
+ "match": "\\b\\w+\\b"
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
- "numbers": {
|
|
|
+ "common": {
|
|
|
+ "comments": [
|
|
|
+ "For including comments, operators, keywords, literals, and language constants ",
|
|
|
+ "in other rules that use begin/end. This way we do not accidentally override their ",
|
|
|
+ "highlighting in complex rules."
|
|
|
+ ],
|
|
|
"patterns": [
|
|
|
- {
|
|
|
- "name": "constant.numeric.carbon",
|
|
|
- "match": "0x[_0-9A-F]+(\\.[_0-9A-F]+(p[-+]?[1-9][0-9]*)?)?"
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "constant.numeric.carbon",
|
|
|
- "match": "0b[_01]+"
|
|
|
- },
|
|
|
- {
|
|
|
- "name": "constant.numeric.carbon",
|
|
|
- "match": "[1-9][_0-9]*(\\.[_0-9]+(e[-+]?[1-9][0-9]*)?)?"
|
|
|
- }
|
|
|
+ { "include": "#comments" },
|
|
|
+ { "include": "#strings" },
|
|
|
+ { "include": "#operators" },
|
|
|
+ { "include": "#special-keywords" },
|
|
|
+ { "include": "#introducer-keywords" },
|
|
|
+ { "include": "#modifier-keywords" },
|
|
|
+ { "include": "#misc-keywords" },
|
|
|
+ { "include": "#self-keywords" },
|
|
|
+ { "include": "#true-false" },
|
|
|
+ { "include": "#type-literals" },
|
|
|
+ { "include": "#numbers" }
|
|
|
]
|
|
|
}
|
|
|
}
|