diff options
| author | Damian Tarnawski <gthetarnav@gmail.com> | 2024-09-25 14:15:47 +0200 |
|---|---|---|
| committer | Damian Tarnawski <gthetarnav@gmail.com> | 2024-09-25 14:15:47 +0200 |
| commit | d0f0f4d53559d8f7a2ccfa8108456b9a05ed417a (patch) | |
| tree | 089021995a4867e56834854a4318b8316fb19fdd /editors | |
| parent | 172c249a5819ccaecc574d7f625b6c698b04db73 (diff) | |
Add grammar for ternary exp and union member access
Diffstat (limited to 'editors')
| -rw-r--r-- | editors/vscode/syntaxes/odin.tmLanguage.json | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/editors/vscode/syntaxes/odin.tmLanguage.json b/editors/vscode/syntaxes/odin.tmLanguage.json index b1190a4..c47b964 100644 --- a/editors/vscode/syntaxes/odin.tmLanguage.json +++ b/editors/vscode/syntaxes/odin.tmLanguage.json @@ -79,6 +79,7 @@ "expressions": { "patterns": [ { "include": "#comments" }, + { "include": "#ternary" }, { "include": "#map-bitset" }, { "include": "#slice" }, { "include": "#keywords" }, @@ -86,6 +87,8 @@ { "include": "#basic-types" }, { "include": "#procedure-calls" }, { "include": "#property-access" }, + { "include": "#union-member-access" }, + { "include": "#union-non-nil-access" }, { "include": "#strings" }, { "include": "#punctuation" }, { "include": "#variable-name" } @@ -355,20 +358,51 @@ } ] }, + "ternary": { + "name": "meta.ternary.odin", + "begin": "\\?", + "beginCaptures": { "0": { "name": "keyword.operator.ternary.odin" } }, + "end": ":", + "endCaptures": { "0": { "name": "keyword.operator.ternary.odin" } }, + "patterns": [{ "include": "#expressions" }] + }, "slice": { "name": "meta.slice.odin", "begin": "\\[", "beginCaptures": { "0": { "name": "meta.brace.square.odin" } }, "end": "\\]", "endCaptures": { "0": { "name": "meta.brace.square.odin" } }, - "patterns": [ { "include": "#expressions" } ] + "patterns": [ + { "match": "\\?", "name": "keyword.operator.array.odin" }, + { "match": ":", "name": "keyword.operator.slice.odin" }, + { "include": "#expressions" } + ] }, "property-access": { + "match": "([A-Za-z_]\\w*)\\s*(\\.)\\s*(?=[A-Za-z_]\\w*)", "captures": { "1": { "name": "variable.other.object.odin" }, "2": { "name": "punctuation.accessor.odin" } + } + }, + "union-member-access": { + "begin": "([A-Za-z_]\\w*)\\s*(\\.)\\s*(\\()", + "beginCaptures": { + "1": { "name": "variable.other.object.odin" }, + "2": { "name": "punctuation.accessor.odin" }, + "3": { "name": "meta.brace.round.odin" } }, - "match": "([A-Za-z_]\\w*)\\s*(\\.)(?=\\s*[A-Za-z_]\\w*)" + "end": "\\)", + "endCaptures": {"0": { "name": "meta.brace.round.odin" }}, + "patterns": [{ "include": "#type-declaration" }] + }, + "union-non-nil-access": { + "match": "([A-Za-z_]\\w*)\\s*(\\.)\\s*(\\?)", + "captures": { + "1": { "name": "variable.other.object.odin" }, + "2": { "name": "punctuation.accessor.odin" }, + "3": { "name": "punctuation.accessor.optional.odin" } + } }, "comments": { "patterns": [ @@ -511,10 +545,6 @@ "name": "storage.type.function.arrow.odin" }, { - "name": "keyword.operator.ternary.odin", - "match": "\\?" - }, - { "name": "keyword.operator.odin", "match": "@|(\\||\\!|:|\\+|-|\\*|/|%|\\<\\<?|\\>\\>?|\\~)=?|=|: : ?|\\$" }, |