diff --git a/package/Tact.sublime-completions b/package/Tact.sublime-completions index 99d0890..16cc445 100644 --- a/package/Tact.sublime-completions +++ b/package/Tact.sublime-completions @@ -14,6 +14,11 @@ "kind": ["function", "a", "Attribute"], "details": "Tact Docs" }, + { + "trigger": "asm\tasm with optional arrangement (...)", + "contents": "asm $0", + "kind": ["function", "a", "Attribute"] + }, // Literals, Base trait and constants { @@ -100,6 +105,11 @@ "kind": ["variable", "c", "Constant"], "details": "Tact Docs" }, + { + "trigger": "SendOnlyEstimateFee\tequal to 1024", + "contents": "SendOnlyEstimateFee", + "kind": ["variable", "c", "Constant"] + }, { "trigger": "ReserveExact\tequal to 0", "contents": "ReserveExact", @@ -150,6 +160,16 @@ "kind": ["variable", "s", "Struct"], "details": "Tact Docs" }, + { + "trigger": "StdAddress", + "contents": "StdAddress", + "kind": ["variable", "s", "Struct"] + }, + { + "trigger": "VarAddress", + "contents": "VarAddress", + "kind": ["variable", "s", "Struct"] + }, // Built-in types and serialization options { @@ -607,6 +627,26 @@ "kind": "function", "details": "Tact Docs" }, + { + "trigger": "slice\tSlice from a BoC String at compile-time", + "contents": "slice(${1:bocBase64String})", + "kind": "function" + }, + { + "trigger": "rawSlice\tSlice from a String at compile-time", + "contents": "rawSlice(${1:someString})", + "kind": "function" + }, + { + "trigger": "ascii\tInt sum of ASCII values at compile-time", + "contents": "aslii(${1:asciiString})", + "kind": "function" + }, + { + "trigger": "crc32\tCRC32 of a String at compile-time", + "contents": "crc32(${1:someString})", + "kind": "function" + }, // Core library: Debug { @@ -651,6 +691,16 @@ "kind": "function", "details": "Tact Docs" }, + { + "trigger": "parseStdAddress\tparse StdAddress from a Slice", + "contents": "parseStdAddress(${1:slice_Slice})", + "kind": "function" + }, + { + "trigger": "parseVarAddress\tparse VarAddress from a Slice", + "contents": "parseVarAddress(${1:slice_Slice})", + "kind": "function" + }, // Core library: Random { @@ -823,11 +873,61 @@ "kind": "function", "details": "Tact Docs" }, + { + "trigger": "nativeSendMessageReturnForwardFee\tsend message Cell with mode Int and get fees", + "contents": "nativeSendMessageReturnForwardFee(${1:cell}, ${2:mode_Int})", + "kind": "function" + }, { "trigger": "nativeReserve\treserve nanoToncoin amount Int with mode Int", "contents": "nativeReserve(${1:amount_Int}, ${2:mode_Int})", "kind": "function", "details": "Tact Docs" - } + }, + { + "trigger": "nativeReserve\treserve nanoToncoin amount Int with mode Int", + "contents": "nativeReserve(${1:amount_Int}, ${2:mode_Int})", + "kind": "function" + }, + { + "trigger": "gasConsumed\tget gas consumed so far", + "contents": "gasConsumed()", + "kind": "function" + }, + { + "trigger": "getComputeFee\tcalc compute cost in nanoToncoins", + "contents": "getComputeFee(${1:gas_used_Int, ${2:is_masterchain_Bool})", + "kind": "function" + }, + { + "trigger": "getStorageFee\tcalc storage fees in nanoToncoins", + "contents": "getStorageFee(${1:cells_Int, ${2:bits_Int}, ${3:seconds_Int}, ${4:is_masterchain_Bool})", + "kind": "function" + }, + { + "trigger": "getForwardFee\tcalc forward fees in nanoToncoins", + "contents": "getForwardFee(${1:cells_Int, ${2:bits_Int}, ${3:is_masterchain_Bool})", + "kind": "function" + }, + { + "trigger": "getSimpleComputeFee\tcalc extra compute cost in nanoToncoins", + "contents": "getSimpleComputeFee(${1:gas_used_Int, ${2:is_masterchain_Bool})", + "kind": "function" + }, + { + "trigger": "getSimpleForwardFee\tcalc extra forward fees in nanoToncoins", + "contents": "getSimpleForwardFee(${1:cells_Int, ${2:bits_Int}, ${3:is_masterchain_Bool})", + "kind": "function" + }, + { + "trigger": "getOriginalFwdFee\tcalc original fwd_fee in nanoToncoins", + "contents": "getOriginalFwdFee(${1:fwd_fee_Int, ${2:is_masterchain_Bool})", + "kind": "function" + }, + { + "trigger": "myStorageDue\tstorage fee debt in nanoToncoins", + "contents": "myStorageDue(${1:fwd_fee_Int, ${2:is_masterchain_Bool})", + "kind": "function" + }, ] } diff --git a/package/Tact.tmLanguage b/package/Tact.tmLanguage index d6d0e86..9f69015 100644 --- a/package/Tact.tmLanguage +++ b/package/Tact.tmLanguage @@ -212,11 +212,59 @@ + + comment + Asm arrangements + begin + (?<!\.)(asm)\s*(\() + beginCaptures + + 1 + + name + entity.other.attribute-name.tact + + 2 + + name + punctuation.brackets.round.tact + + + patterns + + + include + #variable + + + match + -> + name + keyword.operator.mapsto.tact + + + match + \b([0-9]*)\b + name + constant.numeric.decimal.tact + + + end + \) + endCaptures + + 0 + + name + punctuation.brackets.round.tact + + + comment Fallback match match - (?<!\.)\b(@name|@interface)\b + (?<!\.)\b(@name|@interface|asm)\b name entity.other.attribute-name.tact @@ -394,7 +442,7 @@ comment Other constants from the core library match - (?<!\.)\b(SendRemainingValue|SendRemainingBalance|SendPayGasSeparately|SendIgnoreErrors|SendBounceIfActionFail|SendDestroyIfZero|ReserveExact|ReserveAllExcept|ReserveAtMost|ReserveAddOriginalBalance|ReserveInvertSign|ReserveBounceIfActionFail)\b + (?<!\.)\b(SendRemainingValue|SendRemainingBalance|SendPayGasSeparately|SendIgnoreErrors|SendBounceIfActionFail|SendDestroyIfZero|SendOnlyEstimateFee|ReserveExact|ReserveAllExcept|ReserveAtMost|ReserveAddOriginalBalance|ReserveInvertSign|ReserveBounceIfActionFail)\b name constant.other.builtin.tact @@ -559,7 +607,7 @@ match - (?<!\.)\b(as)\s+([a-zA-Z_][a-zA-Z0-9_]*)\b + (?<!\.)\b(as)\s+(coins|remaining|bytes32|bytes64|int257|u?int(?:2[0-5][0-6]|1[0-9][0-9]|[1-9][0-9]?))\b captures 1 @@ -871,4 +919,4 @@ - + \ No newline at end of file diff --git a/package/Tact.tmLanguage.json b/package/Tact.tmLanguage.json index 882d495..073d318 100644 --- a/package/Tact.tmLanguage.json +++ b/package/Tact.tmLanguage.json @@ -138,9 +138,40 @@ } } }, + { + "comment": "Asm arrangements", + "begin": "(?", + "name": "keyword.operator.mapsto.tact" + }, + { + "match": "\\b([0-9]*)\\b", + "name": "constant.numeric.decimal.tact" + } + ], + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.brackets.round.tact" + } + } + }, { "comment": "Fallback match", - "match": "(? 0) fun addTwo(first: Int, second: Int): Int { SOMETHING SOMETHING } +// <- entity.other.attribute-name.tact +// ^ punctuation.brackets.round.tact +// ^^^^^^ variable.other.tact +// ^^^^^ variable.other.tact +// ^^ keyword.operator.mapsto.tact +// ^ constant.numeric.decimal.tact +// ^ punctuation.brackets.round.tact \ No newline at end of file diff --git a/tests/syntax_test_struct.tact b/tests/syntax_test_struct.tact index b1447e8..4f79187 100644 --- a/tests/syntax_test_struct.tact +++ b/tests/syntax_test_struct.tact @@ -63,3 +63,39 @@ fun TestStruct() { // ^ punctuation.brackets.curly.tact // ^ punctuation.semi.tact } + +struct Serialization { + f1: Int as uint1; + // ^^^^^ entity.name.type.tact + f2: Int as int1; + // ^^^^ entity.name.type.tact + f3: Int as uint10; + // ^^^^^^ entity.name.type.tact + f4: Int as int10; + // ^^^^^ entity.name.type.tact + f5: Int as uint100; + // ^^^^^^^ entity.name.type.tact + f6: Int as int100; + // ^^^^^^ entity.name.type.tact + f7: Int as uint200; + // ^^^^^^^ entity.name.type.tact + f8: Int as int200; + // ^^^^^^ entity.name.type.tact + f9: Int as uint256; + // ^^^^^^^ entity.name.type.tact + f10: Int as int257; + // ^^^^^^ entity.name.type.tact + f9wrong: Int as uint257; + // ^^^^^^^ variable.other.tact + f10wrong: Int as int258; + // ^^^^^^ variable.other.tact + + b32: Slice as bytes32; + // ^^^^^^^ entity.name.type.tact + b64: Slice as bytes64; + // ^^^^^^^ entity.name.type.tact + coin: Int as coins; + // ^^^^^ entity.name.type.tact + payload: Slice as remaining; + // ^^^^^^^^^ entity.name.type.tact +} \ No newline at end of file