Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/grammars/tala.tmLanguage.json
blob: 74c4467489bced3f161952748a4987673672ae55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
{
  "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
  "name": "Tala",
  "scopeName": "source.tala",
  "fileTypes": ["tala"],
  "patterns": [
    { "include": "#comments" },
    { "include": "#raw-strings" },
    { "include": "#strings" },
    { "include": "#characters" },
    { "include": "#preprocessor" },
    { "include": "#attributes" },
    { "include": "#numbers" },
    { "include": "#callables" },
    { "include": "#declarations" },
    { "include": "#keywords" },
    { "include": "#types" },
    { "include": "#constants" },
    { "include": "#operators" }
  ],
  "repository": {
    "comments": {
      "patterns": [
        {
          "name": "comment.block.documentation.tala",
          "begin": "--\\[(=*)\\[\\|",
          "beginCaptures": {
            "0": { "name": "punctuation.definition.comment.begin.tala" }
          },
          "end": "\\]\\1\\]",
          "endCaptures": {
            "0": { "name": "punctuation.definition.comment.end.tala" }
          }
        },
        {
          "name": "comment.block.documentation.namespace.tala",
          "begin": "--\\[(=*)\\[!",
          "beginCaptures": {
            "0": { "name": "punctuation.definition.comment.begin.tala" }
          },
          "end": "\\]\\1\\]",
          "endCaptures": {
            "0": { "name": "punctuation.definition.comment.end.tala" }
          }
        },
        {
          "name": "comment.block.tala",
          "begin": "--\\[(=*)\\[",
          "beginCaptures": {
            "0": { "name": "punctuation.definition.comment.begin.tala" }
          },
          "end": "\\]\\1\\]",
          "endCaptures": {
            "0": { "name": "punctuation.definition.comment.end.tala" }
          }
        },
        {
          "name": "comment.line.documentation.tala",
          "match": "--\\|.*$"
        },
        {
          "name": "comment.line.documentation.namespace.tala",
          "match": "--!.*$"
        },
        {
          "name": "comment.line.double-dash.tala",
          "match": "--.*$"
        }
      ]
    },
    "raw-strings": {
      "patterns": [
        {
          "name": "string.quoted.other.raw.tala",
          "begin": "(?<!--)\\[(=*)\\[",
          "beginCaptures": {
            "0": { "name": "punctuation.definition.string.begin.tala" }
          },
          "end": "\\]\\1\\]",
          "endCaptures": {
            "0": { "name": "punctuation.definition.string.end.tala" }
          }
        }
      ]
    },
    "strings": {
      "patterns": [
        {
          "name": "string.quoted.double.tala",
          "begin": "\"",
          "beginCaptures": {
            "0": { "name": "punctuation.definition.string.begin.tala" }
          },
          "end": "\"",
          "endCaptures": {
            "0": { "name": "punctuation.definition.string.end.tala" }
          },
          "patterns": [{ "include": "#escapes" }]
        }
      ]
    },
    "characters": {
      "patterns": [
        {
          "name": "string.quoted.single.character.tala",
          "begin": "'",
          "beginCaptures": {
            "0": { "name": "punctuation.definition.string.begin.tala" }
          },
          "end": "'",
          "endCaptures": {
            "0": { "name": "punctuation.definition.string.end.tala" }
          },
          "patterns": [{ "include": "#escapes" }]
        }
      ]
    },
    "escapes": {
      "patterns": [
        {
          "name": "constant.character.escape.tala",
          "match": "\\\\(?:[0abefnrtv'\"\\\\]|x[0-9A-Fa-f]+|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}|\\r?\\n)"
        },
        {
          "name": "invalid.illegal.escape.tala",
          "match": "\\\\."
        }
      ]
    },
    "preprocessor": {
      "patterns": [
        {
          "comment": "#expect is a statement of test code; its condition is an ordinary expression.",
          "match": "(#)(expect)\\b",
          "captures": {
            "1": { "name": "punctuation.definition.keyword.tala" },
            "2": { "name": "keyword.control.test.tala" }
          }
        },
        {
          "name": "meta.preprocessor.tala",
          "begin": "^\\s*(#)(define|setdef|undef|if|elseif|else|endif|error|warn|info|message|region|endregion)\\b",
          "beginCaptures": {
            "1": { "name": "punctuation.definition.directive.tala" },
            "2": { "name": "keyword.control.directive.tala" }
          },
          "end": "$",
          "patterns": [
            { "include": "#strings" },
            { "include": "#numbers" },
            {
              "name": "support.function.preprocessor.tala",
              "match": "\\b(?:os|family)(?=\\s*\\()"
            },
            {
              "name": "keyword.operator.logical.tala",
              "match": "&&|\\|\\||\\bnot\\b"
            }
          ]
        }
      ]
    },
    "attributes": {
      "patterns": [
        {
          "name": "meta.attribute.file.tala",
          "begin": "(#)(\\[)",
          "beginCaptures": {
            "1": { "name": "punctuation.definition.annotation.tala" },
            "2": { "name": "punctuation.section.brackets.begin.tala" }
          },
          "end": "\\]",
          "endCaptures": {
            "0": { "name": "punctuation.section.brackets.end.tala" }
          },
          "patterns": [
            { "include": "#strings" },
            { "include": "#numbers" },
            {
              "name": "entity.name.type.attribute.tala",
              "match": "\\b[A-Z][A-Za-z0-9_]*(?:\\.[A-Z][A-Za-z0-9_]*)*\\b"
            }
          ]
        },
        {
          "name": "meta.attribute.tala",
          "begin": "\\[(?=[A-Za-z_])",
          "beginCaptures": {
            "0": { "name": "punctuation.section.brackets.begin.tala" }
          },
          "end": "\\]",
          "endCaptures": {
            "0": { "name": "punctuation.section.brackets.end.tala" }
          },
          "patterns": [
            { "include": "#strings" },
            { "include": "#numbers" },
            {
              "name": "storage.modifier.attribute-target.tala",
              "match": "\\b(?:file|return|parameter)\\b(?=\\s*:)"
            },
            {
              "name": "entity.name.type.attribute.tala",
              "match": "\\b[A-Z][A-Za-z0-9_]*(?:\\.[A-Z][A-Za-z0-9_]*)*\\b"
            }
          ]
        }
      ]
    },
    "numbers": {
      "patterns": [
        {
          "name": "constant.numeric.float.tala",
          "match": "(?<![A-Za-z0-9_])(?:[0-9](?:[0-9']*[0-9])?\\.[0-9](?:[0-9']*[0-9])?|[0-9](?:[0-9']*[0-9])?[eE][+-]?[0-9]+)(?:[eE][+-]?[0-9]+)?(?![A-Za-z0-9_])"
        },
        {
          "name": "constant.numeric.integer.hexadecimal.tala",
          "match": "(?<![A-Za-z0-9_])0[xX][0-9A-Fa-f](?:[0-9A-Fa-f']*[0-9A-Fa-f])?(?![A-Za-z0-9_])"
        },
        {
          "name": "constant.numeric.integer.binary.tala",
          "match": "(?<![A-Za-z0-9_])0[bB][01](?:[01']*[01])?(?![A-Za-z0-9_])"
        },
        {
          "name": "constant.numeric.integer.octal.tala",
          "match": "(?<![A-Za-z0-9_])0[oO][0-7](?:[0-7']*[0-7])?(?![A-Za-z0-9_])"
        },
        {
          "name": "constant.numeric.integer.decimal.tala",
          "match": "(?<![A-Za-z0-9_])[0-9](?:[0-9']*[0-9])?(?![A-Za-z0-9_])"
        }
      ]
    },
    "callables": {
      "patterns": [
        {
          "name": "storage.modifier.capture.tala",
          "match": "\\b(?:weak|unowned)\\b(?=[^\\]]*\\]\\s*\\\\)"
        },
        {
          "name": "punctuation.definition.lambda.tala",
          "match": "\\\\(?=\\s*(?:\\(|[A-Za-z_]|->))"
        },
        {
          "name": "storage.type.function.arrow.tala",
          "match": "->"
        }
      ]
    },
    "declarations": {
      "patterns": [
        {
          "match": "\\b(namespace)\\s+([A-Za-z_][A-Za-z0-9_]*(?:\\.[A-Za-z_][A-Za-z0-9_]*)*)",
          "captures": {
            "1": { "name": "keyword.declaration.namespace.tala" },
            "2": { "name": "entity.name.namespace.tala" }
          }
        },
        {
          "match": "\\b(data\\s+class|enum\\s+class|class|data|type|object|interface|extension|concept|typealias|attribute)\\s+([A-Za-z_][A-Za-z0-9_]*)",
          "captures": {
            "1": { "name": "keyword.declaration.type.tala" },
            "2": { "name": "entity.name.type.tala" }
          }
        },
        {
          "match": "\\b([A-Za-z_][A-Za-z0-9_]*)\\s*(?=\\()",
          "captures": {
            "1": { "name": "entity.name.function.tala" }
          }
        },
        {
          "match": "\\b(Operator)(<)([^>]+)(>)",
          "captures": {
            "1": { "name": "entity.name.function.operator.tala" },
            "2": { "name": "punctuation.definition.generic.begin.tala" },
            "3": { "name": "keyword.operator.custom.tala" },
            "4": { "name": "punctuation.definition.generic.end.tala" }
          }
        }
      ]
    },
    "keywords": {
      "patterns": [
        {
          "name": "keyword.control.tala",
          "match": "\\b(?:if|else|guard|match|while|do|for|in|by|try|catch|defer|return|throw|yield|break|continue|await|new|Copy|Move)\\b"
        },
        {
          "name": "keyword.declaration.tala",
          "match": "\\b(?:namespace|using|selected|alias|data|class|case|enum|type|object|interface|extension|concept|typealias|attribute|template|typename|requires|targets|permits|throws)\\b"
        },
        {
          "name": "storage.modifier.tala",
          "match": "\\b(?:public|internal|fileprivate|protected|private|static|final|sealed|abstract|inline|extern|virtual|override|op|async|explicit|repeatable|noexcept|convertible|weak|unowned|precedence|associativity|prefix|postfix|left|right)\\b"
        },
        {
          "name": "variable.language.tala",
          "match": "\\b(?:self|Self|super)\\b"
        },
        {
          "name": "keyword.operator.word.tala",
          "match": "\\b(?:and|or|not|is|copy|move)\\b"
        },
        {
          "name": "keyword.other.accessor.tala",
          "match": "\\b(?:get|set)\\b"
        }
      ]
    },
    "types": {
      "patterns": [
        {
          "name": "storage.type.builtin.tala",
          "match": "\\b(?:void|never|bool|char|byte|short|long|int|longint|ubyte|ushort|ulong|uint|ulongint|sfloat|lfloat|float|double|String|auto)\\b"
        },
        {
          "name": "support.type.tala",
          "match": "\\b[A-Z][A-Za-z0-9_]*\\b"
        }
      ]
    },
    "constants": {
      "patterns": [
        {
          "name": "constant.language.tala",
          "match": "\\b(?:true|false|null)\\b"
        }
      ]
    },
    "operators": {
      "patterns": [
        {
          "name": "keyword.operator.assignment.tala",
          "match": "(?<![!<>=\\\\])(?:<<|>>|\\?\\?|[+\\-*/%&|^])?=(?!=)"
        },
        {
          "name": "keyword.operator.range.tala",
          "match": "\\.\\.<|\\.\\.\\.|\\.\\."
        },
        {
          "name": "keyword.operator.arithmetic.tala",
          "match": "\\*\\*|//|[+\\-*/%]"
        },
        {
          "name": "keyword.operator.comparison.tala",
          "match": "==|!=|\\\\=|<=|>=|<|>"
        },
        {
          "name": "keyword.operator.logical.tala",
          "match": "&&|\\|\\||\\?\\?"
        },
        {
          "name": "keyword.operator.conditional.tala",
          "match": "\\?:|\\?|:"
        },
        {
          "name": "keyword.operator.bitwise.tala",
          "match": "<<|>>|[&|^!]"
        },
        {
          "name": "keyword.operator.increment.tala",
          "match": "\\+\\+"
        },
        {
          "name": "keyword.operator.method-reference.tala",
          "match": "::"
        }
      ]
    }
  }
}