From 78d6e4095fd7ca5fcda9a172d4c603d1a4e2a823 Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Wed, 29 May 2024 17:46:54 +0200 Subject: [PATCH] feat: new and awesome grammar, suitable for ST, VSCode, docs and beyond! Fully covers Tact 1.3.0 :rocket: My refactoring kept those goals in mind: 1. Grammar should work with docs, which feature lots of small snippets without the full context of a regular Tact file 2. Grammar should work with Sublime, VSCode and Monaco editor (VSCode's underlying editor). 3. Grammar should properly highlight the "happy path", when the referenced code can be checked by Tact compiler. After all, this is a TextMate grammar, which operates on sequences of RegExes. And thus, it's nigh-impossible and mostly pointless to cover all cases and match up to Ohm's grammer even when one really tries (see 5k+ lines of terse RegEx in TypeScript's TextMate grammar). We just need the "happy path" to work. P.S.: Ironically enough, common advice for parsing HTML with regular expressions is: "Please, don't!", while 80% of all HTML highlighting out there is done with them :) Closes #1 Closes #2 --- .gitignore | 2 + package/Tact.tmLanguage | 801 ++++++++++++++++++++++++++ package/Tact.tmLanguage.json | 525 +++++++++++++++++ package/tact.tmLanguage | 1025 ---------------------------------- package/tact.tmLanguage.json | 673 ---------------------- 5 files changed, 1328 insertions(+), 1698 deletions(-) create mode 100644 package/Tact.tmLanguage create mode 100644 package/Tact.tmLanguage.json delete mode 100644 package/tact.tmLanguage delete mode 100644 package/tact.tmLanguage.json diff --git a/.gitignore b/.gitignore index 1efd363..a1fe1a5 100644 --- a/.gitignore +++ b/.gitignore @@ -140,3 +140,5 @@ dist /.venv !.keep /*.tact +/*.ohm +/*.json diff --git a/package/Tact.tmLanguage b/package/Tact.tmLanguage new file mode 100644 index 0000000..c6a377f --- /dev/null +++ b/package/Tact.tmLanguage @@ -0,0 +1,801 @@ + + + + + name + Tact + displayName + Tact + scopeName + source.tact + fileTypes + + tact + + foldingStartMarker + \{\s*$ + foldingStopMarker + ^\s*\} + patterns + + + include + #comment + + + include + #annotation + + + include + #literal + + + include + #type + + + include + #constant + + + include + #expression + + + include + #punctuation + + + include + #keyword + + + include + #function + + + include + #variable + + + repository + + comment + + patterns + + + name + comment.line.double-slash.tact + begin + // + beginCaptures + + 0 + + name + punctuation.definition.comment.line.double-slash.tact + + + patterns + + + include + #todo + + + end + $ + + + name + comment.block.tact + begin + \s*/\* + beginCaptures + + 0 + + name + comment.block.begin.tact + + + patterns + + + include + #todo + + + end + \*/ + endCaptures + + 0 + + name + comment.block.end.tact + + + + + + todo + + match + (?i)\b(FIXME|TODO|CHANGED|XXX|IDEA|HACK|NOTE|REVIEW|NB|BUG)\b(?-i) + name + keyword.comment.todo.tact + + annotation + + patterns + + + comment + @name() in native functions + begin + ^\s*(@name)\s*(\() + beginCaptures + + 1 + + name + entity.other.attribute-name.tact + + 2 + + name + punctuation.brackets.round.tact + + + patterns + + + comment + FunC identifier + match + ((?:[a-zA-Z_\'\?!&]|::)(?:[a-zA-Z0-9_\'\?!&]|::)*) + name + entity.name.function.func.tact + + + end + \) + endCaptures + + 0 + + name + punctuation.brackets.round.tact + + + + + comment + One or more @inteface() before traits and contracts + begin + (?<!\.)(@interface)\s*(\() + beginCaptures + + 1 + + name + entity.other.attribute-name.tact + + 2 + + name + punctuation.brackets.round.tact + + + patterns + + + include + #string + + + end + \) + endCaptures + + 0 + + name + punctuation.brackets.round.tact + + + + + comment + Fallback match + match + (?<!\.)\b(@name|@interface)\b + name + entity.other.attribute-name.tact + + + + literal + + patterns + + + comment + Hexadecimal integer + match + \b(0[xX][a-fA-F0-9](?:_?[a-fA-F0-9])*)\b + name + constant.numeric.hex.tact + + + comment + Octal integer + match + \b(0[oO][0-7](?:_?[0-7])*)\b + name + constant.numeric.oct.tact + + + comment + Binary integer + match + \b(0[bB][01](?:_?[01])*)\b + name + constant.numeric.bin.tact + + + comment + Decimal integer WITH leading zero + match + \b(0[0-9]*)\b + name + constant.numeric.decimal.tact + + + comment + Decimal integer WITHOUT leading zero + match + \b([1-9](?:_?[0-9])*)\b + name + constant.numeric.decimal.tact + + + comment + Boolean literal + match + (?<!\.)\b(true|false)\b + name + constant.language.bool.tact + + + include + #string + + + comment + self + match + (?<!\.)\b(self)\b + name + variable.language.self.tact + + + + string + + comment + String literal + begin + " + beginCaptures + + 0 + + name + punctuation.definition.string.tact + + + name + string.quoted.double.tact + patterns + + + include + #escape-sequence + + + end + " + endCaptures + + 0 + + name + punctuation.definition.string.tact + + + + escape-sequence + + comment + Allowed escape sequences in strings + match + (\\)(([\\"nrtvbf])|(x[a-fA-F0-9]{2})|(u[a-fA-F0-9]{4})|(u\{[a-fA-F0-9]{1,6}\})) + name + constant.character.escape.tact + captures + + 1 + + name + constant.character.escape.backslash.tact + + 2 + + name + constant.character.escape.special.tact + + 3 + + name + constant.character.escape.hex.tact + + 4 + + name + constant.character.escape.unicode.tact + + 5 + + name + constant.character.escape.unicodepoint.tact + + + + type + + patterns + + + include + #simple-type + + + comment + bounced<T> + begin + (?<!\.)\b(bounced)\s*(<) + beginCaptures + + 1 + + name + entity.name.type.tact storage.type.tact + + 2 + + name + punctuation.brackets.angle.tact + + + patterns + + + include + #simple-type + + + end + > + endCaptures + + 0 + + name + punctuation.brackets.angle.tact + + + + + comment + map<K, V> + begin + (?<!\.)\b(map)\s*(<) + beginCaptures + + 1 + + name + entity.name.type.tact storage.type.tact + + 2 + + name + punctuation.brackets.angle.tact + + + patterns + + + include + #simple-type + + + match + , + name + punctuation.comma.tact + + + include + #as-tlb + + + end + > + endCaptures + + 0 + + name + punctuation.brackets.angle.tact + + + + + include + #as-tlb + + + + simple-type + + comment + Simple types + match + (?<!\.)\b([A-Z][a-zA-Z0-9_]*)(\??) + captures + + 1 + + name + entity.name.type.tact storage.type.tact + + 2 + + name + keyword.operator.optional.tact + + + + as-tlb + + comment + Storage modifiers + patterns + + + match + (?<!\.)\b(as)\s+([a-zA-Z_][a-zA-Z0-9_]*)\b + captures + + 1 + + name + storage.modifier.tact + + 2 + + name + entity.name.type.numeric.tact storage.type.tact + + + + + + constant + + patterns + + + comment + ALL CAPS constants + match + \b([A-Z]{2}[A-Z0-9_]*)\b + name + constant.other.caps.tact + + + comment + Constant declaration or definition + match + ^\s*(const)\s+([A-Z][A-Za-z0-9_]*)\b + captures + + 1 + + name + storage.type.tact + + 2 + + name + constant.other.caps.tact + + + + + comment + null + match + (?<!\.)\b(null)\b + name + constant.language.null.tact + + + + expression + + patterns + + + comment + Logical operators + match + (\|\||&&|!!?)(?!=) + name + keyword.operator.logical.tact + + + comment + Bitwise operators + match + (\^|&|\||~|<<|>>)(?!=) + name + keyword.operator.bitwise.tact + + + comment + Augmented assignment operators + match + (\+=|-=|\*=|/=|%=|\^=|&=|\|=|<<=|>>=) + name + keyword.operator.assignment.tact + + + comment + Assignment operator + match + (?<![<>])=(?!=) + name + keyword.operator.assignment.equal.tact + + + comment + Comparison operators + match + ([!=]=|<=?|>=?) + name + keyword.operator.comparison.tact + + + comment + Math operators + match + ([+\-%]|\*|(?:/(?!/))) + name + keyword.operator.math.tact + + + comment + initOf expression + match + \b(initOf)\b + name + keyword.operator.new.tact + + + comment + Ternary expression + begin + (?!\?\.\s*[^[:digit:]])(\?)(?!\?) + beginCaptures + + 1 + + name + keyword.operator.ternary.tact + + + patterns + + + include + $self + + + end + \s*(:) + endCaptures + + 1 + + name + keyword.operator.ternary.tact + + + + + + punctuation + + patterns + + + match + , + name + punctuation.comma.tact + + + match + [{}] + name + punctuation.brackets.curly.tact + + + match + [()] + name + punctuation.brackets.round.tact + + + match + ; + name + punctuation.semi.tact + + + match + : + name + punctuation.colon.tact + + + match + \. + name + punctuation.dot.tact + + + + keyword + + patterns + + + match + (?<!\.)\b(import)\b + name + keyword.control.import.tact + + + comment + Control flow keywords + match + (?<!\.)\b(if|else|try|catch|repeat|do|until|while|foreach|in|return)\b + name + keyword.control.tact + + + comment + let and const + match + (?<!\.)\b(let|const)\b + name + keyword.other.tact + + + comment + Serialization + match + (?<!\.)\b(as)\b + name + keyword.other.as.tact + + + match + (?<!\.)\b(struct)\b + name + keyword.other.struct.tact + + + match + (?<!\.)\b(message)\b + name + keyword.other.message.tact + + + match + (?<!\.)\b(trait)\b + name + keyword.other.trait.tact + + + match + (?<!\.)\b(contract)\b + name + keyword.other.contract.tact + + + comment + Constant and function attributes + match + (?<!\.)\b(abstract|virtual|override)\b + name + keyword.other.attribute.tact storage.modifier.tact + + + comment + Function attributes + match + (?<!\.)\b(extends|get|inline|mutates)\b + name + keyword.other.attribute.tact + + + comment + Function declaration/definition keywords + match + (?<!\.)\b(fun|native|init|receive|bounced|external)\b + name + keyword.other.function.tact + + + comment + Reserved keywords + match + (?<!\.)\b(extend|public)\b + name + keyword.other.reserved.tact + + + comment + Other keywords + match + (?<!\.)\b(primitive|with)\b + name + keyword.other.tact + + + + function + + comment + Function declaration, definition or call + match + \b((?:[a-zA-Z_][a-zA-Z0-9_]*))\s*\( + captures + + 1 + + name + entity.name.function.tact + + + + variable + + comment + Any valid Tact identifier + match + (?<!\.)\b([a-zA-Z_][a-zA-Z0-9_]*)\b + name + variable.other.tact + + + + \ No newline at end of file diff --git a/package/Tact.tmLanguage.json b/package/Tact.tmLanguage.json new file mode 100644 index 0000000..7e61c90 --- /dev/null +++ b/package/Tact.tmLanguage.json @@ -0,0 +1,525 @@ +{ + "name": "Tact", + "displayName": "Tact", + "scopeName": "source.tact", + "fileTypes": [ + "tact" + ], + "foldingStartMarker": "\\{\\s*$", + "foldingStopMarker": "^\\s*\\}", + "patterns": [ + { + "include": "#comment" + }, + { + "include": "#annotation" + }, + { + "include": "#literal" + }, + { + "include": "#type" + }, + { + "include": "#constant" + }, + { + "include": "#expression" + }, + { + "include": "#punctuation" + }, + { + "include": "#keyword" + }, + { + "include": "#function" + }, + { + "include": "#variable" + } + ], + "repository": { + "comment": { + "patterns": [ + { + "name": "comment.line.double-slash.tact", + "begin": "//", + "beginCaptures": { + "0": { + "name": "punctuation.definition.comment.line.double-slash.tact" + } + }, + "patterns": [ + { + "include": "#todo" + } + ], + "end": "$" + }, + { + "name": "comment.block.tact", + "begin": "\\s*/\\*", + "beginCaptures": { + "0": { + "name": "comment.block.begin.tact" + } + }, + "patterns": [ + { + "include": "#todo" + } + ], + "end": "\\*/", + "endCaptures": { + "0": { + "name": "comment.block.end.tact" + } + } + } + ] + }, + + "todo": { + "match": "(?i)\\b(FIXME|TODO|CHANGED|XXX|IDEA|HACK|NOTE|REVIEW|NB|BUG)\\b(?-i)", + "name": "keyword.comment.todo.tact" + }, + + "annotation": { + "patterns": [ + { + "comment": "@name() in native functions", + "begin": "^\\s*(@name)\\s*(\\()", + "beginCaptures": { + "1": { + "name": "entity.other.attribute-name.tact" + }, + "2": { + "name": "punctuation.brackets.round.tact" + } + }, + "patterns": [ + { + "comment": "FunC identifier", + "match": "((?:[a-zA-Z_\\'\\?!&]|::)(?:[a-zA-Z0-9_\\'\\?!&]|::)*)", + "name": "entity.name.function.func.tact" + } + ], + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.brackets.round.tact" + } + } + }, + { + "comment": "One or more @inteface() before traits and contracts", + "begin": "(?", + "begin": "(?", + "endCaptures": { + "0": { + "name": "punctuation.brackets.angle.tact" + } + } + }, + { + "comment": "map", + "begin": "(?", + "endCaptures": { + "0": { + "name": "punctuation.brackets.angle.tact" + } + } + }, + { + "include": "#as-tlb" + } + ] + }, + + "simple-type": { + "comment": "Simple types", + "match": "(?>)(?!=)", + "name": "keyword.operator.bitwise.tact" + }, + { + "comment": "Augmented assignment operators", + "match": "(\\+=|-=|\\*=|/=|%=|\\^=|&=|\\|=|<<=|>>=)", + "name": "keyword.operator.assignment.tact" + }, + { + "comment": "Assignment operator", + "match": "(?])=(?!=)", + "name": "keyword.operator.assignment.equal.tact" + }, + { + "comment": "Comparison operators", + "match": "([!=]=|<=?|>=?)", + "name": "keyword.operator.comparison.tact" + }, + { + "comment": "Math operators", + "match": "([+\\-%]|\\*|(?:/(?!/)))", + "name": "keyword.operator.math.tact" + }, + { + "comment": "initOf expression", + "match": "\\b(initOf)\\b", + "name": "keyword.operator.new.tact" + }, + { + "comment": "Ternary expression", + "begin": "(?!\\?\\.\\s*[^[:digit:]])(\\?)(?!\\?)", + "beginCaptures": { + "1": { + "name": "keyword.operator.ternary.tact" + } + }, + "patterns": [ + { + "include": "$self" + } + ], + "end": "\\s*(:)", + "endCaptures": { + "1": { + "name": "keyword.operator.ternary.tact" + } + } + } + ] + }, + + "punctuation": { + "patterns": [ + { + "match": ",", + "name": "punctuation.comma.tact" + }, + { + "match": "[{}]", + "name": "punctuation.brackets.curly.tact" + }, + { + "match": "[()]", + "name": "punctuation.brackets.round.tact" + }, + { + "match": ";", + "name": "punctuation.semi.tact" + }, + { + "match": ":", + "name": "punctuation.colon.tact" + }, + { + "match": "\\.", + "name": "punctuation.dot.tact" + } + ] + }, + + "keyword": { + "patterns": [ + { + "match": "(? - - - - name - tact - scopeName - source.tact - fileTypes - - tact - - foldingStartMarker - \{s*$ - foldingStopMarker - ^\s*\} - patterns - - - include - #comments - - - include - #import - - - include - #struct - - - include - #contract-or-trait - - - include - #annotation - - - include - #fun-declaration - - - include - #const-declaration - - - include - #statements - - - repository - - import - - name - meta.import.tact - begin - (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))\b(import)\b\s* - beginCaptures - - 1 - - name - keyword.other.import.tact - - - end - \s*(;) - endCaptures - - 1 - - name - punctuation.terminator.tact - - - patterns - - - include - #comments - - - include - #strings - - - - struct - - name - meta.struct.tact - begin - (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))\b(struct|message)\b - beginCaptures - - 1 - - name - keyword.other.struct - - - end - (?<=\}) - patterns - - - include - #comments - - - include - #struct-header - - - include - #struct-body - - - - struct-header - - patterns - - - include - #comments - - - match - \b[\w]+\b - captures - - 0 - - name - entity.name.type.tact - - - - - match - \(((?:\b0(?:x|X)[0-9a-fA-F][0-9a-fA-F_]*\b)|(?:\b[0-9]+\b))\) - captures - - 1 - - name - constant.numeric - - - - - - struct-body - - begin - \{ - beginCaptures - - 0 - - name - punctuation.definition.block.tact - - - end - \} - endCaptures - - 0 - - name - punctuation.definition.block.tact - - - patterns - - - include - #comments - - - include - #field-declaration - - - - contract-or-trait - - name - meta.struct.tact - begin - (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))\b(contract|trait)\b - beginCaptures - - 1 - - name - keyword.other.struct - - - end - (?<=\}) - patterns - - - include - #comments - - - name - keyword.control.with.tact - match - with - - - name - entity.name.type.tact - match - \b[\w]+\b - - - include - #contract-or-trait-body - - - - contract-or-trait-body - - begin - \{ - beginCaptures - - 0 - - name - punctuation.definition.block.tact - - - end - \} - endCaptures - - 0 - - name - punctuation.definition.block.tact - - - patterns - - - include - #comments - - - include - #init-declaration - - - include - #receive-declaration - - - include - #bounce-declaration - - - include - #fun-declaration - - - include - #const-declaration - - - include - #field-declaration - - - - 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 - - - patterns - - - include - #comments - - - include - #type-annotation - - - include - #variable-init - - - - 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 - - - patterns - - - name - storage.type.tact - match - const - - - name - storage.modifier.tact - match - \b(get|native|extends|mutates|virtual|override|inline|abstract)\b - - - name - variable.name.tact - match - \b[\w]+\b - - - include - #comments - - - include - #type-annotation - - - include - #variable-init - - - - init-declaration - - name - meta.struct.field.tact - begin - (init) - beginCaptures - - 1 - - name - keyword.control.init.tact - - - end - (?<=\}) - patterns - - - include - #comments - - - include - #fun-arguments - - - include - #block-declaration - - - - receive-declaration - - name - meta.struct.field.tact - begin - (receive|external) - beginCaptures - - 1 - - name - keyword.control.receive.tact - - - end - (?<=\}) - patterns - - - include - #comments - - - include - #fun-arguments - - - include - #block-declaration - - - - bounce-declaration - - name - meta.struct.field.tact - begin - (bounced) - beginCaptures - - 1 - - name - keyword.control.bounce.tact - - - end - (?<=\}) - patterns - - - include - #comments - - - include - #fun-arguments - - - include - #block-declaration - - - - fun-declaration - - name - meta.function.tact - begin - (?=\b(?:(?:get|native|extends|mutates|virtual|override|inline|abstract)\s*)*fun\b) - end - (?<=\}|;) - patterns - - - name - storage.type.tact - match - fun - - - name - storage.modifier.tact - match - \b(get|native|extends|mutates|virtual|override|inline|abstract)\b - - - name - meta.definition.function.tact entity.name.function.tact - match - (\b[\w]+\b) - - - include - #fun-declaration-body - - - - fun-declaration-body - - patterns - - - include - #comments - - - include - #fun-arguments - - - include - #type-annotation - - - include - #block-declaration - - - - fun-arguments - - name - meta.parameters.tact - begin - \( - beginCaptures - - 0 - - name - punctuation.definition.parameters.begin.tact - - - end - \) - endCaptures - - 0 - - name - punctuation.definition.parameters.end.tact - - - patterns - - - include - #comments - - - include - #strings - - - include - #type-annotation - - - match - (?:(self)|(\b[\w]+\b)) - captures - - 1 - - name - variable.language.self.tact - - 2 - - name - variable.name.tact - - - - - - block-declaration - - name - meta.block.tact - begin - \{ - beginCaptures - - 0 - - name - punctuation.definition.block.begin.tact - - - end - \} - endCaptures - - 0 - - name - punctuation.definition.block.end.tact - - - patterns - - - include - #statements - - - - statements - - patterns - - - include - #comments - - - include - #block-declaration - - - include - #expressions - - - - annotation - - name - meta.annotation.tact - begin - (@)([\w_]+)(\() - beginCaptures - - 1 - - name - keyword.control.annotation.tact - - 2 - - name - keyword.control.annotation.tact - - 3 - - name - punctuation.definition.annotation.tact - - - end - \) - endCaptures - - 0 - - name - punctuation.definition.annotation.tact - - - patterns - - - include - #annotation-argument - - - - annotation-argument - - patterns - - - match - [\w_]+ - captures - - 0 - - name - entity.name.function.tact - - - - - - expressions - - patterns - - - include - #comments - - - include - #keywords - - - include - #numeric - - - include - #strings - - - include - #type-annotation - - - include - #variables - - - include - #function-call - - - include - #struct-init - - - - 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 - - - patterns - - - include - #comments - - - include - #struct-property - - - - struct-property - - name - meta.struct.init.property, - begin - (\b[\w]+\b)\s*(:) - beginCaptures - - 1 - - name - variable.name.tact - - 2 - - name - punctuation.property.tact - - - end - (?=\}|\,) - patterns - - - include - #comments - - - include - #expressions - - - - variable-init - - name - meta.variable.property.init - begin - (=) - beginCaptures - - 1 - - name - punctuation.tact - - - end - (?=\}|\{|\,|\;) - patterns - - - include - #comments - - - include - #expressions - - - - type-annotation - - name - meta.type.annotation.tact - begin - (:)\s+ - beginCaptures - - 1 - - name - keyword.operator.type.annotation.tact - - - end - (?=\{|\;|\=|\,|\)) - patterns - - - include - #comments - - - include - #type-as - - - include - #type-generic - - - name - keyword.operator.optional.tact - match - \? - - - match - \b[\w]+\b - name - entity.name.type.tact - - - - type-generic - - name - meta.type.generics.tact - begin - < - end - > - patterns - - - include - #comments - - - include - #type-as - - - name - punctuation.tact - match - , - - - match - \b[\w]+\b - name - entity.name.type.tact - - - - type-as - - name - meta.type.annotation.as.tact - begin - (as)\s+ - end - (?=\{|\;|\=|\,|\)|\>) - beginCaptures - - 1 - - name - keyword.control.as.tact - - - patterns - - - include - #comments - - - match - \b[\w]+\b - name - storage.modifier.tact - - - - keywords - - 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 - - - name - keyword.operator - match - (?<=\s)(<=>|>=|<=|!=|==|\^>>|\~>>|>>|<<|\/%|\^%|\~%|\^\/|\~\/|\+=|-=|\*=|\/=|~\/=|\^\/=|%=|\^%=|<<=|>>=|~>>=|\^>>=|&=|\|=|\^=|\^|=|~|\/|%|-|\*|\+|>|<|&|\||:|\?)(?=\s) - - - name - keyword.other - match - \b(false|true)\b - - - - 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 - - patterns - - - name - comment.line - match - \/\/(.*) - - - name - comment.block - begin - /\* - end - \*/ - - - - variables - - patterns - - - match - \b[\w]+\b(?!\s*\()(?!\s*\{) - name - variable.name.tact - - - - function-call - - patterns - - - match - \b[\w]+\b(?=\s*\()(?!\s*\{) - name - entity.name.function.tact - - - - - - \ No newline at end of file diff --git a/package/tact.tmLanguage.json b/package/tact.tmLanguage.json deleted file mode 100644 index 79ae6f7..0000000 --- a/package/tact.tmLanguage.json +++ /dev/null @@ -1,673 +0,0 @@ -{ - "name": "tact", - "scopeName": "source.tact", - "fileTypes": [ - "tact" - ], - "foldingStartMarker": "\\{s*$", - "foldingStopMarker": "^\\s*\\}", - "patterns": [ - { - "include": "#comments" - }, - { - "include": "#import" - }, - { - "include": "#struct" - }, - { - "include": "#contract-or-trait" - }, - { - "include": "#annotation" - }, - { - "include": "#fun-declaration" - }, - { - "include": "#const-declaration" - }, - { - "include": "#statements" - } - ], - "repository": { - "import": { - "name": "meta.import.tact", - "begin": "(?", - "patterns": [ - { - "include": "#comments" - }, - { - "include": "#type-as" - }, - { - "name": "punctuation.tact", - "match": "," - }, - { - "match": "\\b[\\w]+\\b", - "name": "entity.name.type.tact" - } - ] - }, - "type-as": { - "name": "meta.type.annotation.as.tact", - "begin": "(as)\\s+", - "end": "(?=\\{|\\;|\\=|\\,|\\)|\\>)", - "beginCaptures": { - "1": { - "name": "keyword.control.as.tact" - } - }, - "patterns": [ - { - "include": "#comments" - }, - { - "match": "\\b[\\w]+\\b", - "name": "storage.modifier.tact" - } - ] - }, - "keywords": { - "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" - }, - { - "name": "keyword.operator", - "match": "(?<=\\s)(<=>|>=|<=|!=|==|\\^>>|\\~>>|>>|<<|\\/%|\\^%|\\~%|\\^\\/|\\~\\/|\\+=|-=|\\*=|\\/=|~\\/=|\\^\\/=|%=|\\^%=|<<=|>>=|~>>=|\\^>>=|&=|\\|=|\\^=|\\^|=|~|\\/|%|-|\\*|\\+|>|<|&|\\||:|\\?)(?=\\s)" - }, - { - "name": "keyword.other", - "match": "\\b(false|true)\\b" - } - ] - }, - "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": { - "patterns": [ - { - "name": "comment.line", - "match": "\\/\\/(.*)" - }, - { - "name": "comment.block", - "begin": "/\\*", - "end": "\\*/" - } - ] - }, - "variables": { - "patterns": [ - { - "match": "\\b[\\w]+\\b(?!\\s*\\()(?!\\s*\\{)", - "name": "variable.name.tact" - } - ] - }, - "function-call": { - "patterns": [ - { - "match": "\\b[\\w]+\\b(?=\\s*\\()(?!\\s*\\{)", - "name": "entity.name.function.tact" - } - ] - } - } -} \ No newline at end of file