UNPKG

tm-grammars

Version:
1,167 lines (1,166 loc) 27.9 kB
{ "displayName": "Odin", "name": "odin", "patterns": [ { "include": "#file-tags" }, { "include": "#package-name-declaration" }, { "include": "#import-declaration" }, { "include": "#statements" } ], "repository": { "assignments": { "patterns": [ { "include": "#procedure-assignment" }, { "include": "#type-assignment" }, { "include": "#distinct-type-assignment" }, { "include": "#constant-assignment" }, { "include": "#variable-assignment" }, { "include": "#type-annotation" } ] }, "attribute": { "patterns": [ { "captures": { "1": { "name": "keyword.control.attribute.odin" }, "2": { "name": "entity.other.attribute-name.odin" } }, "match": "(@)\\s*([A-Z_a-z]\\w*)\\b", "name": "meta.attribute.odin" }, { "begin": "(@)\\s*(\\()", "beginCaptures": { "1": { "name": "keyword.control.attribute.odin" }, "2": { "name": "meta.brace.round.odin" } }, "end": "\\)", "endCaptures": { "0": { "name": "meta.brace.round.odin" } }, "name": "meta.attribute.odin", "patterns": [ { "match": "\\b([A-Z_a-z]\\w*)\\b", "name": "entity.other.attribute-name.odin" }, { "match": ",", "name": "punctuation.odin" }, { "begin": "=", "beginCaptures": { "0": { "name": "keyword.operator.assignment.odin" } }, "end": "(?=[),])", "patterns": [ { "include": "#expressions" } ] } ] } ] }, "basic-types": { "patterns": [ { "match": "\\b(i(?:8|16|32|64|128|nt))\\b", "name": "support.type.primitive.odin" }, { "match": "\\b(u(?:8|16|32|64|128|int|intptr))\\b", "name": "support.type.primitive.odin" }, { "match": "\\b((?:u16|u32|u64|u128|i16|i32|i64|i128)le)\\b", "name": "support.type.primitive.odin" }, { "match": "\\b((?:i16|i32|i64|i128|u16|u32|u64|u128)be)\\b", "name": "support.type.primitive.odin" }, { "match": "\\b(f(?:16|32|64))\\b", "name": "support.type.primitive.odin" }, { "match": "\\b(f(?:16|32|64)le)\\b", "name": "support.type.primitive.odin" }, { "match": "\\b(f(?:16|32|64)be)\\b", "name": "support.type.primitive.odin" }, { "match": "\\b(complex(?:32|64|128))\\b", "name": "support.type.primitive.odin" }, { "match": "\\b(quaternion(?:64|128|256))\\b", "name": "support.type.primitive.odin" }, { "match": "\\b(b(?:ool|8|16|32|64))\\b", "name": "support.type.primitive.odin" }, { "match": "\\b(string|cstring|rune)\\b", "name": "support.type.primitive.odin" }, { "match": "\\b(rawptr)\\b", "name": "support.type.primitive.odin" }, { "match": "\\b(any|typeid)\\b", "name": "support.type.primitive.odin" }, { "match": "\\b(byte)\\b", "name": "support.type.primitive.odin" } ] }, "block-comment": { "begin": "/\\*", "beginCaptures": { "0": { "name": "punctuation.definition.comment.begin.odin" } }, "end": "\\*/", "endCaptures": { "0": { "name": "punctuation.definition.comment.end.odin" } }, "name": "comment.block.odin", "patterns": [ { "include": "#block-comment" } ] }, "block-definition": { "begin": "\\{", "beginCaptures": { "0": { "name": "punctuation.definition.block.odin" } }, "end": "}", "endCaptures": { "0": { "name": "punctuation.definition.block.odin" } }, "name": "meta.block.odin", "patterns": [ { "include": "#statements" } ] }, "block-label": { "captures": { "1": { "name": "entity.name.label.odin" }, "2": { "name": "punctuation.definition.label.odin" } }, "match": "(\\w+)(:)\\s*(?=for|switch|if|\\{)", "name": "meta.block.label.odin" }, "case-clause": { "begin": "\\b(case)\\b", "beginCaptures": { "1": { "name": "keyword.control.case.odin" } }, "end": ":", "endCaptures": { "0": { "name": "punctuation.definition.section.case-statement.odin" } }, "name": "meta.case-clause.expr.odin", "patterns": [ { "include": "#expressions" } ] }, "comments": { "patterns": [ { "include": "#block-comment" }, { "begin": "//", "beginCaptures": { "0": { "name": "punctuation.definition.comment.odin" } }, "end": "\\n", "name": "comment.line.double-slash.odin" }, { "begin": "#!", "beginCaptures": { "0": { "name": "punctuation.definition.comment.odin" } }, "end": "\\n", "name": "comment.line.shebang.odin" } ] }, "constant-assignment": { "captures": { "1": { "name": "variable.other.constant.odin" }, "2": { "name": "keyword.operator.assignment.odin" } }, "match": "([A-Z_a-z]\\w*)\\s*(:\\s*:)", "name": "meta.definition.variable.odin" }, "distinct-type-assignment": { "begin": "\\b([A-Z_a-z]\\w*)\\s*(:\\s*:)\\s*(?=(distinct)\\b)", "beginCaptures": { "1": { "name": "entity.name.type.odin" }, "2": { "name": "keyword.operator.assignment.odin" }, "3": { "name": "storage.type.odin" } }, "end": "(?=^)|(?<=})", "name": "meta.definition.variable.odin", "patterns": [ { "include": "#type-declaration" } ] }, "expressions": { "patterns": [ { "include": "#comments" }, { "include": "#ternary" }, { "include": "#map-bitset" }, { "include": "#slice" }, { "include": "#keywords" }, { "include": "#type-parameter" }, { "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" } ] }, "file-tags": { "begin": "#\\+[A-Z_a-z][-0-9A-Z_a-z]*", "beginCaptures": { "0": { "name": "entity.name.tag.odin" } }, "end": "\\n", "name": "comment.line.double-slash.odin", "patterns": [ { "match": ",", "name": "punctuation.odin" }, { "match": "!", "name": "keyword.operator.logical.odin" }, { "match": "[A-Z_a-z][-0-9A-Z_a-z]*", "name": "entity.other.attribute-name.odin" } ] }, "import-declaration": { "begin": "\\b((?:|foreign\\s+)import)\\b", "beginCaptures": { "0": { "name": "keyword.control.import.odin" } }, "end": "(?=^|;)", "name": "meta.import.odin", "patterns": [ { "begin": "\\b[A-Z_a-z]\\w*", "beginCaptures": { "0": { "name": "entity.name.namespace.odin" } }, "end": "(?=^|;)", "name": "entity.name.alias.odin", "patterns": [ { "include": "#strings" }, { "include": "#comments" } ] }, { "include": "#strings" }, { "include": "#comments" } ] }, "keywords": { "patterns": [ { "match": "\\b(import|foreign|package)\\b", "name": "keyword.control.odin" }, { "match": "\\b(if|else|or_else|when|where|for|in|not_in|defer|switch|return|or_return)\\b", "name": "keyword.control.odin" }, { "captures": { "1": { "name": "keyword.control.odin" }, "2": { "name": "entity.name.label.odin" } }, "match": "\\b((?:|or_)(?:break|continue))\\b\\s*(\\w+)?" }, { "match": "\\b(fallthrough|case|dynamic)\\b", "name": "keyword.control.odin" }, { "match": "\\b(do|force_inline|no_inline)\\b", "name": "keyword.control.odin" }, { "match": "\\b(asm)\\b", "name": "keyword.control.odin" }, { "match": "\\b(auto_cast|distinct|using)\\b", "name": "storage.modifier.odin" }, { "match": "\\b(context)\\b", "name": "keyword.context.odin" }, { "match": "\\b(ODIN_(?:ARCH|OS))\\b", "name": "variable.other.constant.odin" }, { "match": "\\b(nil|true|false)\\b", "name": "constant.language.odin" }, { "match": "---", "name": "constant.language.odin" }, { "match": "\\b(\\d([_\\d])*(\\.\\d([_\\d])*)?)(([Ee])([-+])?\\d+)?[ijk]?\\b", "name": "constant.numeric.odin" }, { "match": "\\b((0b([01_])+)|(0o([_\\d])+)|(0d([_\\d])+)|(0[Xhx]([_\\h])+))i?\\b", "name": "constant.numeric.odin" }, { "match": "\\b(struct|enum|union|map|bit_set|bit_field|matrix)\\b", "name": "storage.type.odin" }, { "match": "[-%*+/]=|%%=", "name": "keyword.operator.assignment.compound.odin" }, { "match": "(?:[|~]|&~?|<<|>>)=", "name": "keyword.operator.assignment.compound.bitwise.odin" }, { "match": "[!=]=", "name": "keyword.operator.comparison.odin" }, { "match": "[<>]=?", "name": "keyword.operator.relational.odin" }, { "match": "\\.\\.[<=]", "name": "keyword.operator.range.odin" }, { "match": "\\.\\.", "name": "keyword.operator.spread.odin" }, { "match": ":[:=]|=", "name": "keyword.operator.assignment.odin" }, { "match": "&", "name": "keyword.operator.address.odin" }, { "match": "\\^", "name": "keyword.operator.address.odin" }, { "match": "->", "name": "storage.type.function.arrow.odin" }, { "match": "@|([-!%*+/:|]|<<?|>>?|~)=?|=|: : ?|\\$", "name": "keyword.operator.odin" }, { "match": "#[A-Z_a-z]\\w*", "name": "entity.name.tag.odin" } ] }, "map-bitset": { "begin": "\\b(bit_set|map)\\b", "beginCaptures": { "0": { "name": "storage.type.odin" } }, "end": "]", "endCaptures": { "0": { "name": "punctuation.definition.bracket.square.odin" } }, "patterns": [ { "match": "\\[", "name": "punctuation.definition.bracket.square.odin" }, { "include": "#type-declaration" } ] }, "object-definition": { "begin": "\\{", "beginCaptures": { "0": { "name": "punctuation.definition.block.odin" } }, "end": "}", "endCaptures": { "0": { "name": "punctuation.definition.block.odin" } }, "name": "meta.object.type.odin", "patterns": [ { "include": "#statements" } ] }, "package-name-declaration": { "captures": { "1": { "name": "keyword.control.odin" }, "2": { "name": "entity.name.type.module.odin" } }, "match": "^\\s*(package)\\s+([A-Z_a-z]\\w*)" }, "parameters": { "begin": "\\(", "beginCaptures": { "0": { "name": "punctuation.definition.parameters.begin.odin" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.definition.parameters.end.odin" } }, "name": "meta.parameters.odin", "patterns": [ { "include": "#assignments" }, { "include": "#expressions" } ] }, "procedure-assignment": { "begin": "\\b([A-Z_a-z]\\w*)\\s*(:\\s*:|=)\\s*(#\\w+)?\\s*(?=proc\\b)", "beginCaptures": { "1": { "name": "meta.definition.function.odin entity.name.function.odin" }, "2": { "name": "keyword.operator.assignment.odin" }, "3": { "name": "keyword.other.odin" } }, "end": "(?=^)|(?<=})", "name": "meta.definition.variable.odin", "patterns": [ { "include": "#type-declaration" } ] }, "procedure-calls": { "patterns": [ { "begin": "\\b(cast|transmute)\\b\\s*(\\()", "beginCaptures": { "1": { "name": "keyword.function.odin" }, "2": { "name": "meta.brace.round.odin" } }, "end": "\\)", "endCaptures": { "0": { "name": "meta.brace.round.odin" } }, "name": "meta.function-call.odin", "patterns": [ { "include": "#type-declaration" } ] }, { "begin": "\\b((?:size|align)_of)\\b\\s*(\\()", "beginCaptures": { "1": { "name": "support.function.builtin.odin" }, "2": { "name": "meta.brace.round.odin" } }, "end": "\\)", "endCaptures": { "0": { "name": "meta.brace.round.odin" } }, "name": "meta.function-call.odin", "patterns": [ { "include": "#type-declaration" } ] }, { "begin": "\\b(len|cap|offset_of_selector|offset_of_member|offset_of|offset_of_by_string|type_of|type_info_of|typeid_of|swizzle|complex|quaternion|real|imag|jmag|kmag|conj|expand_values|min|max|abs|clamp|soa_zip|soa_unzip|make|new|new_clone|resize|reserve|append|delete|free|free_all|assert|panic)\\b\\s*(\\()", "beginCaptures": { "1": { "name": "support.function.builtin.odin" }, "2": { "name": "meta.brace.round.odin" } }, "end": "\\)", "endCaptures": { "0": { "name": "meta.brace.round.odin" } }, "name": "meta.function-call.odin", "patterns": [ { "include": "#expressions" } ] }, { "begin": "([A-Z_a-z]\\w*)\\s*(\\()", "beginCaptures": { "1": { "name": "entity.name.function.odin" }, "2": { "name": "meta.brace.round.odin" } }, "end": "\\)", "endCaptures": { "0": { "name": "meta.brace.round.odin" } }, "name": "meta.function-call.odin", "patterns": [ { "include": "#expressions" } ] } ] }, "property-access": { "captures": { "1": { "name": "variable.other.object.odin" }, "2": { "name": "punctuation.accessor.odin" } }, "match": "([A-Z_a-z]\\w*)\\s*(\\.)\\s*(?=[A-Z_a-z]\\w*)" }, "punctuation": { "match": "[](),.;\\[\\\\{}]", "name": "punctuation.odin" }, "return-type-declaration": { "begin": "->", "beginCaptures": { "0": { "name": "storage.type.function.arrow.odin" } }, "end": "(?=^|[),;{]|where)", "name": "meta.return.type.odin", "patterns": [ { "include": "#comments" }, { "include": "#keywords" }, { "include": "#basic-types" }, { "include": "#property-access" }, { "begin": "\\(", "beginCaptures": { "0": { "name": "punctuation.definition.parameters.begin.odin" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.definition.parameters.end.odin" } }, "name": "meta.parameters.odin", "patterns": [ { "include": "#comments" }, { "include": "#assignments" }, { "include": "#keywords" }, { "include": "#basic-types" }, { "include": "#property-access" }, { "include": "#type-name" }, { "include": "#punctuation" } ] }, { "include": "#type-name" } ] }, "slice": { "begin": "\\[", "beginCaptures": { "0": { "name": "meta.brace.square.odin" } }, "end": "]", "endCaptures": { "0": { "name": "meta.brace.square.odin" } }, "name": "meta.slice.odin", "patterns": [ { "match": "\\?", "name": "keyword.operator.array.odin" }, { "match": ":", "name": "keyword.operator.slice.odin" }, { "include": "#expressions" } ] }, "statements": { "patterns": [ { "include": "#attribute" }, { "include": "#procedure-assignment" }, { "include": "#type-assignment" }, { "include": "#distinct-type-assignment" }, { "include": "#constant-assignment" }, { "include": "#variable-assignment" }, { "include": "#case-clause" }, { "include": "#block-label" }, { "include": "#type-annotation" }, { "include": "#block-definition" }, { "include": "#expressions" } ] }, "string-escaped-char": { "patterns": [ { "match": "\\\\(x1b|e|033)\\[[0-9;]*m", "name": "constant.character.escape.ansi-color-sequence.odin" }, { "match": "\\\\([\"'\\\\abefnrtuv]|x\\h{2}|u\\h{4}|U\\h{8}|[0-7]{3})", "name": "constant.character.escape.odin" }, { "match": "%([%E-HMTUXb-imo-tvwxz])", "name": "constant.character.escape.placeholders.odin" }, { "match": "%(\\d*\\.?\\d*f)", "name": "constant.character.escape.placeholders-floats.odin" }, { "match": "\\\\.", "name": "invalid.illegal.unknown-escape.odin" } ] }, "strings": { "patterns": [ { "begin": "\"", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.odin" } }, "end": "\"", "endCaptures": { "0": { "name": "punctuation.definition.string.end.odin" } }, "name": "string.quoted.double.odin", "patterns": [ { "include": "#string-escaped-char" } ] }, { "begin": "'", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.odin" } }, "end": "'", "endCaptures": { "0": { "name": "punctuation.definition.string.end.odin" } }, "name": "string.quoted.single.odin", "patterns": [ { "include": "#string-escaped-char" } ] }, { "begin": "`", "beginCaptures": { "0": { "name": "punctuation.definition.string.begin.odin" } }, "end": "`", "endCaptures": { "0": { "name": "punctuation.definition.string.end.odin" } }, "name": "string.quoted.raw.odin" } ] }, "ternary": { "begin": "\\?", "beginCaptures": { "0": { "name": "keyword.operator.ternary.odin" } }, "end": ":", "endCaptures": { "0": { "name": "keyword.operator.ternary.odin" } }, "name": "meta.ternary.odin", "patterns": [ { "include": "#expressions" } ] }, "type-annotation": { "begin": "(?:([A-Z_a-z]\\w*)\\s*(,)\\s*)?(?:([A-Z_a-z]\\w*)\\s*(,)\\s*)?([A-Z_a-z]\\w*)\\s*(:)", "beginCaptures": { "1": { "name": "variable.name.odin" }, "2": { "name": "punctuation.odin" }, "3": { "name": "variable.name.odin" }, "4": { "name": "punctuation.odin" }, "5": { "name": "variable.name.odin" }, "6": { "name": "keyword.operator.type.annotation.odin" } }, "end": "(?=^|[),:;=]|for|switch|if|\\{)", "name": "meta.type.annotation.odin", "patterns": [ { "include": "#type-declaration" } ] }, "type-assignment": { "begin": "\\b([A-Z_a-z]\\w*)\\s*(:\\s*:)\\s*(?=(struct|union|enum|bit_set|bit_field)\\b)", "beginCaptures": { "1": { "name": "entity.name.type.odin" }, "2": { "name": "keyword.operator.assignment.odin" }, "3": { "name": "storage.type.odin" } }, "end": "(?=^)|(?<=})", "name": "meta.definition.variable.odin", "patterns": [ { "include": "#type-declaration" } ] }, "type-declaration": { "name": "meta.type.declaration.odin", "patterns": [ { "include": "#map-bitset" }, { "begin": "\\b(proc|struct|union|enum|bit_field)\\b", "beginCaptures": { "1": { "name": "storage.type.odin" } }, "end": "(?=^|[),;])|(?<=})", "patterns": [ { "include": "#parameters" }, { "include": "#return-type-declaration" }, { "include": "#object-definition" }, { "include": "#expressions" } ] }, { "include": "#comments" }, { "include": "#strings" }, { "include": "#block-definition" }, { "include": "#keywords" }, { "include": "#basic-types" }, { "include": "#slice" }, { "begin": "\\(", "beginCaptures": { "0": { "name": "punctuation.definition.typeparameters.begin.odin" } }, "end": "\\)", "endCaptures": { "0": { "name": "punctuation.definition.typeparameters.end.odin" } }, "patterns": [ { "include": "#type-declaration" } ] }, { "include": "#property-access" }, { "include": "#punctuation" }, { "include": "#type-name" } ] }, "type-name": { "match": "\\b[A-Z_a-z]\\w*\\b", "name": "entity.name.type.odin" }, "type-parameter": { "captures": { "1": { "name": "keyword.operator.odin" }, "2": { "name": "entity.name.type.parameter.odin" } }, "match": "(\\$)\\s*\\b([A-Z_a-z]\\w*)\\b" }, "union-member-access": { "begin": "([A-Z_a-z]\\w*)\\s*(\\.)\\s*(\\()", "beginCaptures": { "1": { "name": "variable.other.object.odin" }, "2": { "name": "punctuation.accessor.odin" }, "3": { "name": "meta.brace.round.odin" } }, "end": "\\)", "endCaptures": { "0": { "name": "meta.brace.round.odin" } }, "patterns": [ { "include": "#type-declaration" } ] }, "union-non-nil-access": { "captures": { "1": { "name": "variable.other.object.odin" }, "2": { "name": "punctuation.accessor.odin" }, "3": { "name": "punctuation.accessor.optional.odin" } }, "match": "([A-Z_a-z]\\w*)\\s*(\\.)\\s*(\\?)" }, "variable-assignment": { "captures": { "1": { "name": "variable.name.odin" }, "2": { "name": "punctuation.odin" }, "3": { "name": "variable.name.odin" }, "4": { "name": "punctuation.odin" }, "5": { "name": "variable.name.odin" }, "6": { "name": "keyword.operator.assignment.odin" } }, "match": "(?:([A-Z_a-z]\\w*)\\s*(,)\\s*)?(?:([A-Z_a-z]\\w*)\\s*(,)\\s*)?([A-Z_a-z]\\w*)\\s*(:\\s*=)", "name": "meta.definition.variable.odin" }, "variable-name": { "match": "\\b[A-Z_a-z]\\w*\\b", "name": "variable.name.odin" } }, "scopeName": "source.odin" }