Skip to content

Commit

Permalink
feat: match 1.4.0 (#15)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
novusnota authored Jun 21, 2024
1 parent 5f86619 commit a028cf9
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package/Snippets/variable.sublime-snippet
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<snippet>
<content><![CDATA[let ${1:name}: ${2:type} = ${0:value};]]></content>
<content><![CDATA[let ${1:name}${2:: type} = ${0:value};]]></content>
<tabTrigger>variable</tabTrigger>
<scope>source.tact</scope>
<description>let …: … = …;</description>
Expand Down
6 changes: 3 additions & 3 deletions package/Tact.sublime-completions
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,10 @@
"details": "<a href=\"https://docs.tact-lang.org/ref/core-debug#nativethrow\">Tact Docs</a>"
},
{
"trigger": "nativeThrowWhen\tthrow exit code under condition",
"contents": "nativeThrowWhen(${1:code_Int}, ${2:condition_Bool})",
"trigger": "nativeThrowIf\tthrow exit code under condition",
"contents": "nativeThrowIf(${1:code_Int}, ${2:condition_Bool})",
"kind": "function",
"details": "<a href=\"https://docs.tact-lang.org/ref/core-debug#nativethrowwhen\">Tact Docs</a>"
"details": "<a href=\"https://docs.tact-lang.org/ref/core-debug#nativethrowif\">Tact Docs</a>"
},
{
"trigger": "nativeThrowUnless\tthrow exit code unless condition",
Expand Down
29 changes: 21 additions & 8 deletions package/Tact.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -725,15 +725,15 @@
<key>comment</key>
<string>Control flow keywords, prefixed by more than one dot</string>
<key>match</key>
<string>(?&lt;=\.\.)\b(else|catch|until|in)\b</string>
<string>(?&lt;=\.\.)\b(else|catch|until|in(?!\s*\())\b</string>
<key>name</key>
<string>keyword.control.tact</string>
</dict>
<dict>
<key>comment</key>
<string>Control flow keywords</string>
<key>match</key>
<string>(?&lt;!\.)\b(if|else|try|catch|repeat|do|until|while|foreach|in|return)\b</string>
<string>(?&lt;!\.)\b(if|else|try|catch|repeat|do|until|while|foreach|in(?!\s*\()|return)\b</string>
<key>name</key>
<string>keyword.control.tact</string>
</dict>
Expand Down Expand Up @@ -849,12 +849,25 @@
</dict>
<key>variable</key>
<dict>
<key>comment</key>
<string>Any valid Tact identifier</string>
<key>match</key>
<string>\b([a-zA-Z_][a-zA-Z0-9_]*)\b</string>
<key>name</key>
<string>variable.other.tact</string>
<key>patterns</key>
<array>
<dict>
<key>comment</key>
<string>Any valid Tact identifier</string>
<key>match</key>
<string>(?&lt;!\.)\b(_)\b</string>
<key>name</key>
<string>comment.unused-identifier.tact</string>
</dict>
<dict>
<key>comment</key>
<string>Any valid Tact identifier</string>
<key>match</key>
<string>\b([a-zA-Z_][a-zA-Z0-9_]*)\b</string>
<key>name</key>
<string>variable.other.tact</string>
</dict>
</array>
</dict>
</dict>
</dict>
Expand Down
19 changes: 14 additions & 5 deletions package/Tact.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,12 @@
},
{
"comment": "Control flow keywords, prefixed by more than one dot",
"match": "(?<=\\.\\.)\\b(else|catch|until|in)\\b",
"match": "(?<=\\.\\.)\\b(else|catch|until|in(?!\\s*\\())\\b",
"name": "keyword.control.tact"
},
{
"comment": "Control flow keywords",
"match": "(?<!\\.)\\b(if|else|try|catch|repeat|do|until|while|foreach|in|return)\\b",
"match": "(?<!\\.)\\b(if|else|try|catch|repeat|do|until|while|foreach|in(?!\\s*\\()|return)\\b",
"name": "keyword.control.tact"
},
{
Expand Down Expand Up @@ -556,9 +556,18 @@
},

"variable": {
"comment": "Any valid Tact identifier",
"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b",
"name": "variable.other.tact"
"patterns": [
{
"comment": "Any valid Tact identifier",
"match": "(?<!\\.)\\b(_)\\b",
"name": "comment.unused-identifier.tact"
},
{
"comment": "Any valid Tact identifier",
"match": "\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b",
"name": "variable.other.tact"
}
]
}
}
}
3 changes: 3 additions & 0 deletions tests/syntax_test_statement.tact
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ extends fun c(self: SomeMessage): Int {
// ^^ keyword.operator.assignment.tact
// ^^ constant.numeric.decimal.tact
// ^ punctuation.semi.tact

let _ = 20;
// ^ comment.unused-identifier.tact
}

self.description = "Tact is awesome!";
Expand Down

0 comments on commit a028cf9

Please sign in to comment.