Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Commit 17b997c

Browse files
authored
chore: more enhancements for Tact grammar (#237)
Description of changes: tact-lang/tact-sublime@ffc2d9a
1 parent 9d84f66 commit 17b997c

File tree

1 file changed

+62
-29
lines changed

1 file changed

+62
-29
lines changed

grammars/grammar-tact.json

Lines changed: 62 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@
1818
"include": "#literal"
1919
},
2020
{
21-
"include": "#type"
21+
"include": "#invalid"
2222
},
2323
{
2424
"include": "#constant"
2525
},
26+
{
27+
"include": "#type"
28+
},
2629
{
2730
"include": "#expression"
2831
},
@@ -234,6 +237,53 @@
234237
}
235238
},
236239

240+
"invalid": {
241+
"patterns": [
242+
{
243+
"comment": "Anything starting with __gen or __tact",
244+
"match": "\\b__(?:gen|tact)[a-zA-Z0-9_]*\\b",
245+
"name": "invalid.illegal.identifier.tact"
246+
}
247+
]
248+
},
249+
250+
"constant": {
251+
"patterns": [
252+
{
253+
"comment": "self.storageReserve",
254+
"match": "(?<=self\\.)(storageReserve)\\b",
255+
"name": "constant.other.builtin.tact"
256+
},
257+
{
258+
"comment": "Other constants from the core library",
259+
"match": "(?<!\\.)\\b(SendRemainingValue|SendRemainingBalance|SendPayGasSeparately|SendIgnoreErrors|SendBounceIfActionFail|SendDestroyIfZero|ReserveExact|ReserveAllExcept|ReserveAtMost|ReserveAddOriginalBalance|ReserveInvertSign|ReserveBounceIfActionFail)\\b",
260+
"name": "constant.other.builtin.tact"
261+
},
262+
{
263+
"comment": "ALL CAPS constants",
264+
"match": "\\b([A-Z]{2}[A-Z0-9_]*)\\b",
265+
"name": "constant.other.caps.tact"
266+
},
267+
{
268+
"comment": "Constant declaration or definition",
269+
"match": "^\\s*(const)\\s+([a-zA-Z_][A-Za-z0-9_]*)\\b",
270+
"captures": {
271+
"1": {
272+
"name": "keyword.other.tact"
273+
},
274+
"2": {
275+
"name": "constant.other.declaration.tact"
276+
}
277+
}
278+
},
279+
{
280+
"comment": "null",
281+
"match": "(?<!\\.)\\b(null)\\b",
282+
"name": "constant.language.null.tact"
283+
}
284+
]
285+
},
286+
237287
"type": {
238288
"patterns": [
239289
{
@@ -328,33 +378,6 @@
328378
]
329379
},
330380

331-
"constant": {
332-
"patterns": [
333-
{
334-
"comment": "ALL CAPS constants",
335-
"match": "\\b([A-Z]{2}[A-Z0-9_]*)\\b",
336-
"name": "constant.other.caps.tact"
337-
},
338-
{
339-
"comment": "Constant declaration or definition",
340-
"match": "^\\s*(const)\\s+([A-Z][A-Za-z0-9_]*)\\b",
341-
"captures": {
342-
"1": {
343-
"name": "keyword.other.tact"
344-
},
345-
"2": {
346-
"name": "constant.other.caps.tact"
347-
}
348-
}
349-
},
350-
{
351-
"comment": "null",
352-
"match": "(?<!\\.)\\b(null)\\b",
353-
"name": "constant.language.null.tact"
354-
}
355-
]
356-
},
357-
358381
"expression": {
359382
"patterns": [
360383
{
@@ -450,6 +473,11 @@
450473
"match": "(?<!\\.)\\b(import)\\b",
451474
"name": "keyword.control.import.tact"
452475
},
476+
{
477+
"comment": "Control flow keywords, prefixed by more than one dot",
478+
"match": "(?<=\\.\\.)\\b(else|catch|until|in)\\b",
479+
"name": "keyword.control.tact"
480+
},
453481
{
454482
"comment": "Control flow keywords",
455483
"match": "(?<!\\.)\\b(if|else|try|catch|repeat|do|until|while|foreach|in|return)\\b",
@@ -493,7 +521,12 @@
493521
},
494522
{
495523
"comment": "Function declaration/definition keywords",
496-
"match": "(?<!\\.)\\b(fun|native|init|receive|bounced|external)\\b",
524+
"match": "(?<!\\.)\\b(fun|native)\\b",
525+
"name": "keyword.other.function.tact"
526+
},
527+
{
528+
"comment": "Special functions",
529+
"match": "(?<!\\.)\\b(init|receive|bounced|external)(?=\\s*\\()",
497530
"name": "keyword.other.function.tact"
498531
},
499532
{

0 commit comments

Comments
 (0)