@mirascript/textmate 0.1.82 → 0.1.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.c8rc.json +6 -0
- package/ava.config.js +4 -0
- package/dist/grammar.d.ts +14 -0
- package/dist/grammar.d.ts.map +1 -0
- package/dist/grammar.js +1129 -0
- package/dist/grammar.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -8
- package/dist/index.js.map +1 -0
- package/dist/language.d.ts +18 -0
- package/dist/language.d.ts.map +1 -0
- package/dist/language.js +15 -0
- package/dist/language.js.map +1 -0
- package/dist/mirascript-doc.tmLanguage.json +477 -86
- package/dist/mirascript-template.tmLanguage.json +422 -277
- package/dist/mirascript.tmLanguage.json +426 -272
- package/package.json +11 -13
- package/src/grammar.ts +1157 -0
- package/src/index.ts +10 -0
- package/src/language.ts +21 -0
- package/tests/_engine.ts +53 -0
- package/tests/grammar/documentation-comments.ts +157 -0
- package/tests/grammar/documentation-mode.ts +372 -0
- package/tests/grammar/language.ts +59 -0
- package/tests/grammar/strings.ts +35 -0
- package/tests/js-compatibility.ts +22 -0
- package/tests/language.ts +9 -0
- package/tests/tsconfig.json +3 -0
- package/tsconfig.json +11 -0
package/dist/grammar.js
ADDED
|
@@ -0,0 +1,1129 @@
|
|
|
1
|
+
import { CONSTANT_KEYWORDS, CONTROL_KEYWORDS, KEYWORDS, NUMERIC_KEYWORDS, REG_IDENTIFIER, RESERVED_KEYWORDS, } from '@mirascript/constants';
|
|
2
|
+
import { mirascriptDocLanguage, mirascriptLanguage, mirascriptTemplateLanguage } from "./language.js";
|
|
3
|
+
const SCOPE_SUFFIX = 'mira';
|
|
4
|
+
const IDENTIFIER = REG_IDENTIFIER.source;
|
|
5
|
+
const IDENTIFIER_START = String.raw `(?<!\p{XID_Continue})`;
|
|
6
|
+
const IDENTIFIER_END = String.raw `(?!\p{XID_Continue})`;
|
|
7
|
+
const MAX_VERBATIM_LENGTH = 16;
|
|
8
|
+
const BUILT_IN_TYPES = [
|
|
9
|
+
'any',
|
|
10
|
+
'unknown',
|
|
11
|
+
'never',
|
|
12
|
+
'boolean',
|
|
13
|
+
'true',
|
|
14
|
+
'false',
|
|
15
|
+
'number',
|
|
16
|
+
'string',
|
|
17
|
+
'record',
|
|
18
|
+
'array',
|
|
19
|
+
'extern',
|
|
20
|
+
'module',
|
|
21
|
+
'nil',
|
|
22
|
+
];
|
|
23
|
+
const DOC_CONSTANT_IDENTIFIER = String.raw `(?:@+\p{XID_Continue}+|\p{Lu}[\p{XID_Continue}]*)`;
|
|
24
|
+
const DOC_TAG_NAME = String.raw `[^>\r\n]*[^>\s]`;
|
|
25
|
+
const DOC_TAG_CONTENT = String.raw `(?:module|function|extern)(?:[ \t]+${DOC_TAG_NAME})?`;
|
|
26
|
+
const DOC_FIELD_NAME = String.raw `(?:${IDENTIFIER}|\d+|"(?:\\.|[^"\\\r\n])*"|'(?:\\.|[^'\\\r\n])*')`;
|
|
27
|
+
const DOC_TAG_NUMBER = String.raw `\d[\d_]*(?:\.[\d_]+)?(?:[eE][+-]?[\d_]*\d)?`;
|
|
28
|
+
/**
|
|
29
|
+
* Escape a literal value for insertion into an Oniguruma regular expression.
|
|
30
|
+
*/
|
|
31
|
+
function escapeRegex(value) {
|
|
32
|
+
return value.replaceAll(/[\\^$.*+?()[\]{}|]/g, String.raw `\$&`).replaceAll(/\s+/g, String.raw `\s+`);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Build a longest-first regular-expression alternation.
|
|
36
|
+
*/
|
|
37
|
+
function alternatives(values) {
|
|
38
|
+
return [...values]
|
|
39
|
+
.sort((a, b) => b.length - a.length)
|
|
40
|
+
.map(escapeRegex)
|
|
41
|
+
.join('|');
|
|
42
|
+
}
|
|
43
|
+
const numericKeywordSet = new Set(NUMERIC_KEYWORDS);
|
|
44
|
+
const constantKeywords = CONSTANT_KEYWORDS.filter((keyword) => !numericKeywordSet.has(keyword));
|
|
45
|
+
const languageVariables = ['_', 'global'];
|
|
46
|
+
const wordOperators = ['in', 'is', 'and', 'or', 'not'];
|
|
47
|
+
const declarationKeywords = ['fn', 'op', 'let', 'const', 'mut', 'where'];
|
|
48
|
+
const moduleKeywords = ['mod', 'pub', 'use'];
|
|
49
|
+
const classifiedKeywords = new Set([
|
|
50
|
+
...CONSTANT_KEYWORDS,
|
|
51
|
+
...CONTROL_KEYWORDS,
|
|
52
|
+
...languageVariables,
|
|
53
|
+
...wordOperators,
|
|
54
|
+
...declarationKeywords,
|
|
55
|
+
...moduleKeywords,
|
|
56
|
+
...RESERVED_KEYWORDS,
|
|
57
|
+
'type',
|
|
58
|
+
]);
|
|
59
|
+
const otherKeywords = KEYWORDS.filter((keyword) => !classifiedKeywords.has(keyword));
|
|
60
|
+
const mirascriptFenceTags = alternatives([mirascriptLanguage.name, ...mirascriptLanguage.aliases]);
|
|
61
|
+
const documentationMiraFenceBegin = String.raw `^(\s*\*\s?)(\x60{3,})\s*((?i:${mirascriptFenceTags}))?\s*$`;
|
|
62
|
+
const documentationOtherFenceBegin = String.raw `^(\s*\*\s?)(\x60{3,})\s*(\S+)(?:\s+.*)?\s*$`;
|
|
63
|
+
const documentationFenceEnd = String.raw `^(?:(\s*\*\s?)(\2\x60*)\s*$)|(?=\*/)`;
|
|
64
|
+
const documentationMiraLine = String.raw `^(?!\s*\*\s*\x60{3,}\s*$)(?!.*\*/)(\s*\*\s?)`;
|
|
65
|
+
const documentationInjectionSelector = 'L:comment.block.documentation.mira -markup.fenced_code.block.mira -meta.documentation.inline.mira';
|
|
66
|
+
/**
|
|
67
|
+
* Create interpolation rules for one exact dollar-sign width.
|
|
68
|
+
*/
|
|
69
|
+
function interpolationPatterns(dollarCount) {
|
|
70
|
+
const dollars = String.raw `\$`.repeat(dollarCount);
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
name: `meta.interpolation.simple.${SCOPE_SUFFIX}`,
|
|
74
|
+
match: `(${dollars})(${IDENTIFIER})`,
|
|
75
|
+
captures: {
|
|
76
|
+
1: { name: `punctuation.definition.template-expression.begin.${SCOPE_SUFFIX}` },
|
|
77
|
+
2: { name: `variable.other.${SCOPE_SUFFIX}` },
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: `meta.interpolation.block.${SCOPE_SUFFIX}`,
|
|
82
|
+
begin: String.raw `(${dollars}\{)`,
|
|
83
|
+
beginCaptures: { 1: { name: `punctuation.definition.template-expression.begin.${SCOPE_SUFFIX}` } },
|
|
84
|
+
end: String.raw `\}`,
|
|
85
|
+
endCaptures: { 0: { name: `punctuation.definition.template-expression.end.${SCOPE_SUFFIX}` } },
|
|
86
|
+
patterns: [{ include: '#braced-content' }],
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: `meta.interpolation.expression.${SCOPE_SUFFIX}`,
|
|
90
|
+
begin: String.raw `(${dollars}\()`,
|
|
91
|
+
beginCaptures: { 1: { name: `punctuation.definition.template-expression.begin.${SCOPE_SUFFIX}` } },
|
|
92
|
+
end: String.raw `\)`,
|
|
93
|
+
endCaptures: { 0: { name: `punctuation.definition.template-expression.end.${SCOPE_SUFFIX}` } },
|
|
94
|
+
patterns: [
|
|
95
|
+
{
|
|
96
|
+
begin: ':(?!:)',
|
|
97
|
+
beginCaptures: { 0: { name: `punctuation.separator.format.${SCOPE_SUFFIX}` } },
|
|
98
|
+
end: String.raw `(?=\))`,
|
|
99
|
+
contentName: `string.unquoted.format.${SCOPE_SUFFIX}`,
|
|
100
|
+
patterns: [{ include: '#format-content' }],
|
|
101
|
+
},
|
|
102
|
+
{ include: '#interpolation-expression-content' },
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Create a quoted-string rule with escapes and single-dollar interpolation.
|
|
109
|
+
*/
|
|
110
|
+
function normalString(quote, label) {
|
|
111
|
+
const escapedQuote = escapeRegex(quote);
|
|
112
|
+
return {
|
|
113
|
+
name: `string.quoted.${label}.${SCOPE_SUFFIX}`,
|
|
114
|
+
begin: escapedQuote,
|
|
115
|
+
beginCaptures: { 0: { name: `punctuation.definition.string.begin.${SCOPE_SUFFIX}` } },
|
|
116
|
+
end: escapedQuote,
|
|
117
|
+
endCaptures: { 0: { name: `punctuation.definition.string.end.${SCOPE_SUFFIX}` } },
|
|
118
|
+
patterns: [
|
|
119
|
+
{ name: `constant.character.escape.unicode.${SCOPE_SUFFIX}`, match: String.raw `\\u\{[0-9A-Fa-f]+\}` },
|
|
120
|
+
{ name: `constant.character.escape.hex.${SCOPE_SUFFIX}`, match: String.raw `\\x[0-9A-Fa-f]{2}` },
|
|
121
|
+
{ name: `constant.character.escape.${SCOPE_SUFFIX}`, match: '\\\\[\\\\\'"\\`$rntbfv0]' },
|
|
122
|
+
{ name: `invalid.illegal.escape.${SCOPE_SUFFIX}`, match: String.raw `\\.` },
|
|
123
|
+
...interpolationPatterns(1),
|
|
124
|
+
],
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Create an exact-width MiraScript verbatim-string rule.
|
|
129
|
+
*/
|
|
130
|
+
function verbatimString(atCount, quote, label) {
|
|
131
|
+
const ats = '@'.repeat(atCount);
|
|
132
|
+
const escapedQuote = escapeRegex(quote);
|
|
133
|
+
return {
|
|
134
|
+
name: `string.quoted.${label}.verbatim.${SCOPE_SUFFIX}`,
|
|
135
|
+
begin: `(?<!@)${ats}${escapedQuote}`,
|
|
136
|
+
beginCaptures: { 0: { name: `punctuation.definition.string.begin.${SCOPE_SUFFIX}` } },
|
|
137
|
+
end: `${escapedQuote}${ats}(?!@)`,
|
|
138
|
+
endCaptures: { 0: { name: `punctuation.definition.string.end.${SCOPE_SUFFIX}` } },
|
|
139
|
+
patterns: interpolationPatterns(atCount),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Build normal and 1-16 marker verbatim-string rules for every quote style.
|
|
144
|
+
*/
|
|
145
|
+
function stringPatterns() {
|
|
146
|
+
const quotes = [
|
|
147
|
+
['"', 'double'],
|
|
148
|
+
["'", 'single'],
|
|
149
|
+
['`', 'backtick'],
|
|
150
|
+
];
|
|
151
|
+
return [
|
|
152
|
+
...Array.from({ length: MAX_VERBATIM_LENGTH }, (_, index) => MAX_VERBATIM_LENGTH - index).flatMap((atCount) => quotes.map(([quote, label]) => verbatimString(atCount, quote, label))),
|
|
153
|
+
...quotes.map(([quote, label]) => normalString(quote, label)),
|
|
154
|
+
];
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Build the documentation-comment rules shared by source and doc grammars.
|
|
158
|
+
*/
|
|
159
|
+
function documentationRepository(sourceInclude = '#source') {
|
|
160
|
+
return {
|
|
161
|
+
documentation: {
|
|
162
|
+
patterns: [
|
|
163
|
+
{ include: '#documentation-mirascript-fence' },
|
|
164
|
+
{ include: '#documentation-other-fence' },
|
|
165
|
+
{ include: '#documentation-line' },
|
|
166
|
+
{ include: '#documentation-fragment' },
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
'documentation-inline': {
|
|
170
|
+
patterns: [
|
|
171
|
+
{
|
|
172
|
+
name: `storage.type.class.documentation.${SCOPE_SUFFIX}`,
|
|
173
|
+
match: String.raw `@(param|returns)\b`,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: `markup.bold.documentation.${SCOPE_SUFFIX}`,
|
|
177
|
+
match: String.raw `\*\*[^*]+\*\*`,
|
|
178
|
+
},
|
|
179
|
+
{ name: `markup.italic.documentation.${SCOPE_SUFFIX}`, match: String.raw `\*[^*]+\*` },
|
|
180
|
+
{ name: `constant.character.escape.documentation.${SCOPE_SUFFIX}`, match: String.raw `\\\*` },
|
|
181
|
+
],
|
|
182
|
+
},
|
|
183
|
+
'documentation-line': {
|
|
184
|
+
patterns: [
|
|
185
|
+
{
|
|
186
|
+
match: String.raw `^(?!\s*\*/)(\s*\*\s?)(.*?)(?=\*/|$)`,
|
|
187
|
+
captures: {
|
|
188
|
+
1: { name: `comment.block.documentation.${SCOPE_SUFFIX}` },
|
|
189
|
+
2: {
|
|
190
|
+
name: `meta.documentation.inline.${SCOPE_SUFFIX}`,
|
|
191
|
+
patterns: [{ include: '#documentation-inline' }],
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
},
|
|
197
|
+
'documentation-fragment': {
|
|
198
|
+
patterns: [
|
|
199
|
+
{
|
|
200
|
+
match: String.raw `(?!\*/)(.+?)(?=\*/|$)`,
|
|
201
|
+
captures: {
|
|
202
|
+
1: {
|
|
203
|
+
name: `meta.documentation.inline.${SCOPE_SUFFIX}`,
|
|
204
|
+
patterns: [{ include: '#documentation-inline' }],
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
},
|
|
210
|
+
'documentation-mirascript-fence': {
|
|
211
|
+
patterns: [
|
|
212
|
+
{
|
|
213
|
+
name: `markup.fenced_code.block.${SCOPE_SUFFIX}`,
|
|
214
|
+
begin: documentationMiraFenceBegin,
|
|
215
|
+
beginCaptures: {
|
|
216
|
+
1: { name: `comment.block.documentation.${SCOPE_SUFFIX}` },
|
|
217
|
+
2: { name: `punctuation.definition.markdown.${SCOPE_SUFFIX}` },
|
|
218
|
+
3: { name: `fenced_code.block.language.${SCOPE_SUFFIX}` },
|
|
219
|
+
},
|
|
220
|
+
end: documentationFenceEnd,
|
|
221
|
+
endCaptures: {
|
|
222
|
+
1: { name: `comment.block.documentation.${SCOPE_SUFFIX}` },
|
|
223
|
+
2: { name: `punctuation.definition.markdown.${SCOPE_SUFFIX}` },
|
|
224
|
+
},
|
|
225
|
+
patterns: [
|
|
226
|
+
{
|
|
227
|
+
name: `meta.embedded.block.${SCOPE_SUFFIX}`,
|
|
228
|
+
contentName: `source.${SCOPE_SUFFIX}`,
|
|
229
|
+
begin: documentationMiraLine,
|
|
230
|
+
beginCaptures: {
|
|
231
|
+
1: { name: `comment.block.documentation.${SCOPE_SUFFIX}` },
|
|
232
|
+
},
|
|
233
|
+
while: documentationMiraLine,
|
|
234
|
+
whileCaptures: {
|
|
235
|
+
1: { name: `comment.block.documentation.${SCOPE_SUFFIX}` },
|
|
236
|
+
},
|
|
237
|
+
patterns: [{ include: sourceInclude }],
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: `comment.block.documentation.${SCOPE_SUFFIX}`,
|
|
241
|
+
match: String.raw `^(?!\s*\*/)(\s*\*\s?)`,
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
},
|
|
247
|
+
'documentation-other-fence': {
|
|
248
|
+
patterns: [
|
|
249
|
+
{
|
|
250
|
+
name: `markup.fenced_code.block.${SCOPE_SUFFIX}`,
|
|
251
|
+
contentName: `markup.raw.block.${SCOPE_SUFFIX}`,
|
|
252
|
+
begin: documentationOtherFenceBegin,
|
|
253
|
+
beginCaptures: {
|
|
254
|
+
1: { name: `comment.block.documentation.${SCOPE_SUFFIX}` },
|
|
255
|
+
2: { name: `punctuation.definition.markdown.${SCOPE_SUFFIX}` },
|
|
256
|
+
3: { name: `fenced_code.block.language.${SCOPE_SUFFIX}` },
|
|
257
|
+
},
|
|
258
|
+
end: documentationFenceEnd,
|
|
259
|
+
endCaptures: {
|
|
260
|
+
1: { name: `comment.block.documentation.${SCOPE_SUFFIX}` },
|
|
261
|
+
2: { name: `punctuation.definition.markdown.${SCOPE_SUFFIX}` },
|
|
262
|
+
},
|
|
263
|
+
patterns: [
|
|
264
|
+
{
|
|
265
|
+
name: `comment.block.documentation.${SCOPE_SUFFIX}`,
|
|
266
|
+
match: String.raw `^(?!\s*\*/)(\s*\*\s?)`,
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
],
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Build the shared repository used by source and template grammars.
|
|
276
|
+
*/
|
|
277
|
+
function sourceRepository() {
|
|
278
|
+
/**
|
|
279
|
+
* Create a boundary-aware TextMate keyword rule.
|
|
280
|
+
*/
|
|
281
|
+
const keywordRule = (values, name) => ({
|
|
282
|
+
name: `${name}.${SCOPE_SUFFIX}`,
|
|
283
|
+
match: `${IDENTIFIER_START}(?:${alternatives(values)})${IDENTIFIER_END}`,
|
|
284
|
+
});
|
|
285
|
+
const keywordPatterns = [
|
|
286
|
+
keywordRule(NUMERIC_KEYWORDS, 'constant.numeric.language'),
|
|
287
|
+
keywordRule(constantKeywords, 'constant.language'),
|
|
288
|
+
keywordRule(CONTROL_KEYWORDS, 'keyword.control'),
|
|
289
|
+
keywordRule(wordOperators, 'keyword.operator.wordlike'),
|
|
290
|
+
keywordRule(declarationKeywords, 'keyword.declaration'),
|
|
291
|
+
keywordRule(moduleKeywords, 'keyword.control.module'),
|
|
292
|
+
keywordRule(RESERVED_KEYWORDS, 'keyword.reserved'),
|
|
293
|
+
keywordRule(languageVariables, 'variable.language'),
|
|
294
|
+
keywordRule(otherKeywords, 'keyword.other'),
|
|
295
|
+
];
|
|
296
|
+
return {
|
|
297
|
+
source: {
|
|
298
|
+
patterns: [
|
|
299
|
+
{ include: '#comments' },
|
|
300
|
+
{ include: '#strings' },
|
|
301
|
+
{ include: '#function-declarations' },
|
|
302
|
+
{ include: '#module-declarations' },
|
|
303
|
+
{ include: '#for-bindings' },
|
|
304
|
+
{ include: '#record-properties' },
|
|
305
|
+
{ include: '#member-access' },
|
|
306
|
+
{ include: '#type-keyword' },
|
|
307
|
+
{ include: '#keywords' },
|
|
308
|
+
{ include: '#function-calls' },
|
|
309
|
+
{ include: '#numbers' },
|
|
310
|
+
{ include: '#identifiers' },
|
|
311
|
+
{ include: '#operators' },
|
|
312
|
+
{ include: '#punctuation' },
|
|
313
|
+
],
|
|
314
|
+
},
|
|
315
|
+
comments: {
|
|
316
|
+
patterns: [
|
|
317
|
+
{ name: `comment.line.double-slash.${SCOPE_SUFFIX}`, match: '//.*$' },
|
|
318
|
+
{
|
|
319
|
+
name: `comment.block.documentation.${SCOPE_SUFFIX}`,
|
|
320
|
+
begin: String.raw `/\*\*`,
|
|
321
|
+
end: String.raw `\*/`,
|
|
322
|
+
},
|
|
323
|
+
{ name: `comment.block.${SCOPE_SUFFIX}`, begin: String.raw `/\*`, end: String.raw `\*/` },
|
|
324
|
+
],
|
|
325
|
+
},
|
|
326
|
+
...documentationRepository(),
|
|
327
|
+
'format-content': {
|
|
328
|
+
patterns: [
|
|
329
|
+
{ name: `constant.character.escape.format.${SCOPE_SUFFIX}`, match: String.raw `\\.` },
|
|
330
|
+
{
|
|
331
|
+
begin: String.raw `\[`,
|
|
332
|
+
end: String.raw `\]`,
|
|
333
|
+
name: `string.unquoted.format.character-class.${SCOPE_SUFFIX}`,
|
|
334
|
+
patterns: [{ name: `constant.character.escape.format.${SCOPE_SUFFIX}`, match: String.raw `\\.` }],
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
begin: String.raw `\(`,
|
|
338
|
+
end: String.raw `\)`,
|
|
339
|
+
name: `string.unquoted.format.group.${SCOPE_SUFFIX}`,
|
|
340
|
+
patterns: [{ include: '#format-content' }],
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
},
|
|
344
|
+
strings: { patterns: stringPatterns() },
|
|
345
|
+
'function-declarations': {
|
|
346
|
+
patterns: [
|
|
347
|
+
{
|
|
348
|
+
name: `meta.function.declaration.${SCOPE_SUFFIX}`,
|
|
349
|
+
begin: String.raw `${IDENTIFIER_START}(fn)(\s+)(${IDENTIFIER})(\s*)(\()`,
|
|
350
|
+
beginCaptures: {
|
|
351
|
+
1: { name: `keyword.declaration.function.${SCOPE_SUFFIX}` },
|
|
352
|
+
3: { name: `entity.name.function.${SCOPE_SUFFIX}` },
|
|
353
|
+
5: { name: `punctuation.section.parameters.begin.${SCOPE_SUFFIX}` },
|
|
354
|
+
},
|
|
355
|
+
end: String.raw `\)`,
|
|
356
|
+
endCaptures: { 0: { name: `punctuation.section.parameters.end.${SCOPE_SUFFIX}` } },
|
|
357
|
+
patterns: [{ include: '#parameters' }],
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
name: `meta.function.declaration.${SCOPE_SUFFIX}`,
|
|
361
|
+
match: String.raw `${IDENTIFIER_START}(fn)(\s+)(${IDENTIFIER})`,
|
|
362
|
+
captures: {
|
|
363
|
+
1: { name: `keyword.declaration.function.${SCOPE_SUFFIX}` },
|
|
364
|
+
3: { name: `entity.name.function.${SCOPE_SUFFIX}` },
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
name: `meta.function.expression.parameters.${SCOPE_SUFFIX}`,
|
|
369
|
+
begin: String.raw `${IDENTIFIER_START}(fn)(\s*)(\()`,
|
|
370
|
+
beginCaptures: {
|
|
371
|
+
1: { name: `keyword.declaration.function.${SCOPE_SUFFIX}` },
|
|
372
|
+
3: { name: `punctuation.section.parameters.begin.${SCOPE_SUFFIX}` },
|
|
373
|
+
},
|
|
374
|
+
end: String.raw `\)`,
|
|
375
|
+
endCaptures: { 0: { name: `punctuation.section.parameters.end.${SCOPE_SUFFIX}` } },
|
|
376
|
+
patterns: [{ include: '#parameters' }],
|
|
377
|
+
},
|
|
378
|
+
],
|
|
379
|
+
},
|
|
380
|
+
parameters: {
|
|
381
|
+
patterns: [
|
|
382
|
+
{
|
|
383
|
+
match: String.raw `${IDENTIFIER_START}(mut)(\s+)(${IDENTIFIER})`,
|
|
384
|
+
captures: {
|
|
385
|
+
1: { name: `keyword.declaration.mutable.${SCOPE_SUFFIX}` },
|
|
386
|
+
3: { name: `variable.emphasis.${SCOPE_SUFFIX}` },
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
name: `keyword.declaration.mutable.${SCOPE_SUFFIX}`,
|
|
391
|
+
match: `${IDENTIFIER_START}mut${IDENTIFIER_END}`,
|
|
392
|
+
},
|
|
393
|
+
{ name: `keyword.operator.spread.${SCOPE_SUFFIX}`, match: String.raw `\.\.` },
|
|
394
|
+
{ name: `variable.other.constant.emphasis.${SCOPE_SUFFIX}`, match: IDENTIFIER },
|
|
395
|
+
{ name: `punctuation.separator.parameter.${SCOPE_SUFFIX}`, match: ',' },
|
|
396
|
+
{
|
|
397
|
+
begin: String.raw `\(`,
|
|
398
|
+
end: String.raw `\)`,
|
|
399
|
+
patterns: [{ include: '#parameters' }],
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
begin: String.raw `\[`,
|
|
403
|
+
end: String.raw `\]`,
|
|
404
|
+
patterns: [{ include: '#parameters' }],
|
|
405
|
+
},
|
|
406
|
+
{ include: '#record-properties' },
|
|
407
|
+
],
|
|
408
|
+
},
|
|
409
|
+
'module-declarations': {
|
|
410
|
+
patterns: [
|
|
411
|
+
{
|
|
412
|
+
match: String.raw `${IDENTIFIER_START}(mod)(\s+)(${IDENTIFIER})`,
|
|
413
|
+
captures: {
|
|
414
|
+
1: { name: `keyword.control.module.${SCOPE_SUFFIX}` },
|
|
415
|
+
3: { name: `entity.name.namespace.${SCOPE_SUFFIX}` },
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
],
|
|
419
|
+
},
|
|
420
|
+
'for-bindings': {
|
|
421
|
+
patterns: [
|
|
422
|
+
{
|
|
423
|
+
match: String.raw `${IDENTIFIER_START}(for)(\s+)(mut)(\s+)(${IDENTIFIER})(\s+)(in)${IDENTIFIER_END}`,
|
|
424
|
+
captures: {
|
|
425
|
+
1: { name: `keyword.control.loop.${SCOPE_SUFFIX}` },
|
|
426
|
+
3: { name: `keyword.declaration.mutable.${SCOPE_SUFFIX}` },
|
|
427
|
+
5: { name: `variable.other.readwrite.${SCOPE_SUFFIX}` },
|
|
428
|
+
7: { name: `keyword.control.loop.${SCOPE_SUFFIX}` },
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
match: String.raw `${IDENTIFIER_START}(for)(\s+)(${IDENTIFIER})(\s+)(in)${IDENTIFIER_END}`,
|
|
433
|
+
captures: {
|
|
434
|
+
1: { name: `keyword.control.loop.${SCOPE_SUFFIX}` },
|
|
435
|
+
3: { name: `variable.other.${SCOPE_SUFFIX}` },
|
|
436
|
+
5: { name: `keyword.control.loop.${SCOPE_SUFFIX}` },
|
|
437
|
+
},
|
|
438
|
+
},
|
|
439
|
+
],
|
|
440
|
+
},
|
|
441
|
+
'record-properties': {
|
|
442
|
+
patterns: [
|
|
443
|
+
{
|
|
444
|
+
match: String.raw `(${IDENTIFIER})(\s*)(\??:)(?!:)`,
|
|
445
|
+
captures: {
|
|
446
|
+
1: { name: `variable.other.property.${SCOPE_SUFFIX}` },
|
|
447
|
+
3: { name: `punctuation.separator.key-value.${SCOPE_SUFFIX}` },
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
],
|
|
451
|
+
},
|
|
452
|
+
'member-access': {
|
|
453
|
+
patterns: [
|
|
454
|
+
{
|
|
455
|
+
match: String.raw `(\.)(\s*)(\d+)`,
|
|
456
|
+
captures: {
|
|
457
|
+
1: { name: `punctuation.accessor.${SCOPE_SUFFIX}` },
|
|
458
|
+
3: { name: `variable.other.property.${SCOPE_SUFFIX}` },
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
match: `(\\.)(\\s*)(${IDENTIFIER})(\\s*)(!?)(?=\\s*(?:\\(|@*["'\`]))`,
|
|
463
|
+
captures: {
|
|
464
|
+
1: { name: `punctuation.accessor.${SCOPE_SUFFIX}` },
|
|
465
|
+
3: { name: `entity.name.function.member.${SCOPE_SUFFIX}` },
|
|
466
|
+
5: { name: `keyword.operator.non-null.${SCOPE_SUFFIX}` },
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
match: String.raw `(\.)(\s*)(${IDENTIFIER})`,
|
|
471
|
+
captures: {
|
|
472
|
+
1: { name: `punctuation.accessor.${SCOPE_SUFFIX}` },
|
|
473
|
+
3: { name: `variable.other.property.${SCOPE_SUFFIX}` },
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
],
|
|
477
|
+
},
|
|
478
|
+
'function-calls': {
|
|
479
|
+
patterns: [
|
|
480
|
+
{
|
|
481
|
+
match: `(${IDENTIFIER})(\\s*)(!?)(?=\\s*(?:\\(|@*["'\`]))`,
|
|
482
|
+
captures: {
|
|
483
|
+
1: { name: `entity.name.function.${SCOPE_SUFFIX}` },
|
|
484
|
+
3: { name: `keyword.operator.non-null.${SCOPE_SUFFIX}` },
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
],
|
|
488
|
+
},
|
|
489
|
+
'type-keyword': {
|
|
490
|
+
patterns: [
|
|
491
|
+
{
|
|
492
|
+
name: `keyword.operator.expression.${SCOPE_SUFFIX}`,
|
|
493
|
+
match: String.raw `${IDENTIFIER_START}type${IDENTIFIER_END}(?=\s*\(|\s+${IDENTIFIER})`,
|
|
494
|
+
},
|
|
495
|
+
],
|
|
496
|
+
},
|
|
497
|
+
numbers: {
|
|
498
|
+
patterns: [
|
|
499
|
+
{
|
|
500
|
+
name: `constant.numeric.hex.${SCOPE_SUFFIX}`,
|
|
501
|
+
match: `0[xX][0-9A-Fa-f](?:[0-9A-Fa-f_]*[0-9A-Fa-f])?${IDENTIFIER_END}`,
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
name: `constant.numeric.octal.${SCOPE_SUFFIX}`,
|
|
505
|
+
match: `0[oO][0-7](?:[0-7_]*[0-7])?${IDENTIFIER_END}`,
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
name: `constant.numeric.binary.${SCOPE_SUFFIX}`,
|
|
509
|
+
match: `0[bB][01](?:[01_]*[01])?${IDENTIFIER_END}`,
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
name: `invalid.illegal.numeric.${SCOPE_SUFFIX}`,
|
|
513
|
+
match: String.raw `0[xXoObB]\p{XID_Continue}*`,
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
name: `constant.numeric.float.${SCOPE_SUFFIX}`,
|
|
517
|
+
match: String.raw `\d[\d_]*(?:\.[\d_]+)?(?:[eE][+-]?[\d_]*\d)?${IDENTIFIER_END}`,
|
|
518
|
+
},
|
|
519
|
+
],
|
|
520
|
+
},
|
|
521
|
+
keywords: { patterns: keywordPatterns },
|
|
522
|
+
identifiers: {
|
|
523
|
+
patterns: [
|
|
524
|
+
{ name: `variable.other.constant.${SCOPE_SUFFIX}`, match: String.raw `@+\p{XID_Continue}+` },
|
|
525
|
+
{ name: `variable.other.${SCOPE_SUFFIX}`, match: IDENTIFIER },
|
|
526
|
+
],
|
|
527
|
+
},
|
|
528
|
+
operators: {
|
|
529
|
+
patterns: [
|
|
530
|
+
{ name: `keyword.operator.spread.${SCOPE_SUFFIX}`, match: String.raw `\.\.<|\.\.` },
|
|
531
|
+
{ name: `keyword.operator.bind.${SCOPE_SUFFIX}`, match: '::' },
|
|
532
|
+
{ name: `keyword.operator.conditional.${SCOPE_SUFFIX}`, match: String.raw `\?:` },
|
|
533
|
+
{
|
|
534
|
+
name: `keyword.operator.assignment.${SCOPE_SUFFIX}`,
|
|
535
|
+
match: String.raw `&&=|\|\|=|\?\?=|\+=|-=|\*=|/=|%=|\^=|=`,
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
name: `keyword.operator.comparison.${SCOPE_SUFFIX}`,
|
|
539
|
+
match: '===|!==|>=|<=|==|!=|=~|!~|>|<',
|
|
540
|
+
},
|
|
541
|
+
{ name: `keyword.operator.logical.${SCOPE_SUFFIX}`, match: String.raw `&&|\|\||\?\?|!` },
|
|
542
|
+
{ name: `keyword.operator.arithmetic.${SCOPE_SUFFIX}`, match: String.raw `\+|-|\*|/|%|\^` },
|
|
543
|
+
],
|
|
544
|
+
},
|
|
545
|
+
punctuation: {
|
|
546
|
+
patterns: [
|
|
547
|
+
{ name: `punctuation.section.braces.${SCOPE_SUFFIX}`, match: '[{}]' },
|
|
548
|
+
{ name: `punctuation.section.brackets.${SCOPE_SUFFIX}`, match: String.raw `[\[\]]` },
|
|
549
|
+
{ name: `punctuation.section.parens.${SCOPE_SUFFIX}`, match: '[()]' },
|
|
550
|
+
{ name: `punctuation.separator.${SCOPE_SUFFIX}`, match: '[,;:]' },
|
|
551
|
+
{ name: `punctuation.accessor.${SCOPE_SUFFIX}`, match: String.raw `\.` },
|
|
552
|
+
],
|
|
553
|
+
},
|
|
554
|
+
'braced-content': {
|
|
555
|
+
patterns: [
|
|
556
|
+
{ begin: String.raw `\{`, end: String.raw `\}`, patterns: [{ include: '#braced-content' }] },
|
|
557
|
+
{ begin: String.raw `\(`, end: String.raw `\)`, patterns: [{ include: '#parenthesized-content' }] },
|
|
558
|
+
{ begin: String.raw `\[`, end: String.raw `\]`, patterns: [{ include: '#bracketed-content' }] },
|
|
559
|
+
{ include: '#source' },
|
|
560
|
+
],
|
|
561
|
+
},
|
|
562
|
+
'interpolation-expression-content': {
|
|
563
|
+
patterns: [
|
|
564
|
+
{ begin: String.raw `\(`, end: String.raw `\)`, patterns: [{ include: '#parenthesized-content' }] },
|
|
565
|
+
{ begin: String.raw `\{`, end: String.raw `\}`, patterns: [{ include: '#braced-content' }] },
|
|
566
|
+
{ begin: String.raw `\[`, end: String.raw `\]`, patterns: [{ include: '#bracketed-content' }] },
|
|
567
|
+
{ include: '#comments' },
|
|
568
|
+
{ include: '#strings' },
|
|
569
|
+
{ include: '#function-declarations' },
|
|
570
|
+
{ include: '#module-declarations' },
|
|
571
|
+
{ include: '#for-bindings' },
|
|
572
|
+
{ include: '#member-access' },
|
|
573
|
+
{ include: '#type-keyword' },
|
|
574
|
+
{ include: '#keywords' },
|
|
575
|
+
{ include: '#function-calls' },
|
|
576
|
+
{ include: '#numbers' },
|
|
577
|
+
{ include: '#identifiers' },
|
|
578
|
+
{ include: '#operators' },
|
|
579
|
+
{ include: '#punctuation' },
|
|
580
|
+
],
|
|
581
|
+
},
|
|
582
|
+
'parenthesized-content': {
|
|
583
|
+
patterns: [
|
|
584
|
+
{ begin: String.raw `\(`, end: String.raw `\)`, patterns: [{ include: '#parenthesized-content' }] },
|
|
585
|
+
{ begin: String.raw `\{`, end: String.raw `\}`, patterns: [{ include: '#braced-content' }] },
|
|
586
|
+
{ begin: String.raw `\[`, end: String.raw `\]`, patterns: [{ include: '#bracketed-content' }] },
|
|
587
|
+
{ include: '#source' },
|
|
588
|
+
],
|
|
589
|
+
},
|
|
590
|
+
'bracketed-content': {
|
|
591
|
+
patterns: [
|
|
592
|
+
{ begin: String.raw `\[`, end: String.raw `\]`, patterns: [{ include: '#bracketed-content' }] },
|
|
593
|
+
{ begin: String.raw `\{`, end: String.raw `\}`, patterns: [{ include: '#braced-content' }] },
|
|
594
|
+
{ begin: String.raw `\(`, end: String.raw `\)`, patterns: [{ include: '#parenthesized-content' }] },
|
|
595
|
+
{ include: '#source' },
|
|
596
|
+
],
|
|
597
|
+
},
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Create the ordinary MiraScript TextMate grammar.
|
|
602
|
+
*/
|
|
603
|
+
export function createMiraScriptGrammar() {
|
|
604
|
+
return {
|
|
605
|
+
...mirascriptLanguage,
|
|
606
|
+
patterns: [{ include: '#source' }],
|
|
607
|
+
repository: sourceRepository(),
|
|
608
|
+
injections: {
|
|
609
|
+
[documentationInjectionSelector]: {
|
|
610
|
+
patterns: [{ include: '#documentation' }],
|
|
611
|
+
},
|
|
612
|
+
},
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Create the MiraScript template TextMate grammar.
|
|
617
|
+
*/
|
|
618
|
+
export function createMiraScriptTemplateGrammar() {
|
|
619
|
+
return {
|
|
620
|
+
...mirascriptTemplateLanguage,
|
|
621
|
+
patterns: [
|
|
622
|
+
...interpolationPatterns(1),
|
|
623
|
+
{ name: 'string.unquoted.template.mira', match: '[^$]+' },
|
|
624
|
+
{ name: 'string.unquoted.template.mira', match: String.raw `\$` },
|
|
625
|
+
],
|
|
626
|
+
repository: sourceRepository(),
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Create the generated-document and type-signature TextMate grammar.
|
|
631
|
+
*/
|
|
632
|
+
export function createMiraScriptDocGrammar() {
|
|
633
|
+
return {
|
|
634
|
+
...mirascriptDocLanguage,
|
|
635
|
+
patterns: [{ include: '#doc' }],
|
|
636
|
+
injections: {
|
|
637
|
+
[documentationInjectionSelector]: {
|
|
638
|
+
patterns: [{ include: '#documentation' }],
|
|
639
|
+
},
|
|
640
|
+
},
|
|
641
|
+
repository: {
|
|
642
|
+
...documentationRepository('source.mira#source'),
|
|
643
|
+
doc: {
|
|
644
|
+
patterns: [
|
|
645
|
+
{ include: '#tag' },
|
|
646
|
+
{ include: '#global-value' },
|
|
647
|
+
{ include: '#global-constants' },
|
|
648
|
+
{ include: '#inline-parameter' },
|
|
649
|
+
{ include: '#properties' },
|
|
650
|
+
{ include: '#inline-label' },
|
|
651
|
+
{ include: '#binding-value' },
|
|
652
|
+
{ include: '#bindings' },
|
|
653
|
+
{ include: '#function-signatures' },
|
|
654
|
+
{ include: '#generic-types' },
|
|
655
|
+
{ include: '#parameters' },
|
|
656
|
+
{ include: '#return-type' },
|
|
657
|
+
{ include: '#tag-comment' },
|
|
658
|
+
{ include: 'source.mira' },
|
|
659
|
+
],
|
|
660
|
+
},
|
|
661
|
+
tag: {
|
|
662
|
+
patterns: [
|
|
663
|
+
{
|
|
664
|
+
name: 'meta.documentation.tag.mira',
|
|
665
|
+
contentName: 'meta.documentation.tag.content.mira',
|
|
666
|
+
begin: `(<)(?=${DOC_TAG_CONTENT}>)`,
|
|
667
|
+
beginCaptures: { 1: { name: 'punctuation.definition.tag.begin.mira' } },
|
|
668
|
+
end: '(>)',
|
|
669
|
+
endCaptures: { 1: { name: 'punctuation.definition.tag.end.mira' } },
|
|
670
|
+
patterns: [{ include: '#tag-content' }],
|
|
671
|
+
},
|
|
672
|
+
],
|
|
673
|
+
},
|
|
674
|
+
'global-value': {
|
|
675
|
+
patterns: [
|
|
676
|
+
{
|
|
677
|
+
name: 'meta.documentation.global-value.mira',
|
|
678
|
+
begin: String.raw `^(\x00)?(\(global\))(\s+)(${IDENTIFIER})(\s*)(=)`,
|
|
679
|
+
beginCaptures: {
|
|
680
|
+
2: { name: 'entity.name.label.mira' },
|
|
681
|
+
4: { name: 'variable.other.mira' },
|
|
682
|
+
6: { name: 'keyword.operator.assignment.mira' },
|
|
683
|
+
},
|
|
684
|
+
end: '$',
|
|
685
|
+
patterns: [{ include: '#doc-value' }],
|
|
686
|
+
},
|
|
687
|
+
],
|
|
688
|
+
},
|
|
689
|
+
'global-constants': {
|
|
690
|
+
patterns: [
|
|
691
|
+
{
|
|
692
|
+
match: String.raw `^(\x00)?(\(global\))(\s+)(${DOC_CONSTANT_IDENTIFIER})(?=\s*(?:=|;|$))`,
|
|
693
|
+
captures: {
|
|
694
|
+
2: { name: 'entity.name.label.mira' },
|
|
695
|
+
4: { name: 'variable.other.constant.mira' },
|
|
696
|
+
},
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
match: String.raw `^(\x00)?(${DOC_CONSTANT_IDENTIFIER})(?=\s*(?:=|;|$))`,
|
|
700
|
+
captures: { 2: { name: 'variable.other.constant.mira' } },
|
|
701
|
+
},
|
|
702
|
+
],
|
|
703
|
+
},
|
|
704
|
+
'inline-parameter': {
|
|
705
|
+
patterns: [
|
|
706
|
+
{
|
|
707
|
+
match: String.raw `^(\x00)?(\(parameter(?:\s+pattern)?\))(\s+)(\.\.)?(mut)(\s+)(${IDENTIFIER})`,
|
|
708
|
+
captures: {
|
|
709
|
+
2: { name: 'entity.name.label.mira' },
|
|
710
|
+
4: { name: 'keyword.operator.spread.mira' },
|
|
711
|
+
5: { name: 'keyword.declaration.mutable.mira' },
|
|
712
|
+
7: { name: 'variable.emphasis.mira' },
|
|
713
|
+
},
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
match: String.raw `^(\x00)?(\(parameter(?:\s+pattern)?\))(\s+)(\.\.)?(\s*)(${IDENTIFIER})`,
|
|
717
|
+
captures: {
|
|
718
|
+
2: { name: 'entity.name.label.mira' },
|
|
719
|
+
4: { name: 'keyword.operator.spread.mira' },
|
|
720
|
+
6: { name: 'variable.other.constant.emphasis.mira' },
|
|
721
|
+
},
|
|
722
|
+
},
|
|
723
|
+
],
|
|
724
|
+
},
|
|
725
|
+
'inline-label': {
|
|
726
|
+
patterns: [
|
|
727
|
+
{
|
|
728
|
+
match: String.raw `^(\x00)?(\([^():,\[\]<>|&\r\n]+\))(?=\s+\S)`,
|
|
729
|
+
captures: { 2: { name: 'entity.name.label.mira' } },
|
|
730
|
+
},
|
|
731
|
+
],
|
|
732
|
+
},
|
|
733
|
+
bindings: {
|
|
734
|
+
patterns: [
|
|
735
|
+
{
|
|
736
|
+
match: String.raw `${IDENTIFIER_START}(let)(\s+)(mut)(\s+)(${IDENTIFIER})`,
|
|
737
|
+
captures: {
|
|
738
|
+
1: { name: 'keyword.declaration.variable.mira' },
|
|
739
|
+
3: { name: 'keyword.declaration.mutable.mira' },
|
|
740
|
+
5: { name: 'variable.other.readwrite.mira' },
|
|
741
|
+
},
|
|
742
|
+
},
|
|
743
|
+
{
|
|
744
|
+
match: String.raw `${IDENTIFIER_START}(let|const)(\s+)(${IDENTIFIER})`,
|
|
745
|
+
captures: {
|
|
746
|
+
1: { name: 'keyword.declaration.variable.mira' },
|
|
747
|
+
3: { name: 'variable.other.constant.mira' },
|
|
748
|
+
},
|
|
749
|
+
},
|
|
750
|
+
],
|
|
751
|
+
},
|
|
752
|
+
'binding-value': {
|
|
753
|
+
patterns: [
|
|
754
|
+
{
|
|
755
|
+
begin: String.raw `${IDENTIFIER_START}(let)(\s+)(mut)(\s+)(${IDENTIFIER})(\s*)(=)`,
|
|
756
|
+
beginCaptures: {
|
|
757
|
+
1: { name: 'keyword.declaration.variable.mira' },
|
|
758
|
+
3: { name: 'keyword.declaration.mutable.mira' },
|
|
759
|
+
5: { name: 'variable.other.readwrite.mira' },
|
|
760
|
+
7: { name: 'keyword.operator.assignment.mira' },
|
|
761
|
+
},
|
|
762
|
+
end: '$',
|
|
763
|
+
patterns: [{ include: '#doc-value' }],
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
begin: String.raw `${IDENTIFIER_START}(let|const)(\s+)(${IDENTIFIER})(\s*)(=)`,
|
|
767
|
+
beginCaptures: {
|
|
768
|
+
1: { name: 'keyword.declaration.variable.mira' },
|
|
769
|
+
3: { name: 'variable.other.constant.mira' },
|
|
770
|
+
5: { name: 'keyword.operator.assignment.mira' },
|
|
771
|
+
},
|
|
772
|
+
end: '$',
|
|
773
|
+
patterns: [{ include: '#doc-value' }],
|
|
774
|
+
},
|
|
775
|
+
],
|
|
776
|
+
},
|
|
777
|
+
'function-signatures': {
|
|
778
|
+
patterns: [
|
|
779
|
+
{
|
|
780
|
+
match: String.raw `${IDENTIFIER_START}(?:(pub)(\s+))?(fn)(\s+)(${IDENTIFIER})(?=\s*(?:<|\())`,
|
|
781
|
+
captures: {
|
|
782
|
+
1: { name: 'keyword.control.module.mira' },
|
|
783
|
+
3: { name: 'keyword.declaration.function.mira' },
|
|
784
|
+
5: { name: 'entity.name.function.mira' },
|
|
785
|
+
},
|
|
786
|
+
},
|
|
787
|
+
],
|
|
788
|
+
},
|
|
789
|
+
properties: {
|
|
790
|
+
patterns: [
|
|
791
|
+
{
|
|
792
|
+
name: 'meta.documentation.field.mira',
|
|
793
|
+
begin: String.raw `^(\x00)?(?:(\(field\))(\s+))?(${DOC_FIELD_NAME})(\s*)(\??:)(?=[ \t]*/\*[ \t]*<extern[ \t]+(?:(?:async[ \t]+)?function\*?)(?:[ \t]+${DOC_TAG_NAME})?>[ \t]*\*/)`,
|
|
794
|
+
beginCaptures: {
|
|
795
|
+
2: { name: 'entity.name.label.mira' },
|
|
796
|
+
4: { name: 'entity.name.function.mira' },
|
|
797
|
+
6: { name: 'punctuation.separator.type.mira' },
|
|
798
|
+
},
|
|
799
|
+
end: '$',
|
|
800
|
+
patterns: [
|
|
801
|
+
{ include: '#tag-comment' },
|
|
802
|
+
{ include: '#tag' },
|
|
803
|
+
{ include: '#doc-record-value' },
|
|
804
|
+
{ include: '#doc-array-value' },
|
|
805
|
+
{ include: '#type-context' },
|
|
806
|
+
],
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
name: 'meta.documentation.field.mira',
|
|
810
|
+
begin: String.raw `^(\x00)?(?:(\(field\))(\s+))?(${DOC_FIELD_NAME})(\s*)(\??:)(?=[ \t]*/\*[ \t]*<extern[ \t]+class(?:[ \t]+${DOC_TAG_NAME})?>[ \t]*\*/)`,
|
|
811
|
+
beginCaptures: {
|
|
812
|
+
2: { name: 'entity.name.label.mira' },
|
|
813
|
+
4: { name: 'entity.name.type.mira' },
|
|
814
|
+
6: { name: 'punctuation.separator.type.mira' },
|
|
815
|
+
},
|
|
816
|
+
end: '$',
|
|
817
|
+
patterns: [
|
|
818
|
+
{ include: '#tag-comment' },
|
|
819
|
+
{ include: '#tag' },
|
|
820
|
+
{ include: '#doc-record-value' },
|
|
821
|
+
{ include: '#doc-array-value' },
|
|
822
|
+
{ include: '#type-context' },
|
|
823
|
+
],
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
name: 'meta.documentation.field.mira',
|
|
827
|
+
begin: String.raw `^(\x00)?(?:(\(field\))(\s+))?(${DOC_FIELD_NAME})(\s*)(\??:)`,
|
|
828
|
+
beginCaptures: {
|
|
829
|
+
2: { name: 'entity.name.label.mira' },
|
|
830
|
+
4: { name: 'variable.other.property.mira' },
|
|
831
|
+
6: { name: 'punctuation.separator.type.mira' },
|
|
832
|
+
},
|
|
833
|
+
end: '$',
|
|
834
|
+
patterns: [
|
|
835
|
+
{ include: '#tag-comment' },
|
|
836
|
+
{ include: '#tag' },
|
|
837
|
+
{ include: '#doc-record-value' },
|
|
838
|
+
{ include: '#doc-array-value' },
|
|
839
|
+
{ include: '#type-context' },
|
|
840
|
+
],
|
|
841
|
+
},
|
|
842
|
+
],
|
|
843
|
+
},
|
|
844
|
+
'doc-value': {
|
|
845
|
+
patterns: [
|
|
846
|
+
{ include: '#tag-properties' },
|
|
847
|
+
{ include: '#tag-comment' },
|
|
848
|
+
{ include: '#tag' },
|
|
849
|
+
{ include: '#doc-record-value' },
|
|
850
|
+
{ include: '#doc-array-value' },
|
|
851
|
+
{ include: 'source.mira' },
|
|
852
|
+
],
|
|
853
|
+
},
|
|
854
|
+
'doc-record-value': {
|
|
855
|
+
patterns: [
|
|
856
|
+
{
|
|
857
|
+
begin: String.raw `\(`,
|
|
858
|
+
beginCaptures: { 0: { name: 'punctuation.section.parens.begin.mira' } },
|
|
859
|
+
end: String.raw `\)`,
|
|
860
|
+
endCaptures: { 0: { name: 'punctuation.section.parens.end.mira' } },
|
|
861
|
+
patterns: [{ include: '#doc-value' }],
|
|
862
|
+
},
|
|
863
|
+
],
|
|
864
|
+
},
|
|
865
|
+
'doc-array-value': {
|
|
866
|
+
patterns: [
|
|
867
|
+
{
|
|
868
|
+
begin: String.raw `\[`,
|
|
869
|
+
beginCaptures: { 0: { name: 'punctuation.section.brackets.begin.mira' } },
|
|
870
|
+
end: String.raw `\]`,
|
|
871
|
+
endCaptures: { 0: { name: 'punctuation.section.brackets.end.mira' } },
|
|
872
|
+
patterns: [{ include: '#doc-value' }],
|
|
873
|
+
},
|
|
874
|
+
],
|
|
875
|
+
},
|
|
876
|
+
'tag-properties': {
|
|
877
|
+
patterns: [
|
|
878
|
+
{
|
|
879
|
+
match: String.raw `(${DOC_FIELD_NAME})(\s*)(:)(?=[ \t]*/\*[ \t]*<extern[ \t]+(?:(?:async[ \t]+)?function\*?)(?:[ \t]+${DOC_TAG_NAME})?>[ \t]*\*/)`,
|
|
880
|
+
captures: {
|
|
881
|
+
1: { name: 'entity.name.function.mira' },
|
|
882
|
+
3: { name: 'punctuation.separator.key-value.mira' },
|
|
883
|
+
},
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
match: String.raw `(${DOC_FIELD_NAME})(\s*)(:)(?=[ \t]*/\*[ \t]*<extern[ \t]+class(?:[ \t]+${DOC_TAG_NAME})?>[ \t]*\*/)`,
|
|
887
|
+
captures: {
|
|
888
|
+
1: { name: 'entity.name.type.mira' },
|
|
889
|
+
3: { name: 'punctuation.separator.key-value.mira' },
|
|
890
|
+
},
|
|
891
|
+
},
|
|
892
|
+
],
|
|
893
|
+
},
|
|
894
|
+
'tag-comment': {
|
|
895
|
+
patterns: [
|
|
896
|
+
{
|
|
897
|
+
name: 'comment.block.mira',
|
|
898
|
+
contentName: 'meta.documentation.tag.mira',
|
|
899
|
+
begin: String.raw `(/\*)([ \t]*)(<)(?=${DOC_TAG_CONTENT}>[ \t]*\*/)`,
|
|
900
|
+
beginCaptures: {
|
|
901
|
+
1: { name: 'punctuation.definition.comment.begin.mira' },
|
|
902
|
+
3: { name: 'punctuation.definition.tag.begin.mira' },
|
|
903
|
+
},
|
|
904
|
+
end: String.raw `(>)([ \t]*)(\*/)`,
|
|
905
|
+
endCaptures: {
|
|
906
|
+
1: { name: 'punctuation.definition.tag.end.mira' },
|
|
907
|
+
3: { name: 'punctuation.definition.comment.end.mira' },
|
|
908
|
+
},
|
|
909
|
+
patterns: [{ include: '#tag-content' }],
|
|
910
|
+
},
|
|
911
|
+
],
|
|
912
|
+
},
|
|
913
|
+
'tag-content': {
|
|
914
|
+
patterns: [
|
|
915
|
+
{
|
|
916
|
+
match: String.raw `(extern)([ \t]+)(?:(async)([ \t]+))?(function)(\*)?(?:([ \t]+)(${DOC_TAG_NAME}))?(?=>)`,
|
|
917
|
+
captures: {
|
|
918
|
+
1: { name: 'keyword.declaration.extern.mira' },
|
|
919
|
+
3: { name: 'keyword.js' },
|
|
920
|
+
5: { name: 'keyword.js' },
|
|
921
|
+
6: { name: 'keyword.operator.generator.js' },
|
|
922
|
+
8: { name: 'entity.name.function.js' },
|
|
923
|
+
},
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
match: String.raw `(extern)([ \t]+)(class)(?:([ \t]+)(${DOC_TAG_NAME}))?(?=>)`,
|
|
927
|
+
captures: {
|
|
928
|
+
1: { name: 'keyword.declaration.extern.mira' },
|
|
929
|
+
3: { name: 'keyword.js' },
|
|
930
|
+
5: { name: 'entity.name.type.js' },
|
|
931
|
+
},
|
|
932
|
+
},
|
|
933
|
+
{
|
|
934
|
+
match: String.raw `(extern)([ \t]+)(${DOC_TAG_NAME})(\()(${DOC_TAG_NUMBER})(\))(?=>)`,
|
|
935
|
+
captures: {
|
|
936
|
+
1: { name: 'keyword.declaration.extern.mira' },
|
|
937
|
+
3: { name: 'entity.name.type.js' },
|
|
938
|
+
4: { name: 'punctuation.section.parens.begin.mira' },
|
|
939
|
+
5: { name: 'constant.numeric.mira' },
|
|
940
|
+
6: { name: 'punctuation.section.parens.end.mira' },
|
|
941
|
+
},
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
match: String.raw `(extern)(?:([ \t]+)(${DOC_TAG_NAME}))?(?=>)`,
|
|
945
|
+
captures: {
|
|
946
|
+
1: { name: 'keyword.declaration.extern.mira' },
|
|
947
|
+
3: { name: 'entity.name.type.js' },
|
|
948
|
+
},
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
match: String.raw `(module)(?:([ \t]+)(${DOC_TAG_NAME}))?(?=>)`,
|
|
952
|
+
captures: {
|
|
953
|
+
1: { name: 'keyword.declaration.module.mira' },
|
|
954
|
+
3: { name: 'entity.name.namespace.mira' },
|
|
955
|
+
},
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
match: String.raw `(function)(?:([ \t]+)(${DOC_TAG_NAME}))?(?=>)`,
|
|
959
|
+
captures: {
|
|
960
|
+
1: { name: 'keyword.declaration.function.mira' },
|
|
961
|
+
3: { name: 'entity.name.function.mira' },
|
|
962
|
+
},
|
|
963
|
+
},
|
|
964
|
+
],
|
|
965
|
+
},
|
|
966
|
+
'reflection-type': {
|
|
967
|
+
patterns: [
|
|
968
|
+
{
|
|
969
|
+
match: String.raw `${IDENTIFIER_START}(type)(\s*)(\()(\s*)(${IDENTIFIER})(\s*)(\))`,
|
|
970
|
+
captures: {
|
|
971
|
+
1: { name: 'support.type.type.mira' },
|
|
972
|
+
3: { name: 'punctuation.section.parens.begin.mira' },
|
|
973
|
+
5: { name: 'variable.other.mira' },
|
|
974
|
+
7: { name: 'punctuation.section.parens.end.mira' },
|
|
975
|
+
},
|
|
976
|
+
},
|
|
977
|
+
],
|
|
978
|
+
},
|
|
979
|
+
'type-context': {
|
|
980
|
+
patterns: [
|
|
981
|
+
{ include: '#reflection-type' },
|
|
982
|
+
{ include: '#function-type' },
|
|
983
|
+
{ include: '#generic-types' },
|
|
984
|
+
{ include: '#type-grouping' },
|
|
985
|
+
{ include: '#type-brackets' },
|
|
986
|
+
{ include: '#type-atoms' },
|
|
987
|
+
],
|
|
988
|
+
},
|
|
989
|
+
'function-type': {
|
|
990
|
+
patterns: [
|
|
991
|
+
{
|
|
992
|
+
begin: String.raw `${IDENTIFIER_START}(fn)${IDENTIFIER_END}(?=\s*(?:<|\())`,
|
|
993
|
+
beginCaptures: { 1: { name: 'support.type.function.mira' } },
|
|
994
|
+
end: String.raw `(?=\s*(?:,|\)|$))`,
|
|
995
|
+
patterns: [
|
|
996
|
+
{ include: '#generic-types' },
|
|
997
|
+
{ include: '#parameters' },
|
|
998
|
+
{ include: '#return-type' },
|
|
999
|
+
{ include: '#type-context' },
|
|
1000
|
+
],
|
|
1001
|
+
},
|
|
1002
|
+
],
|
|
1003
|
+
},
|
|
1004
|
+
'generic-types': {
|
|
1005
|
+
patterns: [
|
|
1006
|
+
{
|
|
1007
|
+
begin: '<',
|
|
1008
|
+
beginCaptures: { 0: { name: 'punctuation.definition.type-parameters.begin.mira' } },
|
|
1009
|
+
end: '>',
|
|
1010
|
+
endCaptures: { 0: { name: 'punctuation.definition.type-parameters.end.mira' } },
|
|
1011
|
+
patterns: [
|
|
1012
|
+
{ include: '#reflection-type' },
|
|
1013
|
+
{ include: '#function-type' },
|
|
1014
|
+
{ include: '#generic-types' },
|
|
1015
|
+
{ include: '#type-grouping' },
|
|
1016
|
+
{ include: '#type-brackets' },
|
|
1017
|
+
{ include: '#type-atoms' },
|
|
1018
|
+
],
|
|
1019
|
+
},
|
|
1020
|
+
],
|
|
1021
|
+
},
|
|
1022
|
+
parameters: {
|
|
1023
|
+
patterns: [
|
|
1024
|
+
{
|
|
1025
|
+
begin: String.raw `\(`,
|
|
1026
|
+
beginCaptures: { 0: { name: 'punctuation.section.parameters.begin.mira' } },
|
|
1027
|
+
end: String.raw `\)`,
|
|
1028
|
+
endCaptures: { 0: { name: 'punctuation.section.parameters.end.mira' } },
|
|
1029
|
+
patterns: [
|
|
1030
|
+
{
|
|
1031
|
+
begin: String.raw `(\.\.)?(\s*)(mut)?(\s*)(${IDENTIFIER})(\s*)(\??:)(?=\s*fn${IDENTIFIER_END})`,
|
|
1032
|
+
beginCaptures: {
|
|
1033
|
+
1: { name: 'keyword.operator.spread.mira' },
|
|
1034
|
+
3: { name: 'keyword.declaration.mutable.mira' },
|
|
1035
|
+
5: { name: 'entity.name.function.emphasis.mira' },
|
|
1036
|
+
7: { name: 'punctuation.separator.type.mira' },
|
|
1037
|
+
},
|
|
1038
|
+
end: String.raw `(?=,|\))`,
|
|
1039
|
+
patterns: [{ include: '#type-context' }],
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
begin: String.raw `(\.\.)?(\s*)(mut)?(\s*)(${IDENTIFIER})(\s*)(\??:)`,
|
|
1043
|
+
beginCaptures: {
|
|
1044
|
+
1: { name: 'keyword.operator.spread.mira' },
|
|
1045
|
+
3: { name: 'keyword.declaration.mutable.mira' },
|
|
1046
|
+
5: { name: 'variable.emphasis.mira' },
|
|
1047
|
+
7: { name: 'punctuation.separator.type.mira' },
|
|
1048
|
+
},
|
|
1049
|
+
end: String.raw `(?=,|\))`,
|
|
1050
|
+
patterns: [{ include: '#type-context' }],
|
|
1051
|
+
},
|
|
1052
|
+
{
|
|
1053
|
+
match: String.raw `(\.\.)?(\s*)(mut)(\s+)(${IDENTIFIER})`,
|
|
1054
|
+
captures: {
|
|
1055
|
+
1: { name: 'keyword.operator.spread.mira' },
|
|
1056
|
+
3: { name: 'keyword.declaration.mutable.mira' },
|
|
1057
|
+
5: { name: 'variable.emphasis.mira' },
|
|
1058
|
+
},
|
|
1059
|
+
},
|
|
1060
|
+
{ name: 'keyword.operator.spread.mira', match: String.raw `\.\.` },
|
|
1061
|
+
{ name: 'variable.emphasis.mira', match: IDENTIFIER },
|
|
1062
|
+
{ name: 'punctuation.separator.parameter.mira', match: ',' },
|
|
1063
|
+
],
|
|
1064
|
+
},
|
|
1065
|
+
],
|
|
1066
|
+
},
|
|
1067
|
+
'type-grouping': {
|
|
1068
|
+
patterns: [
|
|
1069
|
+
{
|
|
1070
|
+
begin: String.raw `\(`,
|
|
1071
|
+
beginCaptures: { 0: { name: 'punctuation.section.parens.begin.mira' } },
|
|
1072
|
+
end: String.raw `\)`,
|
|
1073
|
+
endCaptures: { 0: { name: 'punctuation.section.parens.end.mira' } },
|
|
1074
|
+
patterns: [
|
|
1075
|
+
{
|
|
1076
|
+
begin: String.raw `(${IDENTIFIER})(\s*)(\??:)`,
|
|
1077
|
+
beginCaptures: {
|
|
1078
|
+
1: { name: 'variable.other.property.mira' },
|
|
1079
|
+
3: { name: 'punctuation.separator.type.mira' },
|
|
1080
|
+
},
|
|
1081
|
+
end: String.raw `(?=,|\))`,
|
|
1082
|
+
patterns: [{ include: '#type-context' }],
|
|
1083
|
+
},
|
|
1084
|
+
{ include: '#type-context' },
|
|
1085
|
+
],
|
|
1086
|
+
},
|
|
1087
|
+
],
|
|
1088
|
+
},
|
|
1089
|
+
'type-brackets': {
|
|
1090
|
+
patterns: [
|
|
1091
|
+
{
|
|
1092
|
+
begin: String.raw `\[`,
|
|
1093
|
+
beginCaptures: { 0: { name: 'punctuation.section.brackets.begin.mira' } },
|
|
1094
|
+
end: String.raw `\]`,
|
|
1095
|
+
endCaptures: { 0: { name: 'punctuation.section.brackets.end.mira' } },
|
|
1096
|
+
patterns: [{ include: '#type-context' }],
|
|
1097
|
+
},
|
|
1098
|
+
],
|
|
1099
|
+
},
|
|
1100
|
+
'return-type': {
|
|
1101
|
+
patterns: [
|
|
1102
|
+
{
|
|
1103
|
+
begin: '->',
|
|
1104
|
+
beginCaptures: { 0: { name: 'keyword.operator.type.mira' } },
|
|
1105
|
+
end: String.raw `(?=,|\)|$)`,
|
|
1106
|
+
patterns: [{ include: '#type-context' }],
|
|
1107
|
+
},
|
|
1108
|
+
],
|
|
1109
|
+
},
|
|
1110
|
+
'type-atoms': {
|
|
1111
|
+
patterns: [
|
|
1112
|
+
{ include: '#reflection-type' },
|
|
1113
|
+
{
|
|
1114
|
+
name: 'support.type.builtin.mira',
|
|
1115
|
+
match: `${IDENTIFIER_START}(?:${alternatives(BUILT_IN_TYPES)})${IDENTIFIER_END}`,
|
|
1116
|
+
},
|
|
1117
|
+
{ name: 'keyword.operator.type.mira', match: '[&|]' },
|
|
1118
|
+
{ name: 'keyword.operator.spread.mira', match: String.raw `\.\.` },
|
|
1119
|
+
{ name: 'entity.name.type.mira', match: IDENTIFIER },
|
|
1120
|
+
{ name: 'punctuation.section.brackets.mira', match: String.raw `[\[\]]` },
|
|
1121
|
+
{ name: 'punctuation.separator.type.mira', match: '[,.?:]' },
|
|
1122
|
+
{ include: 'source.mira#strings' },
|
|
1123
|
+
{ include: 'source.mira#numbers' },
|
|
1124
|
+
],
|
|
1125
|
+
},
|
|
1126
|
+
},
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
//# sourceMappingURL=grammar.js.map
|