diff --git a/src/assets/ton/tact/tmLanguage.json b/src/assets/ton/tact/tmLanguage.json index be20995..c4a095d 100644 --- a/src/assets/ton/tact/tmLanguage.json +++ b/src/assets/ton/tact/tmLanguage.json @@ -1,276 +1,374 @@ { - "name": "tact", - "scopeName": "source.tact", "fileTypes": [ "tact" ], + "name": "Tact Language", "foldingStartMarker": "\\{s*$", "foldingStopMarker": "^\\s*\\}", "patterns": [ { - "include": "#comments" + "include": "#comment" }, { - "include": "#import" + "include": "#natspec" }, { - "include": "#struct" + "include": "#operator" }, { - "include": "#contract-or-trait" + "include": "#global" }, { - "include": "#annotation" + "include": "#control" }, { - "include": "#fun-declaration" + "include": "#constant" }, { - "include": "#const-declaration" + "include": "#primitive" }, { - "include": "#statements" + "include": "#type-primitive" + }, + { + "include": "#declaration" + }, + { + "include": "#function-call" + }, + { + "include": "#punctuation" } ], "repository": { - "import": { - "name": "meta.import.tact", - "begin": "(?(?!>)|>=|\\&\\&|\\|\\||\\:(?!=)|\\?)", + "name": "keyword.operator.logic" + }, + "operator-mapping": { + "match": "(=>)", + "name": "keyword.operator.mapping" + }, + "operator-arithmetic": { + "match": "(\\+|\\-|\\/|\\*|%)", + "name": "keyword.operator.arithmetic" + }, + "operator-binary": { + "match": "(\\^|\\&|\\||<<|>>)", + "name": "keyword.operator.binary" + }, + "operator-assignment": { + "match": "(\\:?=)", + "name": "keyword.operator.assignment" + }, + "control": { "patterns": [ { - "include": "#comments" + "include": "#control-flow" }, { - "include": "#init-declaration" + "include": "#control-import" }, { - "include": "#receive-declaration" + "include": "#control-underscore" }, { - "include": "#bounce-declaration" - }, + "include": "#control-other" + } + ] + }, + "control-flow": { + "patterns": [ { - "include": "#fun-declaration" - }, + "match": "\\b(if|else|foreach|in|while|do|until|repeat|return|extends|mutates|abstract|native|let|override|virtual|const|self|is|initOf|map|primitive|as|null|try|catch)\\b", + "name": "keyword.control.flow" + } + ] + }, + "control-import": { + "patterns": [ { - "include": "#const-declaration" + "begin": "\\b(import)\\b", + "beginCaptures": { + "1": { + "name": "keyword.control.import" + } + }, + "end": "(?=\\;)", + "patterns": [ + { + "begin": "((?=\\{))", + "end": "((?=\\}))", + "patterns": [ + { + "match": "\\b(\\w+)\\b", + "name": "entity.name.type.interface" + } + ] + }, + { + "match": "\\b(from)\\b", + "name": "keyword.control.import.from" + }, + { + "include": "#string" + }, + { + "include": "#punctuation" + } + ] }, { - "include": "#field-declaration" + "match": "\\b(import)\\b", + "name": "keyword.control.import" } ] }, - "field-declaration": { - "name": "meta.struct.field.tact", - "begin": "(\\b[\\w]+\\b)", - "beginCaptures": { - "1": { - "name": "variable.object.property.tact" - } - }, - "end": "(;)", - "endCaptures": { - "1": { - "name": "punctuation.terminator.tact" - } - }, + "control-underscore": { + "match": "\\b(_)\\b", + "name": "constant.other.underscore" + }, + "control-other": { + "match": "\\b(new|delete)\\b", + "name": "keyword.control" + }, + "constant": { "patterns": [ { - "include": "#comments" + "include": "#constant-boolean" }, { - "include": "#type-annotation" + "include": "#constant-time" }, { - "include": "#variable-init" + "include": "#constant-currency" } ] }, - "const-declaration": { - "name": "meta.struct.field.tact", - "begin": "(?=\\b(?:(?:get|native|extends|mutates|virtual|override|inline|abstract)\\s*)*const\\b)", - "end": "(;)", - "endCaptures": { - "1": { - "name": "punctuation.terminator.tact" - } - }, + "constant-boolean": { + "match": "\\b(true|false)\\b", + "name": "constant.language.boolean" + }, + "constant-time": { + "match": "\\b(now)\\b", + "name": "constant.language.time" + }, + "constant-currency": { + "match": "\\b(ton)\\b", + "name": "constant.language.currency" + }, + "number": { "patterns": [ { - "name": "storage.type.tact", - "match": "const" + "include": "#number-decimal" }, { - "name": "storage.modifier.tact", - "match": "\\b(get|native|extends|mutates|virtual|override|inline|abstract)\\b" + "include": "#number-octal" }, { - "name": "variable.name.tact", - "match": "\\b[\\w]+\\b" + "include": "#number-binary" }, { - "include": "#comments" + "include": "#number-hex" }, { - "include": "#type-annotation" + "include": "#number-scientific" + } + ] + }, + "number-decimal": { + "match": "\\b([0-9_]+(\\.[0-9_]+)?)\\b", + "name": "constant.numeric.decimal" + }, + "number-octal": { + "match": "\\b(0o[0-7_]+)\\b", + "name": "constant.numeric.octal" + }, + "number-binary": { + "match": "\\b(0b[01_]+)\\b", + "name": "constant.numeric.binary" + }, + "number-hex": { + "match": "\\b(0[xX][a-fA-F0-9_]+)\\b", + "name": "constant.numeric.hexadecimal" + }, + "number-scientific": { + "match": "\\b(?:0\\.(?:0[1-9]|[1-9][0-9_]?)|[1-9][0-9_]*(?:\\.\\d{1,2})?)(?:e[+-]?[0-9_]+)?", + "name": "constant.numeric.scientific" + }, + "string": { + "patterns": [ + { + "match": "\\\"(?:(?:\\\\\")|[^\\\"])*\\\"", + "name": "string.quoted.double" }, { - "include": "#variable-init" + "match": "\\'[^\\']*\\'", + "name": "string.quoted.single" } ] }, - "init-declaration": { - "name": "meta.struct.field.tact", - "begin": "(init)", - "beginCaptures": { - "1": { - "name": "keyword.control.init.tact" - } - }, - "end": "(?<=\\})", + "primitive": { "patterns": [ { - "include": "#comments" + "include": "#number-decimal" }, { - "include": "#fun-arguments" + "include": "#number-octal" }, { - "include": "#block-declaration" + "include": "#number-binary" + }, + { + "include": "#number-hex" + }, + { + "include": "#number-scientific" + }, + { + "include": "#string" } ] }, - "receive-declaration": { + "bounce-declaration": { "name": "meta.struct.field.tact", - "begin": "(receive|external)", + "begin": "(bounce)", "beginCaptures": { "1": { - "name": "keyword.control.receive.tact" + "name": "keyword.control.bounce" } }, "end": "(?<=\\})", @@ -279,395 +377,547 @@ "include": "#comments" }, { - "include": "#fun-arguments" - }, + "include": "#declaration-function-arguments" + } + ] + }, + "type-primitive": { + "patterns": [ { - "include": "#block-declaration" + "begin": "\\b(Int|Bool|Address|Slice|Cell|Builder|String|StringBuilder|(?<=: )[A-Z][^ ]*)\\b", + "beginCaptures": { + "1": { + "name": "support.type.primitive" + } + }, + "end": "(?=\\{|\\;|\\=|\\,|\\))", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#type-as" + }, + { + "name": "keyword.operator.optional.tact", + "match": "\\?" + }, + { + "match": "\\b[\\w]+\\b", + "name": "entity.name.type.tact" + } + ] } ] }, - "bounce-declaration": { - "name": "meta.struct.field.tact", - "begin": "(bounced)", + "type-as": { + "name": "meta.type.annotation.as", + "begin": "(as)\\s+", + "end": "(?=\\{|\\;|\\=|\\,|\\))", "beginCaptures": { "1": { - "name": "keyword.control.bounce.tact" + "name": "keyword.control.as" } }, - "end": "(?<=\\})", "patterns": [ { "include": "#comments" }, { - "include": "#fun-arguments" - }, - { - "include": "#block-declaration" + "match": "\\b[\\w]+\\b", + "name": "storage.modifier" } ] }, - "fun-declaration": { - "name": "meta.function.tact", - "begin": "(?=\\b(?:(?:get|native|extends|mutates|virtual|override|inline|abstract)\\s*)*fun\\b)", - "end": "(?<=\\}|;)", + "global": { "patterns": [ { - "name": "storage.type.tact", - "match": "fun" - }, - { - "name": "storage.modifier.tact", - "match": "\\b(get|native|extends|mutates|virtual|override|inline|abstract)\\b" + "include": "#global-variables" }, { - "name": "meta.definition.function.tact entity.name.function.tact", - "match": "(\\b[\\w]+\\b)" - }, + "include": "#global-functions" + } + ] + }, + "global-variables": { + "patterns": [ { - "include": "#fun-declaration-body" + "match": "\\b(self)\\b", + "name": "variable.language.self" } ] }, - "fun-declaration-body": { + "global-functions": { "patterns": [ { - "include": "#comments" + "match": "\\b(ton|require|myBalance|myAddress|contractAddress|contractAddressExt)\\b", + "name": "variable.language.transaction" }, { - "include": "#fun-arguments" + "match": "\\b(send|SendParameters|emit|reply)\\b", + "name": "variable.language.message" }, { - "include": "#type-annotation" + "match": "\\b(randomInt|random)\\b", + "name": "variable.language.random" }, { - "include": "#block-declaration" + "match": "\\b(checkSignature|checkDataSignature|min|max|abs)\\b", + "name": "variable.language.math" + }, + { + "match": "\\b(endCell|beginCell)\\b", + "name": "variable.language.cell" + }, + { + "match": "\\b(abi|readForwardFee|throw|nativeThrowWhen|nativeThrowUnless|getConfigParam|nativeRandomize|nativeRandomizeLt|nativePrepareRandom|nativeRandom|nativeRandomInterval|nativeReserve)\\b", + "name": "variable.language.advanced" } ] }, - "fun-arguments": { - "name": "meta.parameters.tact", - "begin": "\\(", - "beginCaptures": { - "0": { - "name": "punctuation.definition.parameters.begin.tact" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "punctuation.definition.parameters.end.tact" - } - }, + "variable": { "patterns": [ { - "include": "#comments" - }, - { - "include": "#strings" + "match": "\\b(\\_\\w+)\\b", + "captures": { + "1": { + "name": "variable.parameter.function" + } + } }, { - "include": "#type-annotation" + "match": "(?:\\.)(\\w+)\\b", + "captures": { + "1": { + "name": "support.variable.property" + } + }, + "patterns": [ + { + "include": "#type-primitive" + } + ] }, { - "match": "(?:(self)|(\\b[\\w]+\\b))", + "match": "\\b(\\w+)\\b", "captures": { "1": { - "name": "variable.language.self.tact" + "name": "variable.parameter.other" + } + }, + "patterns": [ + { + "include": "#type-primitive" }, - "2": { - "name": "variable.name.tact" + { + "include": "#primitive" + }, + { + "include": "#punctuation" + }, + { + "include": "#global" } - } + ] } ] }, - "block-declaration": { - "name": "meta.block.tact", - "begin": "\\{", - "beginCaptures": { - "0": { - "name": "punctuation.definition.block.begin.tact" - } - }, - "end": "\\}", - "endCaptures": { - "0": { - "name": "punctuation.definition.block.end.tact" - } - }, + "declaration": { "patterns": [ { - "include": "#statements" - } - ] - }, - "statements": { - "patterns": [ + "include": "#declaration-message" + }, { - "include": "#comments" + "include": "#declaration-trait" }, { - "include": "#block-declaration" + "include": "#declaration-contract" }, { - "include": "#expressions" - } - ] - }, - "annotation": { - "name": "meta.annotation.tact", - "begin": "(@)([\\w_]+)(\\()", - "beginCaptures": { - "1": { - "name": "keyword.control.annotation.tact" + "include": "#declaration-interface" }, - "2": { - "name": "keyword.control.annotation.tact" + { + "include": "#declaration-function" }, - "3": { - "name": "punctuation.definition.annotation.tact" - } - }, - "end": "\\)", - "endCaptures": { - "0": { - "name": "punctuation.definition.annotation.tact" - } - }, - "patterns": [ { - "include": "#annotation-argument" + "include": "#declaration-init" + }, + { + "include": "#declaration-storage" } ] }, - "annotation-argument": { + "declaration-message": { "patterns": [ { - "match": "[\\w_]+", + "match": "\\b(message)(\\([0-9x]+\\))?\\s+(\\w+)\\b\\s*(?=\\{)", "captures": { - "0": { - "name": "entity.name.function.tact" + "1": { + "name": "storage.type.message" + }, + "2": { + "name": "constant.numeric.decimal" + }, + "3": { + "name": "entity.name.type.message" } - } + }, + "patterns": [ + { + "include": "#number" + } + ] } ] }, - "expressions": { + "declaration-storage-field": { "patterns": [ { - "include": "#comments" - }, - { - "include": "#keywords" + "include": "#comment" }, { - "include": "#numeric" + "include": "#control" }, { - "include": "#strings" + "include": "#type-primitive" }, { - "include": "#type-annotation" + "include": "#primitive" }, { - "include": "#variables" + "include": "#constant" }, { - "include": "#function-call" + "include": "#operator" }, { - "include": "#struct-init" + "include": "#punctuation" } ] }, - "struct-init": { - "name": "meta.struct.init", - "begin": "(\\b[\\w]+\\b)\\s*(\\{)", - "beginCaptures": { - "1": { - "name": "entity.name.type.tact" - }, - "2": { - "name": "punctuation.definition.block.begin.tact" - } - }, - "end": "(})", - "endCaptures": { - "2": { - "name": "punctuation.definition.block.end.tact" - } - }, + "declaration-storage": { "patterns": [ { - "include": "#comments" + "include": "#declaration-storage-mapping" + }, + { + "include": "#declaration-struct" }, { - "include": "#struct-property" + "include": "#declaration-storage-field" } ] }, - "struct-property": { - "name": "meta.struct.init.property,", - "begin": "(\\b[\\w]+\\b)\\s*(:)", - "beginCaptures": { - "1": { - "name": "variable.name.tact" - }, - "2": { - "name": "punctuation.property.tact" - } - }, - "end": "(?=\\}|\\,)", + "declaration-trait": { "patterns": [ { - "include": "#comments" + "match": "\\b(trait)\\b\\s+(\\w+)\\b\\s*(?=\\{)", + "captures": { + "1": { + "name": "storage.type.trait" + }, + "2": { + "name": "entity.name.type.trait" + } + } }, { - "include": "#expressions" + "begin": "\\b(trait)\\b\\s+(\\w+)\\b\\s+\\b(with)\\b\\s+", + "end": "(?=\\{)", + "beginCaptures": { + "1": { + "name": "storage.type.trait" + }, + "2": { + "name": "entity.name.type.trait" + }, + "3": { + "name": "keyword.control.flow" + }, + "4": { + "name": "entity.name.type.trait" + } + } } ] }, - "variable-init": { - "name": "meta.variable.property.init", - "begin": "(=)", - "beginCaptures": { - "1": { - "name": "punctuation.tact" - } - }, - "end": "(?=\\}|\\{|\\,|\\;)", + "declaration-contract": { "patterns": [ { - "include": "#comments" + "match": "\\b(contract)\\b\\s+(\\w+)\\b\\s*(?=\\{)", + "captures": { + "1": { + "name": "storage.type.contract" + }, + "2": { + "name": "entity.name.type.contract" + } + } }, { - "include": "#expressions" + "begin": "\\b(contract)\\b\\s+(\\w+)\\b\\s+\\b(with)\\b\\s+", + "end": "(?=\\{)", + "beginCaptures": { + "1": { + "name": "storage.type.contract" + }, + "2": { + "name": "entity.name.type.contract" + }, + "3": { + "name": "keyword.control.flow" + }, + "4": { + "name": "entity.name.type.contract" + } + } } ] }, - "type-annotation": { - "name": "meta.type.annotation.tact", - "begin": "(:)\\s+", - "beginCaptures": { - "1": { - "name": "keyword.operator.type.annotation.tact" - } - }, - "end": "(?=\\{|\\;|\\=|\\,|\\))", + "declaration-interface": { "patterns": [ { - "include": "#comments" - }, - { - "include": "#type-as" - }, - { - "include": "#type-generic" - }, - { - "name": "keyword.operator.optional.tact", - "match": "\\?" - }, - { - "match": "\\b[\\w]+\\b", - "name": "entity.name.type.tact" + "match": "\\b(interface)\\b\\s+(\\w+)\\b\\s*(?=\\{)", + "captures": { + "1": { + "name": "storage.type.interface" + }, + "2": { + "name": "entity.name.type.interface" + } + } } ] }, - "type-generic": { - "name": "meta.type.generics.tact", - "begin": "<", - "end": ">", + "declaration-struct": { "patterns": [ { - "include": "#comments" - }, - { - "include": "#type-as" - }, - { - "name": "punctuation.tact", - "match": "," + "match": "\\b(struct)(\\s+([A-Za-z_]\\w*))?\\b", + "captures": { + "1": { + "name": "storage.type.struct" + }, + "3": { + "name": "entity.name.type.struct" + } + } }, { - "match": "\\b[\\w]+\\b", - "name": "entity.name.type.tact" + "begin": "\\b(struct)\\b\\s*(\\w+)?\\b\\s*(?=\\{)", + "beginCaptures": { + "1": { + "name": "storage.type.struct" + }, + "2": { + "name": "entity.name.type.struct" + } + }, + "end": "(?=\\})", + "patterns": [ + { + "include": "#type-primitive" + }, + { + "include": "#variable" + }, + { + "include": "#punctuation" + }, + { + "include": "#comment" + } + ] } ] }, - "type-as": { - "name": "meta.type.annotation.as.tact", - "begin": "(as)\\s+", - "end": "(?=\\{|\\;|\\=|\\,|\\)|\\>)", - "beginCaptures": { - "1": { - "name": "keyword.control.as.tact" - } - }, + "declaration-init": { "patterns": [ { - "include": "#comments" + "begin": "\\b(init)\\b", + "beginCaptures": { + "1": { + "name": "keyword.control.flow" + } + }, + "end": "(?=\\{)", + "patterns": [ + { + "include": "#declaration-function-arguments" + }, + { + "begin": "(?<=\\))", + "end": "(?=\\{)", + "patterns": [ + { + "include": "#function-call" + } + ] + } + ] }, { - "match": "\\b[\\w]+\\b", - "name": "storage.modifier.tact" + "match": "\\b(init)\\b", + "captures": { + "1": { + "name": "storage.type.init" + } + } } ] }, - "keywords": { + "declaration-function-arguments": { "patterns": [ { - "name": "keyword.control.tact", - "match": "\\b(if|else|while|do|until|repeat|return|extends|mutates|virtual|override|inline|native|let|const|fun|self|is|initOf|map|bounced|get|as)\\b" + "match": "(?:(self)|(\\b[\\w]+\\b))\\s*(:)\\s*(\\b[\\w]+\\b)", + "captures": { + "1": { + "name": "variable.language.self" + }, + "2": { + "name": "variable.name" + }, + "4": { + "name": "entity.name.type" + } + } + }, + { + "include": "#variable" }, { - "name": "keyword.operator", - "match": "(?<=\\s)(<=>|>=|<=|!=|==|\\^>>|\\~>>|>>|<<|\\/%|\\^%|\\~%|\\^\\/|\\~\\/|\\+=|-=|\\*=|\\/=|~\\/=|\\^\\/=|%=|\\^%=|<<=|>>=|~>>=|\\^>>=|&=|\\|=|\\^=|\\^|=|~|\\/|%|-|\\*|\\+|>|<|&|\\||:|\\?)(?=\\s)" + "include": "#punctuation" }, { - "name": "keyword.other", - "match": "\\b(false|true)\\b" + "include": "#comment" } ] }, - "strings": { - "name": "string.quoted.double.tact", - "begin": "\"", - "end": "\"" - }, - "numeric": { - "name": "constant.numeric", - "match": "(?:\\b0(?:x|X)[0-9a-fA-F][0-9a-fA-F_]*\\b)|(?:\\b[0-9]+\\b)" - }, - "comments": { + "declaration-function": { "patterns": [ { - "name": "comment.line", - "match": "\\/\\/(.*)" + "begin": "\\b((?:(?:public|get|extends|override|inline|virtual|mutates)|\\s+)*)\\s+(fun|native)\\s+(\\w+)\\b", + "beginCaptures": { + "1": { + "name": "keyword.control.flow" + }, + "2": { + "name": "keyword.control.flow" + }, + "3": { + "name": "entity.name.function" + } + }, + "end": "(?=\\{|;)", + "patterns": [ + { + "include": "#natspec" + }, + { + "include": "#global" + }, + { + "include": "#control-flow" + }, + { + "include": "#function-call" + }, + { + "include": "#declaration-function-arguments" + } + ] }, { - "name": "comment.block", - "begin": "/\\*", - "end": "\\*/" + "match": "\\b(fun)\\s+([A-Za-z_]\\w*)\\b", + "captures": { + "1": { + "name": "keyword.control.flow" + }, + "2": { + "name": "entity.name.function" + } + } } ] }, - "variables": { + "declaration-storage-mapping": { "patterns": [ { - "match": "\\b[\\w]+\\b(?!\\s*\\()(?!\\s*\\{)", - "name": "variable.name.tact" + "begin": "\\b(map)\\b", + "beginCaptures": { + "1": { + "name": "storage.type.mapping" + } + }, + "end": "(?=\\))", + "patterns": [ + { + "include": "#declaration-storage-mapping" + }, + { + "include": "#type-primitive" + }, + { + "include": "#punctuation" + }, + { + "include": "#operator" + } + ] + }, + { + "match": "\\b(map)\\b", + "name": "storage.type.mapping" } ] }, "function-call": { + "match": "\\b([A-Za-z_]\\w*)\\s*\\(", + "captures": { + "1": { + "name": "entity.name.function" + } + } + }, + "punctuation": { "patterns": [ { - "match": "\\b[\\w]+\\b(?=\\s*\\()(?!\\s*\\{)", - "name": "entity.name.function.tact" + "match": ";", + "name": "punctuation.terminator.statement" + }, + { + "match": "\\.", + "name": "punctuation.accessor" + }, + { + "match": ",", + "name": "punctuation.separator" + }, + { + "match": "\\{", + "name": "punctuation.brace.curly.begin" + }, + { + "match": "\\}", + "name": "punctuation.brace.curly.end" + }, + { + "match": "\\[", + "name": "punctuation.brace.square.begin" + }, + { + "match": "\\]", + "name": "punctuation.brace.square.end" + }, + { + "match": "\\(", + "name": "punctuation.parameters.begin" + }, + { + "match": "\\)", + "name": "punctuation.parameters.end" } ] } - } -} \ No newline at end of file + }, + "scopeName": "source.tact" +}