Skip to content

Commit a028cf9

Browse files
authored
feat: match 1.4.0 (#15)
* feat: match 1.4.0 * chore: `in` isn't a keyword in Ohm, but a terminal For example, functions can be named `in()`. This behavior may change with Tact 2.0 though. * chore: nativeThrowWhen → nativeThrowIf
1 parent 5f86619 commit a028cf9

File tree

5 files changed

+42
-17
lines changed

5 files changed

+42
-17
lines changed

package/Snippets/variable.sublime-snippet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<snippet>
2-
<content><![CDATA[let ${1:name}: ${2:type} = ${0:value};]]></content>
2+
<content><![CDATA[let ${1:name}${2:: type} = ${0:value};]]></content>
33
<tabTrigger>variable</tabTrigger>
44
<scope>source.tact</scope>
55
<description>let …: … = …;</description>

package/Tact.sublime-completions

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,10 +633,10 @@
633633
"details": "<a href=\"https://docs.tact-lang.org/ref/core-debug#nativethrow\">Tact Docs</a>"
634634
},
635635
{
636-
"trigger": "nativeThrowWhen\tthrow exit code under condition",
637-
"contents": "nativeThrowWhen(${1:code_Int}, ${2:condition_Bool})",
636+
"trigger": "nativeThrowIf\tthrow exit code under condition",
637+
"contents": "nativeThrowIf(${1:code_Int}, ${2:condition_Bool})",
638638
"kind": "function",
639-
"details": "<a href=\"https://docs.tact-lang.org/ref/core-debug#nativethrowwhen\">Tact Docs</a>"
639+
"details": "<a href=\"https://docs.tact-lang.org/ref/core-debug#nativethrowif\">Tact Docs</a>"
640640
},
641641
{
642642
"trigger": "nativeThrowUnless\tthrow exit code unless condition",

package/Tact.tmLanguage

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -725,15 +725,15 @@
725725
<key>comment</key>
726726
<string>Control flow keywords, prefixed by more than one dot</string>
727727
<key>match</key>
728-
<string>(?&lt;=\.\.)\b(else|catch|until|in)\b</string>
728+
<string>(?&lt;=\.\.)\b(else|catch|until|in(?!\s*\())\b</string>
729729
<key>name</key>
730730
<string>keyword.control.tact</string>
731731
</dict>
732732
<dict>
733733
<key>comment</key>
734734
<string>Control flow keywords</string>
735735
<key>match</key>
736-
<string>(?&lt;!\.)\b(if|else|try|catch|repeat|do|until|while|foreach|in|return)\b</string>
736+
<string>(?&lt;!\.)\b(if|else|try|catch|repeat|do|until|while|foreach|in(?!\s*\()|return)\b</string>
737737
<key>name</key>
738738
<string>keyword.control.tact</string>
739739
</dict>
@@ -849,12 +849,25 @@
849849
</dict>
850850
<key>variable</key>
851851
<dict>
852-
<key>comment</key>
853-
<string>Any valid Tact identifier</string>
854-
<key>match</key>
855-
<string>\b([a-zA-Z_][a-zA-Z0-9_]*)\b</string>
856-
<key>name</key>
857-
<string>variable.other.tact</string>
852+
<key>patterns</key>
853+
<array>
854+
<dict>
855+
<key>comment</key>
856+
<string>Any valid Tact identifier</string>
857+
<key>match</key>
858+
<string>(?&lt;!\.)\b(_)\b</string>
859+
<key>name</key>
860+
<string>comment.unused-identifier.tact</string>
861+
</dict>
862+
<dict>
863+
<key>comment</key>
864+
<string>Any valid Tact identifier</string>
865+
<key>match</key>
866+
<string>\b([a-zA-Z_][a-zA-Z0-9_]*)\b</string>
867+
<key>name</key>
868+
<string>variable.other.tact</string>
869+
</dict>
870+
</array>
858871
</dict>
859872
</dict>
860873
</dict>

package/Tact.tmLanguage.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,12 +475,12 @@
475475
},
476476
{
477477
"comment": "Control flow keywords, prefixed by more than one dot",
478-
"match": "(?<=\\.\\.)\\b(else|catch|until|in)\\b",
478+
"match": "(?<=\\.\\.)\\b(else|catch|until|in(?!\\s*\\())\\b",
479479
"name": "keyword.control.tact"
480480
},
481481
{
482482
"comment": "Control flow keywords",
483-
"match": "(?<!\\.)\\b(if|else|try|catch|repeat|do|until|while|foreach|in|return)\\b",
483+
"match": "(?<!\\.)\\b(if|else|try|catch|repeat|do|until|while|foreach|in(?!\\s*\\()|return)\\b",
484484
"name": "keyword.control.tact"
485485
},
486486
{
@@ -556,9 +556,18 @@
556556
},
557557

558558
"variable": {
559-
"comment": "Any valid Tact identifier",
560-
"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b",
561-
"name": "variable.other.tact"
559+
"patterns": [
560+
{
561+
"comment": "Any valid Tact identifier",
562+
"match": "(?<!\\.)\\b(_)\\b",
563+
"name": "comment.unused-identifier.tact"
564+
},
565+
{
566+
"comment": "Any valid Tact identifier",
567+
"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b",
568+
"name": "variable.other.tact"
569+
}
570+
]
562571
}
563572
}
564573
}

tests/syntax_test_statement.tact

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ extends fun c(self: SomeMessage): Int {
5252
// ^^ keyword.operator.assignment.tact
5353
// ^^ constant.numeric.decimal.tact
5454
// ^ punctuation.semi.tact
55+
56+
let _ = 20;
57+
// ^ comment.unused-identifier.tact
5558
}
5659

5760
self.description = "Tact is awesome!";

0 commit comments

Comments
 (0)