@exercism/codemirror-lang-yamlscript 0.0.0-stage → 1.0.0
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/LICENSE +21 -0
- package/README.md +135 -2
- package/dist/index.cjs +1410 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +1403 -0
- package/package.json +51 -4
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1410 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var lr = require('@lezer/lr');
|
|
4
|
+
var language = require('@codemirror/language');
|
|
5
|
+
var highlight = require('@lezer/highlight');
|
|
6
|
+
var autocomplete = require('@codemirror/autocomplete');
|
|
7
|
+
|
|
8
|
+
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
9
|
+
const indent = 87,
|
|
10
|
+
seqIndent = 88,
|
|
11
|
+
dedent = 89,
|
|
12
|
+
newline = 90,
|
|
13
|
+
compactStart = 91,
|
|
14
|
+
keyStart = 92,
|
|
15
|
+
seqDash = 93,
|
|
16
|
+
explicitKey = 94,
|
|
17
|
+
colon = 95,
|
|
18
|
+
doubleColon = 96,
|
|
19
|
+
chainColon = 97,
|
|
20
|
+
KeyOperator = 1,
|
|
21
|
+
BlockScalar = 2,
|
|
22
|
+
PlainScalar = 3,
|
|
23
|
+
callParen = 4,
|
|
24
|
+
ControlKeyword = 5;
|
|
25
|
+
|
|
26
|
+
// These tokenizers handle the YAML layer of YAMLScript, which a Lezer grammar
|
|
27
|
+
// can't describe on its own:
|
|
28
|
+
//
|
|
29
|
+
// - Indentation. Like Python's grammar, they give indent, dedent and newline
|
|
30
|
+
// tokens. A line that is more indented than its block, in a place where no
|
|
31
|
+
// new block can start, continues the expression before it, as YAML's
|
|
32
|
+
// multi-line plain scalars do.
|
|
33
|
+
// - Mapping keys. YAML reads a line as a mapping entry when it holds a ": "
|
|
34
|
+
// outside quotes and brackets. At the start of each entry the tokenizer
|
|
35
|
+
// reads ahead to the end of the line and gives a zero-width keyStart token
|
|
36
|
+
// if it finds one, so the parser knows to read a key.
|
|
37
|
+
// - The ":" and "::" that end a key, the ":" of `x:f` chains, the "- " of
|
|
38
|
+
// sequence items, "|" and ">" block scalars, and plain text in data mode.
|
|
39
|
+
//
|
|
40
|
+
// The rules follow Exercism's tree-sitter grammar for YAMLScript, which the
|
|
41
|
+
// representer uses.
|
|
42
|
+
const NEWLINE = 10, CR = 13, SPACE = 32, TAB = 9, HASH = 35, COLON = 58, DASH = 45, QUESTION = 63, PIPE = 124, GT = 62, PAREN_OPEN = 40, PAREN_CLOSE = 41, BRACKET_OPEN = 91, BRACKET_CLOSE = 93, BRACE_OPEN = 123, BRACE_CLOSE = 125, DOUBLE_QUOTE = 34, SINGLE_QUOTE = 39, BACKSLASH = 92, SLASH = 47, PLUS = 43;
|
|
43
|
+
const isLineEnd = (ch) => ch < 0 || ch == NEWLINE || ch == CR;
|
|
44
|
+
const isBlank = (ch) => ch == SPACE || ch == TAB || isLineEnd(ch);
|
|
45
|
+
const isIdentStart = (ch) => (ch >= 97 && ch <= 122) || (ch >= 65 && ch <= 90) || ch == 95;
|
|
46
|
+
const isIdentChar = (ch) => isIdentStart(ch) || (ch >= 48 && ch <= 57) || ch == DASH;
|
|
47
|
+
// After a newline or a keyStart, the parser's error recovery can end an
|
|
48
|
+
// entry without reading any text, and would then take another zero-width
|
|
49
|
+
// token at the same place, forever. So the context remembers which of these
|
|
50
|
+
// came last since the last real token, and the tokenizer won't repeat it.
|
|
51
|
+
const AFTER_TEXT = 0, AFTER_NEWLINE = 1, AFTER_KEY_START = 2;
|
|
52
|
+
class IndentContext {
|
|
53
|
+
constructor(parent, indent,
|
|
54
|
+
// A sequence written at its key's indentation, as in "key:\n- a\n- b",
|
|
55
|
+
// ends at the first line at that indentation that isn't a "- " item.
|
|
56
|
+
sequence, layout) {
|
|
57
|
+
this.parent = parent;
|
|
58
|
+
this.indent = indent;
|
|
59
|
+
this.sequence = sequence;
|
|
60
|
+
this.layout = layout;
|
|
61
|
+
this.variants = [];
|
|
62
|
+
this.hash = ((parent ? (parent.hash * 31) | 0 : 0) + indent * 8 + (sequence ? 4 : 0) + layout) | 0;
|
|
63
|
+
}
|
|
64
|
+
with(layout) {
|
|
65
|
+
var _a;
|
|
66
|
+
var _b;
|
|
67
|
+
if (layout == this.layout)
|
|
68
|
+
return this;
|
|
69
|
+
return ((_a = (_b = this.variants)[layout]) !== null && _a !== void 0 ? _a : (_b[layout] = new IndentContext(this.parent, this.indent, this.sequence, layout)));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const top = new IndentContext(null, 0, false, AFTER_TEXT);
|
|
73
|
+
// The column of the input's position, counting a tab as reaching the next
|
|
74
|
+
// multiple of 8.
|
|
75
|
+
function columnOf(input) {
|
|
76
|
+
let start = 0;
|
|
77
|
+
while (!isLineEnd(input.peek(start - 1)))
|
|
78
|
+
start--;
|
|
79
|
+
let column = 0;
|
|
80
|
+
for (let i = start; i < 0; i++) {
|
|
81
|
+
column = input.peek(i) == TAB ? column + 8 - (column % 8) : column + 1;
|
|
82
|
+
}
|
|
83
|
+
return column;
|
|
84
|
+
}
|
|
85
|
+
// The column of the input's position if only spaces and tabs come before it on
|
|
86
|
+
// its line, and -1 otherwise. The first line has no line break before it, so
|
|
87
|
+
// it gives -1 too.
|
|
88
|
+
function lineStartColumn(input) {
|
|
89
|
+
for (let i = -1;; i--) {
|
|
90
|
+
const ch = input.peek(i);
|
|
91
|
+
if (ch < 0)
|
|
92
|
+
return -1;
|
|
93
|
+
if (isLineEnd(ch))
|
|
94
|
+
break;
|
|
95
|
+
if (ch != SPACE && ch != TAB)
|
|
96
|
+
return -1;
|
|
97
|
+
}
|
|
98
|
+
return columnOf(input);
|
|
99
|
+
}
|
|
100
|
+
const trackIndent = new lr.ContextTracker({
|
|
101
|
+
start: top,
|
|
102
|
+
shift(context, term, _stack, input) {
|
|
103
|
+
if (term == indent || term == seqIndent || term == compactStart) {
|
|
104
|
+
return new IndentContext(context.with(AFTER_TEXT), columnOf(input), term == seqIndent, AFTER_NEWLINE);
|
|
105
|
+
}
|
|
106
|
+
if (term == dedent)
|
|
107
|
+
return context.parent || context;
|
|
108
|
+
if (term == newline)
|
|
109
|
+
return context.with(AFTER_NEWLINE);
|
|
110
|
+
if (term == keyStart)
|
|
111
|
+
return context.with(AFTER_KEY_START);
|
|
112
|
+
return context.with(AFTER_TEXT);
|
|
113
|
+
},
|
|
114
|
+
hash: (context) => context.hash,
|
|
115
|
+
});
|
|
116
|
+
// Reads from the start of an entry to the end of its line, and says whether
|
|
117
|
+
// the line holds a ": " (or a ":" at its end) outside brackets, quotes and
|
|
118
|
+
// comments.
|
|
119
|
+
function lineHasKey(input) {
|
|
120
|
+
let prev = 0;
|
|
121
|
+
let depth = 0;
|
|
122
|
+
for (let i = 0;; i++) {
|
|
123
|
+
const ch = input.peek(i);
|
|
124
|
+
if (isLineEnd(ch))
|
|
125
|
+
return false;
|
|
126
|
+
if (ch == HASH && (prev == 0 || prev == SPACE || prev == TAB))
|
|
127
|
+
return false;
|
|
128
|
+
// A quote inside a plain scalar, as in `don't: 2`, is an ordinary
|
|
129
|
+
// character.
|
|
130
|
+
const quoteCanStart = prev == 0 || prev == SPACE || prev == TAB || prev == PAREN_OPEN ||
|
|
131
|
+
prev == BRACKET_OPEN || prev == BRACE_OPEN || prev == DASH || prev == PLUS;
|
|
132
|
+
if (ch == DOUBLE_QUOTE && quoteCanStart) {
|
|
133
|
+
for (i++;; i++) {
|
|
134
|
+
const c = input.peek(i);
|
|
135
|
+
if (isLineEnd(c))
|
|
136
|
+
return false;
|
|
137
|
+
if (c == BACKSLASH)
|
|
138
|
+
i++;
|
|
139
|
+
else if (c == DOUBLE_QUOTE)
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
prev = DOUBLE_QUOTE;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (ch == SINGLE_QUOTE && quoteCanStart) {
|
|
146
|
+
for (i++;; i++) {
|
|
147
|
+
const c = input.peek(i);
|
|
148
|
+
if (isLineEnd(c))
|
|
149
|
+
return false;
|
|
150
|
+
if (c == SINGLE_QUOTE) {
|
|
151
|
+
if (input.peek(i + 1) == SINGLE_QUOTE)
|
|
152
|
+
i++;
|
|
153
|
+
else
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
prev = SINGLE_QUOTE;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
// A character literal such as \\( or \\: hides the character after it.
|
|
161
|
+
if (ch == BACKSLASH) {
|
|
162
|
+
if (input.peek(i + 1) == BACKSLASH)
|
|
163
|
+
i += 2;
|
|
164
|
+
prev = 120;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
// A regex literal.
|
|
168
|
+
if (ch == SLASH &&
|
|
169
|
+
(prev == 0 || prev == SPACE || prev == PAREN_OPEN || prev == BRACKET_OPEN || prev == BRACE_OPEN) &&
|
|
170
|
+
!isBlank(input.peek(i + 1))) {
|
|
171
|
+
for (i++;; i++) {
|
|
172
|
+
const c = input.peek(i);
|
|
173
|
+
if (isLineEnd(c))
|
|
174
|
+
return false;
|
|
175
|
+
if (c == BACKSLASH)
|
|
176
|
+
i++;
|
|
177
|
+
else if (c == SLASH)
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
prev = SLASH;
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (ch == PAREN_OPEN || ch == BRACKET_OPEN || ch == BRACE_OPEN)
|
|
184
|
+
depth++;
|
|
185
|
+
if ((ch == PAREN_CLOSE || ch == BRACKET_CLOSE || ch == BRACE_CLOSE) && depth > 0)
|
|
186
|
+
depth--;
|
|
187
|
+
if (ch == COLON && depth == 0 && isBlank(input.peek(i + 1)))
|
|
188
|
+
return true;
|
|
189
|
+
prev = ch;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const layout = new lr.ExternalTokenizer((input, stack) => {
|
|
193
|
+
const context = stack.context;
|
|
194
|
+
const next = input.next;
|
|
195
|
+
if (next < 0) {
|
|
196
|
+
if (context.parent && stack.canShift(dedent))
|
|
197
|
+
input.acceptToken(dedent);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (isBlank(next) || next == HASH)
|
|
201
|
+
return;
|
|
202
|
+
const column = context.layout == AFTER_TEXT ? lineStartColumn(input) : -1;
|
|
203
|
+
if (column >= 0) {
|
|
204
|
+
const dashLine = next == DASH && isBlank(input.peek(1));
|
|
205
|
+
if (column > context.indent) {
|
|
206
|
+
if (stack.canShift(indent))
|
|
207
|
+
return input.acceptToken(indent);
|
|
208
|
+
}
|
|
209
|
+
else if (column == context.indent) {
|
|
210
|
+
if (context.sequence && !dashLine && stack.canShift(dedent))
|
|
211
|
+
return input.acceptToken(dedent);
|
|
212
|
+
if (dashLine && !context.sequence && stack.canShift(seqIndent))
|
|
213
|
+
return input.acceptToken(seqIndent);
|
|
214
|
+
if (stack.canShift(newline))
|
|
215
|
+
return input.acceptToken(newline);
|
|
216
|
+
}
|
|
217
|
+
else if (stack.canShift(dedent)) {
|
|
218
|
+
return input.acceptToken(dedent);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (next == DASH && isBlank(input.peek(1))) {
|
|
222
|
+
if (stack.canShift(seqDash))
|
|
223
|
+
return input.acceptToken(seqDash, 1);
|
|
224
|
+
if (context.layout == AFTER_TEXT && stack.canShift(compactStart))
|
|
225
|
+
return input.acceptToken(compactStart);
|
|
226
|
+
}
|
|
227
|
+
if (next == QUESTION && isBlank(input.peek(1)) && stack.canShift(explicitKey)) {
|
|
228
|
+
return input.acceptToken(explicitKey, 1);
|
|
229
|
+
}
|
|
230
|
+
if (context.layout == AFTER_KEY_START)
|
|
231
|
+
return;
|
|
232
|
+
const compact = context.layout == AFTER_TEXT && stack.canShift(compactStart);
|
|
233
|
+
if ((compact || stack.canShift(keyStart)) && lineHasKey(input)) {
|
|
234
|
+
input.acceptToken(compact ? compactStart : keyStart);
|
|
235
|
+
}
|
|
236
|
+
}, { contextual: true });
|
|
237
|
+
// The ":" that ends a key is followed by a space or the end of the line, and
|
|
238
|
+
// so is "::". A ":" right after a value and before a name, as in `text:uc`,
|
|
239
|
+
// chains a call. Any other ":" starts a keyword such as `:name`.
|
|
240
|
+
const chainable = (ch) => isIdentChar(ch) || ch == PAREN_CLOSE || ch == BRACKET_CLOSE || ch == BRACE_CLOSE ||
|
|
241
|
+
ch == QUESTION || ch == 33 || ch == 42 || ch == PLUS;
|
|
242
|
+
const colons = new lr.ExternalTokenizer((input, stack) => {
|
|
243
|
+
if (input.next != COLON)
|
|
244
|
+
return;
|
|
245
|
+
const after = input.peek(1);
|
|
246
|
+
if (isBlank(after)) {
|
|
247
|
+
if (stack.canShift(colon))
|
|
248
|
+
input.acceptToken(colon, 1);
|
|
249
|
+
}
|
|
250
|
+
else if (after == COLON) {
|
|
251
|
+
if (isBlank(input.peek(2)) && stack.canShift(doubleColon))
|
|
252
|
+
input.acceptToken(doubleColon, 2);
|
|
253
|
+
}
|
|
254
|
+
else if (isIdentStart(after) && chainable(input.peek(-1)) && stack.canShift(chainColon)) {
|
|
255
|
+
input.acceptToken(chainColon, 1);
|
|
256
|
+
}
|
|
257
|
+
}, { contextual: true });
|
|
258
|
+
const binaryOperators = new Set([
|
|
259
|
+
"+", "-", "*", "/", "%", "**", "==", "!=", "<", ">", "<=", ">=",
|
|
260
|
+
"&&", "||", "&&&", "|||", "=~", "!~", "..", "...", "->", "->>",
|
|
261
|
+
]);
|
|
262
|
+
const operatorChars = new Set("+-*/%<>=!&|.~".split("").map((c) => c.charCodeAt(0)));
|
|
263
|
+
// `a +: b` means `a + b`: a key can end with an operator, and its value is
|
|
264
|
+
// the operator's right side.
|
|
265
|
+
const keyOperators = new lr.ExternalTokenizer((input, stack) => {
|
|
266
|
+
if (!operatorChars.has(input.next))
|
|
267
|
+
return;
|
|
268
|
+
let length = 0;
|
|
269
|
+
while (operatorChars.has(input.peek(length)))
|
|
270
|
+
length++;
|
|
271
|
+
if (input.peek(length) != COLON)
|
|
272
|
+
return;
|
|
273
|
+
const after = input.peek(length + 1) == COLON ? length + 2 : length + 1;
|
|
274
|
+
if (!isBlank(input.peek(after)))
|
|
275
|
+
return;
|
|
276
|
+
let text = "";
|
|
277
|
+
for (let i = 0; i < length; i++)
|
|
278
|
+
text += String.fromCharCode(input.peek(i));
|
|
279
|
+
if (binaryOperators.has(text) && stack.canShift(KeyOperator))
|
|
280
|
+
input.acceptToken(KeyOperator, length);
|
|
281
|
+
}, { contextual: true });
|
|
282
|
+
// A "|" or ">" block scalar takes every following line that is blank or more
|
|
283
|
+
// indented than the block that holds its key.
|
|
284
|
+
const blockScalars = new lr.ExternalTokenizer((input, stack) => {
|
|
285
|
+
if ((input.next != PIPE && input.next != GT) || !stack.canShift(BlockScalar))
|
|
286
|
+
return;
|
|
287
|
+
let i = 1;
|
|
288
|
+
for (let ch = input.peek(i); ch == DASH || ch == PLUS || (ch >= 48 && ch <= 57); ch = input.peek(++i))
|
|
289
|
+
;
|
|
290
|
+
if (!isBlank(input.peek(i)))
|
|
291
|
+
return;
|
|
292
|
+
while (!isLineEnd(input.peek(i)))
|
|
293
|
+
i++;
|
|
294
|
+
let end = i;
|
|
295
|
+
const parent = stack.context.indent;
|
|
296
|
+
while (input.peek(i) >= 0) {
|
|
297
|
+
if (input.peek(i) == CR)
|
|
298
|
+
i++;
|
|
299
|
+
if (input.peek(i) == NEWLINE)
|
|
300
|
+
i++;
|
|
301
|
+
let column = 0;
|
|
302
|
+
while (input.peek(i) == SPACE) {
|
|
303
|
+
i++;
|
|
304
|
+
column++;
|
|
305
|
+
}
|
|
306
|
+
if (isLineEnd(input.peek(i))) {
|
|
307
|
+
if (input.peek(i) < 0)
|
|
308
|
+
break;
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
if (column <= parent)
|
|
312
|
+
break;
|
|
313
|
+
while (!isLineEnd(input.peek(i)))
|
|
314
|
+
i++;
|
|
315
|
+
end = i;
|
|
316
|
+
}
|
|
317
|
+
input.acceptToken(BlockScalar, end);
|
|
318
|
+
}, { contextual: true });
|
|
319
|
+
// In data mode, after "::", text such as `north` or `the old lady` is a
|
|
320
|
+
// string. It runs to the end of the line, a ": " or a " #" comment, and
|
|
321
|
+
// more indented lines continue it. Numbers,
|
|
322
|
+
// booleans and nil keep their own tokens.
|
|
323
|
+
const notPlainStart = new Set("-?:,[]{}#&*!|>'\"%@`\\".split("").map((c) => c.charCodeAt(0)));
|
|
324
|
+
const ownToken = /^(-?\d+(\.\d+)?([eE][-+]?\d+)?|true|false|nil)$/;
|
|
325
|
+
const plainScalars = new lr.ExternalTokenizer((input, stack) => {
|
|
326
|
+
if (isBlank(input.next) || input.next == HASH || !stack.canShift(PlainScalar))
|
|
327
|
+
return;
|
|
328
|
+
// A line that continues a multi-line scalar can start with any character.
|
|
329
|
+
const continues = lineStartColumn(input) > stack.context.indent;
|
|
330
|
+
if (notPlainStart.has(input.next) && !continues)
|
|
331
|
+
return;
|
|
332
|
+
let end = 0;
|
|
333
|
+
let text = "";
|
|
334
|
+
for (let i = 0;; i++) {
|
|
335
|
+
const ch = input.peek(i);
|
|
336
|
+
if (isLineEnd(ch))
|
|
337
|
+
break;
|
|
338
|
+
if (ch == COLON && isBlank(input.peek(i + 1)))
|
|
339
|
+
break;
|
|
340
|
+
if (ch == COLON && input.peek(i + 1) == COLON && isBlank(input.peek(i + 2)))
|
|
341
|
+
break;
|
|
342
|
+
if (ch == HASH && (input.peek(i - 1) == SPACE || input.peek(i - 1) == TAB))
|
|
343
|
+
break;
|
|
344
|
+
text += String.fromCharCode(ch);
|
|
345
|
+
if (ch != SPACE && ch != TAB)
|
|
346
|
+
end = i + 1;
|
|
347
|
+
}
|
|
348
|
+
if (end == 0 || ownToken.test(text.trim()))
|
|
349
|
+
return;
|
|
350
|
+
input.acceptToken(PlainScalar, end);
|
|
351
|
+
}, { contextual: true });
|
|
352
|
+
// `f(x)` calls f, and `f (x)` is f followed by a parenthesized expression, so
|
|
353
|
+
// a "(" right after a name or a closing bracket opens an argument list.
|
|
354
|
+
const callParens = new lr.ExternalTokenizer((input, stack) => {
|
|
355
|
+
if (input.next != PAREN_OPEN)
|
|
356
|
+
return;
|
|
357
|
+
const prev = input.peek(-1);
|
|
358
|
+
if ((isIdentChar(prev) || prev == PAREN_CLOSE || prev == BRACKET_CLOSE || prev == BRACE_CLOSE ||
|
|
359
|
+
prev == QUESTION || prev == 33 || prev == 42 || prev == PLUS) &&
|
|
360
|
+
stack.canShift(callParen)) {
|
|
361
|
+
input.acceptToken(callParen, 1);
|
|
362
|
+
}
|
|
363
|
+
}, { contextual: true });
|
|
364
|
+
// These words start most YAMLScript forms. They are highlighted as keywords
|
|
365
|
+
// where a form can start: first in a key, a value or a parenthesized list.
|
|
366
|
+
// Followed by "(" or ".", as in `if(a b c)`, they are ordinary names.
|
|
367
|
+
const controlWords = new Set([
|
|
368
|
+
"if", "if-not", "if-let", "if-some", "when", "when-not", "when-let", "when-some", "when-first",
|
|
369
|
+
"cond", "condp", "case", "else", "then", "do", "loop", "recur", "let", "each", "for",
|
|
370
|
+
"doseq", "dotimes", "while", "try", "catch", "finally", "throw", "binding",
|
|
371
|
+
]);
|
|
372
|
+
const controlKeywords = new lr.ExternalTokenizer((input, stack) => {
|
|
373
|
+
if (!isIdentStart(input.next))
|
|
374
|
+
return;
|
|
375
|
+
let length = 0;
|
|
376
|
+
let text = "";
|
|
377
|
+
for (let ch = input.next; isIdentChar(ch) || ch == QUESTION || ch == 33; ch = input.peek(++length)) {
|
|
378
|
+
text += String.fromCharCode(ch);
|
|
379
|
+
}
|
|
380
|
+
const after = input.peek(length);
|
|
381
|
+
if (after == PAREN_OPEN || after == 46 || (after == COLON && !isBlank(input.peek(length + 1))))
|
|
382
|
+
return;
|
|
383
|
+
if (controlWords.has(text) && stack.canShift(ControlKeyword))
|
|
384
|
+
input.acceptToken(ControlKeyword, length);
|
|
385
|
+
}, { contextual: true });
|
|
386
|
+
|
|
387
|
+
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
388
|
+
const spec_identifier = {__proto__:null,fn:32, true:258, false:258, nil:260, defn:150, "defn-":152, defmacro:154};
|
|
389
|
+
const parser = lr.LRParser.deserialize({
|
|
390
|
+
version: 14,
|
|
391
|
+
states: "6nQYQ#uOOO#_Q%aO'#DjO#oQ#uO'#DiO%bQ%WO'#CfO%rQ%WO'#D}OOQP'#Ee'#EeO%yQ#uO'#CeOOQO'#Ed'#EdQ&UQ#uOOQOQ#tOOO)]Q#{O'#EOO+WQ#tO'#CpOOQV'#Ct'#CtOOQw'#Cu'#CuOOQ!X'#C{'#C{OOQ!X'#C|'#C|O.yQ$mO'#EgO/aQ#tO'#DXO/oQ%WO'#DZO1_Q#tO'#D]O1fQ#tO'#D_O1mQ#tO'#DdO1tQ#tO'#DeOOQw'#FQ'#FQOOQV'#Eg'#EgO3RQ#yO'#EfO3cQ#{O'#EfOOQ!s'#Dg'#DgOOQ!s'#F^'#F^O]Q#uO'#DkOOQP,5:U,5:UO3yQ%XO'#DhO4ZQ%XO'#F]OOQP'#F]'#F]O4qQ$fO'#CkO5PQ#uO'#EQO5UQ#uO,5:TO5aQ&pO'#EOO6TQ'bO'#EgO8[Q&pO'#EfOOQR'#Cg'#CgO9XQ#{O'#CgO9gQ#vO,59QO9oQ&jO,5:aO:aQ#tO,5:dO:fQ#uO,5:iO:kQ#uO'#EPO:sQ#uO,59PO]Q#uOOOOQO'#Cj'#CjO)sQ#tO,59TOOQ!X,59[,59[O;OQ#tO,59[O;VQ#tO'#DOOOQw,59i,59iO/aQ#tO,59kOOQw'#DU'#DUOOQw,59o,59oO;aQ#tO,59qOOQw'#DR'#DROOQw'#FT'#FTOOQw,59s,59sO;fQ#tO,59uOOQw,59u,59uO;fQ#tO,59uOOQw,59w,59wO;mQ#tO,59wOOQ!X,59y,59yO;tQ#tO,59yOOQw,5:O,5:OO;{Q#tO,5:OO?nQ$mO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S$k!W`PSZbcdeijop!S!U!V!`!b!d!f!h!k!p!v#T#Z#d#p$^UvRw$kQ!ifR!t$jQ!_aR#V!XQ!xzQ#m!zQ#n!|R$P#oQnPQ#f!vQ$R#pR$e$^WpP!v#p$^X#k!w#q#z$]Q#f!wQ$R#qQ$Y#zR$e$]g#h!w#i#j#k#q#w#x#z#}$T$]",
|
|
394
|
+
nodeNames: "⚠ KeyOperator BlockScalar PlainScalar ( ControlKeyword Comment Program Tag Mapping Pair Key => BinaryExpression Operator FnExpression fn ) ParamList ] Vector [ -[ +[ Splat VariableName Keyword Number String Character Regex Boolean Nil CallExpression ArgList MemberExpression . PropertyName Variable PostfixExpression PostfixOperator ChainCall FunctionName LeadingMember ( ParenthesizedExpression \\( AnonymousFunction } Map { -{ +{ \\{ Set Quote \\' Tag Block Sequence SequenceItem CompactMapping CompactSequence DataBlock DataMapping DataPair DataKey DataSequence DataItem DataCompactMapping DataCompactSequence Assignment AssignTarget AssignOp FunctionDefinition defn defn- defmacro DefName ExplicitPair",
|
|
395
|
+
maxTerm: 152,
|
|
396
|
+
context: trackIndent,
|
|
397
|
+
nodeProps: [
|
|
398
|
+
["closedBy", -3,4,44,46,")",53,"}"],
|
|
399
|
+
["openedBy", 17,"( \\(",48,"\\{"]
|
|
400
|
+
],
|
|
401
|
+
skippedNodes: [0,6],
|
|
402
|
+
repeatNodeCount: 6,
|
|
403
|
+
tokenData: ";x~RqXY#YYZ#Y]^#Ypq#Yqr#nrs&Ust'rtu(Zuv({vw)]wx)xxy*jyz*oz{*t{|,Q|}#Y}!O,u!O!P/`!P!Q1]!Q![-a![!]4Y!^!_5V!_!`5d!`!a6R!c!}6`!}#O8y#O#P9O#P#Q:t#R#S6`#T#o6`#o#p:y#p#q;O#q#r;s~#_T#V~XY#YYZ#Y]^#Ypq#Y|}#Y~#sYW~OX$cZ]$c^p$cq!_$c!_!`%Q!`#r$c#r#s%k#s;'S$c;'S;=`$z<%lO$c~$hUW~OX$cZ]$c^p$cq;'S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S;=`3h<%lO2Q~2TVO!P2Q!P!Q2j!Q#O2Q#O#P2o#P;'S2Q;'S;=`3h<%lO2Q~2oOn~~2rRO;'S2Q;'S;=`2{;=`O2Q~3OWO!P2Q!P!Q2j!Q#O2Q#O#P2o#P;'S2Q;'S;=`3h;=`<%l2Q<%lO2Q~3kP;=`<%l2Q~3sV$X~O!P2Q!P!Q2j!Q#O2Q#O#P2o#P;'S2Q;'S;=`3h<%lO2Q~4]R!c!}4f#R#S4f#T#o4f~4kVj~qr5Q}!O4f!Q![4f!a!b5Q!c!}4f#R#S4f#T#o4f~5VOj~~5[P#d~!_!`5_~5dO#f~~5iR$TQ!_!`5r!`!a5w#r#s5|~5wO#b~P5|O[P~6RO#l~~6WP#e~!_!`6Z~6`O#g~~6eZ#r~qr7Wz{7W{|7W}!O6`!P!Q7i!Q![6`![!]8g!a!b7W!c!}6`#R#S6`#T#o6`~7]S#r~qr7Wz{7W{|7W!a!b7W~7lR!c!}7u#R#S7u#T#o7u~7zX#r~qr7Wz{7W{|7W}!O7u!Q![7u!a!b7W!c!}7u#R#S7u#T#o7u~8jP![!]8m~8pR!c!}6`#R#S6`#T#o6`~9OOe~~9RSwx9_xy9d#O#P9i#o#p:o~9dO!Y~~9iO!O~~9lXOX:XZp:Xq!c:X!c!}:^!}#T:X#T#o:^#o;'S:X;'S;=`:i<%lO:X~:^Om~~:cQm~!c!}:^#T#o:^~:lP;=`<%l:X~:tO!V~~:yOc~~;OO!S~~;RP#p#q;U~;ZQ#i~!_!`;a#p#q;f~;fO$Z~~;kP#k~!_!`;n~;sO$]~~;xO!Q~",
|
|
404
|
+
tokenizers: [layout, colons, keyOperators, blockScalars, plainScalars, callParens, controlKeywords, 0, 1],
|
|
405
|
+
topRules: {"Program":[0,7]},
|
|
406
|
+
specialized: [{term: 126, get: (value) => spec_identifier[value] || -1}],
|
|
407
|
+
tokenPrec: 1988
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
// These lists name the functions a YAMLScript program can call without a prefix.
|
|
411
|
+
// ysStd comes from the public names in YAMLScript's ys::std library
|
|
412
|
+
// (core/src/ys/v0/std.cljc in https://github.com/yaml/yamlscript, MIT). The
|
|
413
|
+
// others come from Clojure 1.12's clojure.core, which YAMLScript refers, minus
|
|
414
|
+
// the names that ys::std replaces and the ones a YAMLScript name can't spell.
|
|
415
|
+
const ysStd = [
|
|
416
|
+
"B",
|
|
417
|
+
"C",
|
|
418
|
+
"F",
|
|
419
|
+
"F?",
|
|
420
|
+
"I",
|
|
421
|
+
"K",
|
|
422
|
+
"L",
|
|
423
|
+
"L+",
|
|
424
|
+
"M",
|
|
425
|
+
"M+",
|
|
426
|
+
"N",
|
|
427
|
+
"O",
|
|
428
|
+
"O+",
|
|
429
|
+
"S",
|
|
430
|
+
"T",
|
|
431
|
+
"T?",
|
|
432
|
+
"V",
|
|
433
|
+
"V+",
|
|
434
|
+
"a",
|
|
435
|
+
"add",
|
|
436
|
+
"add+",
|
|
437
|
+
"and?",
|
|
438
|
+
"atom",
|
|
439
|
+
"base64",
|
|
440
|
+
"base64-decode",
|
|
441
|
+
"base64-encode",
|
|
442
|
+
"base64-points",
|
|
443
|
+
"blank?",
|
|
444
|
+
"call",
|
|
445
|
+
"chomp",
|
|
446
|
+
"chop",
|
|
447
|
+
"cube",
|
|
448
|
+
"dec+",
|
|
449
|
+
"del",
|
|
450
|
+
"die",
|
|
451
|
+
"diff",
|
|
452
|
+
"digits",
|
|
453
|
+
"div",
|
|
454
|
+
"div+",
|
|
455
|
+
"each",
|
|
456
|
+
"ends?",
|
|
457
|
+
"env-update",
|
|
458
|
+
"eq",
|
|
459
|
+
"err",
|
|
460
|
+
"escape",
|
|
461
|
+
"eval",
|
|
462
|
+
"exit",
|
|
463
|
+
"falsey?",
|
|
464
|
+
"flat",
|
|
465
|
+
"flip",
|
|
466
|
+
"floor",
|
|
467
|
+
"ge",
|
|
468
|
+
"get+",
|
|
469
|
+
"get-url",
|
|
470
|
+
"grep",
|
|
471
|
+
"gt",
|
|
472
|
+
"has?",
|
|
473
|
+
"if",
|
|
474
|
+
"in?",
|
|
475
|
+
"inc+",
|
|
476
|
+
"index",
|
|
477
|
+
"instant",
|
|
478
|
+
"invoke-constructor",
|
|
479
|
+
"join",
|
|
480
|
+
"joins",
|
|
481
|
+
"lc",
|
|
482
|
+
"le",
|
|
483
|
+
"len",
|
|
484
|
+
"lines",
|
|
485
|
+
"load-url",
|
|
486
|
+
"lt",
|
|
487
|
+
"max-long",
|
|
488
|
+
"md5",
|
|
489
|
+
"merge-omap",
|
|
490
|
+
"mul",
|
|
491
|
+
"mul+",
|
|
492
|
+
"ne",
|
|
493
|
+
"new",
|
|
494
|
+
"now",
|
|
495
|
+
"omap",
|
|
496
|
+
"or?",
|
|
497
|
+
"ordered-map-fn",
|
|
498
|
+
"out",
|
|
499
|
+
"pow",
|
|
500
|
+
"pp",
|
|
501
|
+
"pretty",
|
|
502
|
+
"print",
|
|
503
|
+
"put",
|
|
504
|
+
"q",
|
|
505
|
+
"ql",
|
|
506
|
+
"qm",
|
|
507
|
+
"qo",
|
|
508
|
+
"qr",
|
|
509
|
+
"qs",
|
|
510
|
+
"qv",
|
|
511
|
+
"qw",
|
|
512
|
+
"readline",
|
|
513
|
+
"replace",
|
|
514
|
+
"replace1",
|
|
515
|
+
"reset",
|
|
516
|
+
"reverse",
|
|
517
|
+
"rindex",
|
|
518
|
+
"rng",
|
|
519
|
+
"round",
|
|
520
|
+
"say",
|
|
521
|
+
"set",
|
|
522
|
+
"sha1",
|
|
523
|
+
"sha256",
|
|
524
|
+
"sleep",
|
|
525
|
+
"slice",
|
|
526
|
+
"source",
|
|
527
|
+
"split",
|
|
528
|
+
"sqr",
|
|
529
|
+
"sqrt",
|
|
530
|
+
"starts?",
|
|
531
|
+
"stream",
|
|
532
|
+
"sub",
|
|
533
|
+
"sub+",
|
|
534
|
+
"substr",
|
|
535
|
+
"sum",
|
|
536
|
+
"swap",
|
|
537
|
+
"text",
|
|
538
|
+
"throw",
|
|
539
|
+
"to-bool",
|
|
540
|
+
"to-char",
|
|
541
|
+
"to-float",
|
|
542
|
+
"to-int",
|
|
543
|
+
"to-keyw",
|
|
544
|
+
"to-list",
|
|
545
|
+
"to-map",
|
|
546
|
+
"to-num",
|
|
547
|
+
"to-omap",
|
|
548
|
+
"to-set",
|
|
549
|
+
"to-str",
|
|
550
|
+
"to-type",
|
|
551
|
+
"to-vars",
|
|
552
|
+
"to-vec",
|
|
553
|
+
"trim",
|
|
554
|
+
"triml",
|
|
555
|
+
"trimr",
|
|
556
|
+
"truey?",
|
|
557
|
+
"uc",
|
|
558
|
+
"uc1",
|
|
559
|
+
"use-pod",
|
|
560
|
+
"value",
|
|
561
|
+
"warn",
|
|
562
|
+
"when+",
|
|
563
|
+
"words"
|
|
564
|
+
];
|
|
565
|
+
const specialForms = [
|
|
566
|
+
"def",
|
|
567
|
+
"do",
|
|
568
|
+
"let",
|
|
569
|
+
"quote",
|
|
570
|
+
"var",
|
|
571
|
+
"fn",
|
|
572
|
+
"loop",
|
|
573
|
+
"recur",
|
|
574
|
+
"try",
|
|
575
|
+
"catch",
|
|
576
|
+
"finally",
|
|
577
|
+
"monitor-enter",
|
|
578
|
+
"monitor-exit",
|
|
579
|
+
"set!"
|
|
580
|
+
];
|
|
581
|
+
const coreMacros = [
|
|
582
|
+
"amap",
|
|
583
|
+
"and",
|
|
584
|
+
"areduce",
|
|
585
|
+
"assert",
|
|
586
|
+
"binding",
|
|
587
|
+
"bound-fn",
|
|
588
|
+
"case",
|
|
589
|
+
"comment",
|
|
590
|
+
"cond",
|
|
591
|
+
"condp",
|
|
592
|
+
"declare",
|
|
593
|
+
"definline",
|
|
594
|
+
"definterface",
|
|
595
|
+
"defmacro",
|
|
596
|
+
"defmethod",
|
|
597
|
+
"defmulti",
|
|
598
|
+
"defn",
|
|
599
|
+
"defn-",
|
|
600
|
+
"defonce",
|
|
601
|
+
"defprotocol",
|
|
602
|
+
"defrecord",
|
|
603
|
+
"deftype",
|
|
604
|
+
"delay",
|
|
605
|
+
"doseq",
|
|
606
|
+
"dosync",
|
|
607
|
+
"dotimes",
|
|
608
|
+
"doto",
|
|
609
|
+
"extend-protocol",
|
|
610
|
+
"extend-type",
|
|
611
|
+
"for",
|
|
612
|
+
"future",
|
|
613
|
+
"gen-class",
|
|
614
|
+
"gen-interface",
|
|
615
|
+
"if-let",
|
|
616
|
+
"if-not",
|
|
617
|
+
"if-some",
|
|
618
|
+
"import",
|
|
619
|
+
"io!",
|
|
620
|
+
"lazy-cat",
|
|
621
|
+
"lazy-seq",
|
|
622
|
+
"letfn",
|
|
623
|
+
"locking",
|
|
624
|
+
"memfn",
|
|
625
|
+
"ns",
|
|
626
|
+
"or",
|
|
627
|
+
"proxy",
|
|
628
|
+
"proxy-super",
|
|
629
|
+
"pvalues",
|
|
630
|
+
"refer-clojure",
|
|
631
|
+
"reify",
|
|
632
|
+
"sync",
|
|
633
|
+
"time",
|
|
634
|
+
"vswap!",
|
|
635
|
+
"when",
|
|
636
|
+
"when-first",
|
|
637
|
+
"when-let",
|
|
638
|
+
"when-not",
|
|
639
|
+
"when-some",
|
|
640
|
+
"while",
|
|
641
|
+
"with-bindings",
|
|
642
|
+
"with-in-str",
|
|
643
|
+
"with-local-vars",
|
|
644
|
+
"with-open",
|
|
645
|
+
"with-out-str",
|
|
646
|
+
"with-precision",
|
|
647
|
+
"with-redefs"
|
|
648
|
+
];
|
|
649
|
+
const coreFunctions = [
|
|
650
|
+
"NaN?",
|
|
651
|
+
"abs",
|
|
652
|
+
"aclone",
|
|
653
|
+
"add-tap",
|
|
654
|
+
"add-watch",
|
|
655
|
+
"agent",
|
|
656
|
+
"agent-error",
|
|
657
|
+
"agent-errors",
|
|
658
|
+
"aget",
|
|
659
|
+
"alength",
|
|
660
|
+
"alias",
|
|
661
|
+
"all-ns",
|
|
662
|
+
"alter",
|
|
663
|
+
"alter-meta!",
|
|
664
|
+
"alter-var-root",
|
|
665
|
+
"ancestors",
|
|
666
|
+
"any?",
|
|
667
|
+
"apply",
|
|
668
|
+
"array-map",
|
|
669
|
+
"aset",
|
|
670
|
+
"assoc",
|
|
671
|
+
"assoc!",
|
|
672
|
+
"assoc-in",
|
|
673
|
+
"associative?",
|
|
674
|
+
"await",
|
|
675
|
+
"await-for",
|
|
676
|
+
"await1",
|
|
677
|
+
"bases",
|
|
678
|
+
"bean",
|
|
679
|
+
"bigdec",
|
|
680
|
+
"bigint",
|
|
681
|
+
"biginteger",
|
|
682
|
+
"bit-and",
|
|
683
|
+
"bit-and-not",
|
|
684
|
+
"bit-clear",
|
|
685
|
+
"bit-flip",
|
|
686
|
+
"bit-not",
|
|
687
|
+
"bit-or",
|
|
688
|
+
"bit-set",
|
|
689
|
+
"bit-shift-left",
|
|
690
|
+
"bit-shift-right",
|
|
691
|
+
"bit-test",
|
|
692
|
+
"bit-xor",
|
|
693
|
+
"boolean",
|
|
694
|
+
"boolean-array",
|
|
695
|
+
"boolean?",
|
|
696
|
+
"booleans",
|
|
697
|
+
"bound-fn*",
|
|
698
|
+
"bound?",
|
|
699
|
+
"bounded-count",
|
|
700
|
+
"butlast",
|
|
701
|
+
"byte",
|
|
702
|
+
"byte-array",
|
|
703
|
+
"bytes",
|
|
704
|
+
"bytes?",
|
|
705
|
+
"cast",
|
|
706
|
+
"cat",
|
|
707
|
+
"char",
|
|
708
|
+
"char-array",
|
|
709
|
+
"char?",
|
|
710
|
+
"chars",
|
|
711
|
+
"class",
|
|
712
|
+
"class?",
|
|
713
|
+
"clear-agent-errors",
|
|
714
|
+
"clojure-version",
|
|
715
|
+
"coll?",
|
|
716
|
+
"commute",
|
|
717
|
+
"comp",
|
|
718
|
+
"comparator",
|
|
719
|
+
"compare",
|
|
720
|
+
"compare-and-set!",
|
|
721
|
+
"compile",
|
|
722
|
+
"complement",
|
|
723
|
+
"completing",
|
|
724
|
+
"concat",
|
|
725
|
+
"conj",
|
|
726
|
+
"conj!",
|
|
727
|
+
"cons",
|
|
728
|
+
"constantly",
|
|
729
|
+
"contains?",
|
|
730
|
+
"count",
|
|
731
|
+
"counted?",
|
|
732
|
+
"create-ns",
|
|
733
|
+
"cycle",
|
|
734
|
+
"dec",
|
|
735
|
+
"decimal?",
|
|
736
|
+
"dedupe",
|
|
737
|
+
"delay?",
|
|
738
|
+
"deliver",
|
|
739
|
+
"denominator",
|
|
740
|
+
"deref",
|
|
741
|
+
"derive",
|
|
742
|
+
"descendants",
|
|
743
|
+
"disj",
|
|
744
|
+
"disj!",
|
|
745
|
+
"dissoc",
|
|
746
|
+
"dissoc!",
|
|
747
|
+
"distinct",
|
|
748
|
+
"distinct?",
|
|
749
|
+
"doall",
|
|
750
|
+
"dorun",
|
|
751
|
+
"double",
|
|
752
|
+
"double-array",
|
|
753
|
+
"double?",
|
|
754
|
+
"doubles",
|
|
755
|
+
"drop",
|
|
756
|
+
"drop-last",
|
|
757
|
+
"drop-while",
|
|
758
|
+
"eduction",
|
|
759
|
+
"empty",
|
|
760
|
+
"empty?",
|
|
761
|
+
"ensure",
|
|
762
|
+
"ensure-reduced",
|
|
763
|
+
"enumeration-seq",
|
|
764
|
+
"error-handler",
|
|
765
|
+
"error-mode",
|
|
766
|
+
"even?",
|
|
767
|
+
"every-pred",
|
|
768
|
+
"every?",
|
|
769
|
+
"ex-cause",
|
|
770
|
+
"ex-data",
|
|
771
|
+
"ex-info",
|
|
772
|
+
"ex-message",
|
|
773
|
+
"extend",
|
|
774
|
+
"extenders",
|
|
775
|
+
"extends?",
|
|
776
|
+
"false?",
|
|
777
|
+
"ffirst",
|
|
778
|
+
"file-seq",
|
|
779
|
+
"filter",
|
|
780
|
+
"filterv",
|
|
781
|
+
"find",
|
|
782
|
+
"find-keyword",
|
|
783
|
+
"find-ns",
|
|
784
|
+
"find-var",
|
|
785
|
+
"first",
|
|
786
|
+
"flatten",
|
|
787
|
+
"float",
|
|
788
|
+
"float-array",
|
|
789
|
+
"float?",
|
|
790
|
+
"floats",
|
|
791
|
+
"flush",
|
|
792
|
+
"fn?",
|
|
793
|
+
"fnext",
|
|
794
|
+
"fnil",
|
|
795
|
+
"force",
|
|
796
|
+
"format",
|
|
797
|
+
"frequencies",
|
|
798
|
+
"future-call",
|
|
799
|
+
"future-cancel",
|
|
800
|
+
"future-cancelled?",
|
|
801
|
+
"future-done?",
|
|
802
|
+
"future?",
|
|
803
|
+
"gensym",
|
|
804
|
+
"get",
|
|
805
|
+
"get-in",
|
|
806
|
+
"get-method",
|
|
807
|
+
"get-thread-bindings",
|
|
808
|
+
"get-validator",
|
|
809
|
+
"group-by",
|
|
810
|
+
"halt-when",
|
|
811
|
+
"hash",
|
|
812
|
+
"hash-map",
|
|
813
|
+
"hash-ordered-coll",
|
|
814
|
+
"hash-set",
|
|
815
|
+
"hash-unordered-coll",
|
|
816
|
+
"ident?",
|
|
817
|
+
"identical?",
|
|
818
|
+
"identity",
|
|
819
|
+
"ifn?",
|
|
820
|
+
"inc",
|
|
821
|
+
"indexed?",
|
|
822
|
+
"infinite?",
|
|
823
|
+
"inst-ms",
|
|
824
|
+
"inst?",
|
|
825
|
+
"instance?",
|
|
826
|
+
"int",
|
|
827
|
+
"int-array",
|
|
828
|
+
"int?",
|
|
829
|
+
"integer?",
|
|
830
|
+
"interleave",
|
|
831
|
+
"intern",
|
|
832
|
+
"interpose",
|
|
833
|
+
"into",
|
|
834
|
+
"into-array",
|
|
835
|
+
"ints",
|
|
836
|
+
"isa?",
|
|
837
|
+
"iterate",
|
|
838
|
+
"iteration",
|
|
839
|
+
"iterator-seq",
|
|
840
|
+
"juxt",
|
|
841
|
+
"keep",
|
|
842
|
+
"keep-indexed",
|
|
843
|
+
"key",
|
|
844
|
+
"keys",
|
|
845
|
+
"keyword",
|
|
846
|
+
"keyword?",
|
|
847
|
+
"last",
|
|
848
|
+
"line-seq",
|
|
849
|
+
"list",
|
|
850
|
+
"list*",
|
|
851
|
+
"list?",
|
|
852
|
+
"load",
|
|
853
|
+
"load-reader",
|
|
854
|
+
"load-string",
|
|
855
|
+
"loaded-libs",
|
|
856
|
+
"long",
|
|
857
|
+
"long-array",
|
|
858
|
+
"longs",
|
|
859
|
+
"macroexpand",
|
|
860
|
+
"macroexpand-1",
|
|
861
|
+
"make-array",
|
|
862
|
+
"make-hierarchy",
|
|
863
|
+
"map",
|
|
864
|
+
"map-entry?",
|
|
865
|
+
"map-indexed",
|
|
866
|
+
"map?",
|
|
867
|
+
"mapcat",
|
|
868
|
+
"mapv",
|
|
869
|
+
"max",
|
|
870
|
+
"max-key",
|
|
871
|
+
"memoize",
|
|
872
|
+
"merge",
|
|
873
|
+
"merge-with",
|
|
874
|
+
"meta",
|
|
875
|
+
"methods",
|
|
876
|
+
"min",
|
|
877
|
+
"min-key",
|
|
878
|
+
"mod",
|
|
879
|
+
"name",
|
|
880
|
+
"namespace",
|
|
881
|
+
"nat-int?",
|
|
882
|
+
"neg-int?",
|
|
883
|
+
"neg?",
|
|
884
|
+
"newline",
|
|
885
|
+
"next",
|
|
886
|
+
"nfirst",
|
|
887
|
+
"nil?",
|
|
888
|
+
"nnext",
|
|
889
|
+
"not",
|
|
890
|
+
"not-any?",
|
|
891
|
+
"not-empty",
|
|
892
|
+
"not-every?",
|
|
893
|
+
"ns-aliases",
|
|
894
|
+
"ns-imports",
|
|
895
|
+
"ns-interns",
|
|
896
|
+
"ns-map",
|
|
897
|
+
"ns-name",
|
|
898
|
+
"ns-publics",
|
|
899
|
+
"ns-refers",
|
|
900
|
+
"ns-resolve",
|
|
901
|
+
"ns-unalias",
|
|
902
|
+
"ns-unmap",
|
|
903
|
+
"nth",
|
|
904
|
+
"nthnext",
|
|
905
|
+
"nthrest",
|
|
906
|
+
"num",
|
|
907
|
+
"number?",
|
|
908
|
+
"numerator",
|
|
909
|
+
"object-array",
|
|
910
|
+
"odd?",
|
|
911
|
+
"parents",
|
|
912
|
+
"parse-boolean",
|
|
913
|
+
"parse-double",
|
|
914
|
+
"parse-long",
|
|
915
|
+
"parse-uuid",
|
|
916
|
+
"partial",
|
|
917
|
+
"partition",
|
|
918
|
+
"partition-all",
|
|
919
|
+
"partition-by",
|
|
920
|
+
"partitionv",
|
|
921
|
+
"partitionv-all",
|
|
922
|
+
"pcalls",
|
|
923
|
+
"peek",
|
|
924
|
+
"persistent!",
|
|
925
|
+
"pmap",
|
|
926
|
+
"pop",
|
|
927
|
+
"pop!",
|
|
928
|
+
"pop-thread-bindings",
|
|
929
|
+
"pos-int?",
|
|
930
|
+
"pos?",
|
|
931
|
+
"pr",
|
|
932
|
+
"pr-str",
|
|
933
|
+
"prefer-method",
|
|
934
|
+
"prefers",
|
|
935
|
+
"print-dup",
|
|
936
|
+
"print-method",
|
|
937
|
+
"print-str",
|
|
938
|
+
"printf",
|
|
939
|
+
"println",
|
|
940
|
+
"println-str",
|
|
941
|
+
"prn",
|
|
942
|
+
"prn-str",
|
|
943
|
+
"promise",
|
|
944
|
+
"push-thread-bindings",
|
|
945
|
+
"qualified-ident?",
|
|
946
|
+
"qualified-keyword?",
|
|
947
|
+
"qualified-symbol?",
|
|
948
|
+
"quot",
|
|
949
|
+
"rand",
|
|
950
|
+
"rand-int",
|
|
951
|
+
"rand-nth",
|
|
952
|
+
"random-sample",
|
|
953
|
+
"random-uuid",
|
|
954
|
+
"range",
|
|
955
|
+
"ratio?",
|
|
956
|
+
"rational?",
|
|
957
|
+
"rationalize",
|
|
958
|
+
"re-find",
|
|
959
|
+
"re-groups",
|
|
960
|
+
"re-matcher",
|
|
961
|
+
"re-matches",
|
|
962
|
+
"re-pattern",
|
|
963
|
+
"re-seq",
|
|
964
|
+
"read",
|
|
965
|
+
"read-line",
|
|
966
|
+
"read-string",
|
|
967
|
+
"reader-conditional",
|
|
968
|
+
"reader-conditional?",
|
|
969
|
+
"realized?",
|
|
970
|
+
"record?",
|
|
971
|
+
"reduce",
|
|
972
|
+
"reduce-kv",
|
|
973
|
+
"reduced",
|
|
974
|
+
"reduced?",
|
|
975
|
+
"reductions",
|
|
976
|
+
"ref",
|
|
977
|
+
"ref-history-count",
|
|
978
|
+
"ref-max-history",
|
|
979
|
+
"ref-min-history",
|
|
980
|
+
"ref-set",
|
|
981
|
+
"refer",
|
|
982
|
+
"release-pending-sends",
|
|
983
|
+
"rem",
|
|
984
|
+
"remove",
|
|
985
|
+
"remove-all-methods",
|
|
986
|
+
"remove-method",
|
|
987
|
+
"remove-ns",
|
|
988
|
+
"remove-tap",
|
|
989
|
+
"remove-watch",
|
|
990
|
+
"repeat",
|
|
991
|
+
"repeatedly",
|
|
992
|
+
"require",
|
|
993
|
+
"requiring-resolve",
|
|
994
|
+
"reset!",
|
|
995
|
+
"reset-meta!",
|
|
996
|
+
"reset-vals!",
|
|
997
|
+
"resolve",
|
|
998
|
+
"rest",
|
|
999
|
+
"restart-agent",
|
|
1000
|
+
"resultset-seq",
|
|
1001
|
+
"reversible?",
|
|
1002
|
+
"rseq",
|
|
1003
|
+
"rsubseq",
|
|
1004
|
+
"run!",
|
|
1005
|
+
"satisfies?",
|
|
1006
|
+
"second",
|
|
1007
|
+
"select-keys",
|
|
1008
|
+
"send",
|
|
1009
|
+
"send-off",
|
|
1010
|
+
"send-via",
|
|
1011
|
+
"seq",
|
|
1012
|
+
"seq?",
|
|
1013
|
+
"seqable?",
|
|
1014
|
+
"seque",
|
|
1015
|
+
"sequence",
|
|
1016
|
+
"sequential?",
|
|
1017
|
+
"set-agent-send-executor!",
|
|
1018
|
+
"set-agent-send-off-executor!",
|
|
1019
|
+
"set-error-handler!",
|
|
1020
|
+
"set-error-mode!",
|
|
1021
|
+
"set-validator!",
|
|
1022
|
+
"set?",
|
|
1023
|
+
"short",
|
|
1024
|
+
"short-array",
|
|
1025
|
+
"shorts",
|
|
1026
|
+
"shuffle",
|
|
1027
|
+
"shutdown-agents",
|
|
1028
|
+
"simple-ident?",
|
|
1029
|
+
"simple-keyword?",
|
|
1030
|
+
"simple-symbol?",
|
|
1031
|
+
"slurp",
|
|
1032
|
+
"some",
|
|
1033
|
+
"some-fn",
|
|
1034
|
+
"some?",
|
|
1035
|
+
"sort",
|
|
1036
|
+
"sort-by",
|
|
1037
|
+
"sorted-map",
|
|
1038
|
+
"sorted-map-by",
|
|
1039
|
+
"sorted-set",
|
|
1040
|
+
"sorted-set-by",
|
|
1041
|
+
"sorted?",
|
|
1042
|
+
"special-symbol?",
|
|
1043
|
+
"spit",
|
|
1044
|
+
"split-at",
|
|
1045
|
+
"split-with",
|
|
1046
|
+
"splitv-at",
|
|
1047
|
+
"str",
|
|
1048
|
+
"string?",
|
|
1049
|
+
"subs",
|
|
1050
|
+
"subseq",
|
|
1051
|
+
"subvec",
|
|
1052
|
+
"supers",
|
|
1053
|
+
"swap!",
|
|
1054
|
+
"swap-vals!",
|
|
1055
|
+
"symbol",
|
|
1056
|
+
"symbol?",
|
|
1057
|
+
"tagged-literal",
|
|
1058
|
+
"tagged-literal?",
|
|
1059
|
+
"take",
|
|
1060
|
+
"take-last",
|
|
1061
|
+
"take-nth",
|
|
1062
|
+
"take-while",
|
|
1063
|
+
"test",
|
|
1064
|
+
"the-ns",
|
|
1065
|
+
"thread-bound?",
|
|
1066
|
+
"to-array",
|
|
1067
|
+
"to-array-2d",
|
|
1068
|
+
"trampoline",
|
|
1069
|
+
"transduce",
|
|
1070
|
+
"transient",
|
|
1071
|
+
"tree-seq",
|
|
1072
|
+
"true?",
|
|
1073
|
+
"type",
|
|
1074
|
+
"unchecked-add",
|
|
1075
|
+
"unchecked-add-int",
|
|
1076
|
+
"unchecked-byte",
|
|
1077
|
+
"unchecked-char",
|
|
1078
|
+
"unchecked-dec",
|
|
1079
|
+
"unchecked-dec-int",
|
|
1080
|
+
"unchecked-divide-int",
|
|
1081
|
+
"unchecked-double",
|
|
1082
|
+
"unchecked-float",
|
|
1083
|
+
"unchecked-inc",
|
|
1084
|
+
"unchecked-inc-int",
|
|
1085
|
+
"unchecked-int",
|
|
1086
|
+
"unchecked-long",
|
|
1087
|
+
"unchecked-multiply",
|
|
1088
|
+
"unchecked-multiply-int",
|
|
1089
|
+
"unchecked-negate",
|
|
1090
|
+
"unchecked-negate-int",
|
|
1091
|
+
"unchecked-remainder-int",
|
|
1092
|
+
"unchecked-short",
|
|
1093
|
+
"unchecked-subtract",
|
|
1094
|
+
"unchecked-subtract-int",
|
|
1095
|
+
"underive",
|
|
1096
|
+
"unreduced",
|
|
1097
|
+
"unsigned-bit-shift-right",
|
|
1098
|
+
"update",
|
|
1099
|
+
"update-in",
|
|
1100
|
+
"update-keys",
|
|
1101
|
+
"update-vals",
|
|
1102
|
+
"uri?",
|
|
1103
|
+
"use",
|
|
1104
|
+
"uuid?",
|
|
1105
|
+
"val",
|
|
1106
|
+
"vals",
|
|
1107
|
+
"var-get",
|
|
1108
|
+
"var-set",
|
|
1109
|
+
"var?",
|
|
1110
|
+
"vary-meta",
|
|
1111
|
+
"vec",
|
|
1112
|
+
"vector",
|
|
1113
|
+
"vector?",
|
|
1114
|
+
"volatile!",
|
|
1115
|
+
"volatile?",
|
|
1116
|
+
"vreset!",
|
|
1117
|
+
"with-bindings*",
|
|
1118
|
+
"with-meta",
|
|
1119
|
+
"with-redefs-fn",
|
|
1120
|
+
"xml-seq",
|
|
1121
|
+
"zero?",
|
|
1122
|
+
"zipmap"
|
|
1123
|
+
];
|
|
1124
|
+
const coreVars = [
|
|
1125
|
+
"char-escape-string",
|
|
1126
|
+
"char-name-string"
|
|
1127
|
+
];
|
|
1128
|
+
|
|
1129
|
+
// A YAMLScript name, such as `x`, `is-paired`, `empty?` or `swap!`.
|
|
1130
|
+
const Identifier = /^[a-zA-Z_][\w-]*[?!+*]*$/;
|
|
1131
|
+
const wordBefore = /[a-zA-Z_][\w-]*[?!+*]*$/;
|
|
1132
|
+
// Nothing is offered inside these, or while a new function name is typed.
|
|
1133
|
+
const dontComplete = new Set([
|
|
1134
|
+
"String", "Regex", "Character", "Comment", "BlockScalar", "PlainScalar", "Tag",
|
|
1135
|
+
"Keyword", "Number", "DefName",
|
|
1136
|
+
]);
|
|
1137
|
+
function inNode(node, names) {
|
|
1138
|
+
for (let cur = node; cur; cur = cur.parent)
|
|
1139
|
+
if (names.has(cur.name))
|
|
1140
|
+
return true;
|
|
1141
|
+
return false;
|
|
1142
|
+
}
|
|
1143
|
+
/// Snippets for YAMLScript's common forms.
|
|
1144
|
+
const snippets = [
|
|
1145
|
+
autocomplete.snippetCompletion("defn ${name}(${params}):\n\t${}", { label: "defn", detail: "function", type: "keyword" }),
|
|
1146
|
+
autocomplete.snippetCompletion("defn- ${name}(${params}):\n\t${}", { label: "defn-", detail: "private function", type: "keyword" }),
|
|
1147
|
+
autocomplete.snippetCompletion("fn(${params}): ${}", { label: "fn", detail: "anonymous function", type: "keyword" }),
|
|
1148
|
+
autocomplete.snippetCompletion("if ${condition}:\n\tthen: ${}\n\telse: ${}", { label: "if", detail: "conditional", type: "keyword" }),
|
|
1149
|
+
autocomplete.snippetCompletion("when ${condition}:\n\t${}", { label: "when", detail: "conditional", type: "keyword" }),
|
|
1150
|
+
autocomplete.snippetCompletion("cond:\n\t${condition}: ${result}\n\telse: ${default}", { label: "cond", detail: "conditional", type: "keyword" }),
|
|
1151
|
+
autocomplete.snippetCompletion("each ${item} ${items}:\n\t${}", { label: "each", detail: "loop", type: "keyword" }),
|
|
1152
|
+
autocomplete.snippetCompletion("for ${item} ${items}:\n\t${}", { label: "for", detail: "list comprehension", type: "keyword" }),
|
|
1153
|
+
autocomplete.snippetCompletion("loop [${name} ${init}]:\n\tif ${condition}:\n\t\trecur(${next})\n\t\t${result}", { label: "loop", detail: "loop with recur", type: "keyword" }),
|
|
1154
|
+
autocomplete.snippetCompletion("${name} =: ${value}", { label: "=:", detail: "binding", type: "keyword" }),
|
|
1155
|
+
];
|
|
1156
|
+
const header = autocomplete.snippetCompletion("!YS-v0\n\n${}", { label: "!YS-v0", detail: "YAMLScript header", type: "keyword" });
|
|
1157
|
+
const builtinOptions = [
|
|
1158
|
+
...ysStd.map((label) => ({ label, type: "function", detail: "ys::std" })),
|
|
1159
|
+
...specialForms.map((label) => ({ label, type: "keyword", detail: "special form" })),
|
|
1160
|
+
...coreMacros.map((label) => ({ label, type: "keyword", detail: "macro" })),
|
|
1161
|
+
...coreFunctions.map((label) => ({ label, type: "function" })),
|
|
1162
|
+
...coreVars.map((label) => ({ label, type: "variable" })),
|
|
1163
|
+
{ label: "true", type: "constant" },
|
|
1164
|
+
{ label: "false", type: "constant" },
|
|
1165
|
+
{ label: "nil", type: "constant" },
|
|
1166
|
+
];
|
|
1167
|
+
// The cursor is at the start of the file's code, so the `!YS-v0` header can
|
|
1168
|
+
// go there.
|
|
1169
|
+
function atFileStart(state, from) {
|
|
1170
|
+
return /^(\s*#.*\n|\s*\n)*\s*$/.test(state.sliceDoc(0, from));
|
|
1171
|
+
}
|
|
1172
|
+
/// Completes ys::std and clojure.core names, the constants and the
|
|
1173
|
+
/// snippets. At the start of the file it offers the `!YS-v0` header.
|
|
1174
|
+
const builtinCompletionSource = (context) => {
|
|
1175
|
+
const inner = language.syntaxTree(context.state).resolveInner(context.pos, -1);
|
|
1176
|
+
const tag = context.matchBefore(/![\w/-]*$/);
|
|
1177
|
+
if (tag && atFileStart(context.state, tag.from)) {
|
|
1178
|
+
return { from: tag.from, options: [header], validFor: /^![\w/-]*$/ };
|
|
1179
|
+
}
|
|
1180
|
+
if (inNode(inner, dontComplete) || inDefinition(context))
|
|
1181
|
+
return null;
|
|
1182
|
+
const word = context.matchBefore(wordBefore);
|
|
1183
|
+
if (!word && !context.explicit)
|
|
1184
|
+
return null;
|
|
1185
|
+
const from = word ? word.from : context.pos;
|
|
1186
|
+
const options = atFileStart(context.state, from) ? [header, ...snippets, ...builtinOptions] : [...snippets, ...builtinOptions];
|
|
1187
|
+
return { from, options, validFor: Identifier };
|
|
1188
|
+
};
|
|
1189
|
+
// A new function name or parameter is being typed, as in `defn f‸` or
|
|
1190
|
+
// `defn f(a b‸)`. Until the line ends with its ":", the line isn't a key
|
|
1191
|
+
// yet, so the text before the cursor decides.
|
|
1192
|
+
const typingDefinition = /^\s*(defn-?|defmacro)\s+([\w?!+*-]*|\S+\([^)]*)$/;
|
|
1193
|
+
function inDefinition(context) {
|
|
1194
|
+
const line = context.state.doc.lineAt(context.pos);
|
|
1195
|
+
return typingDefinition.test(context.state.sliceDoc(line.from, context.pos));
|
|
1196
|
+
}
|
|
1197
|
+
// These words bind names, as in `loop [n 0 acc []]:` or `for x xs, y ys:`.
|
|
1198
|
+
const bindingWords = new Set([
|
|
1199
|
+
"let", "loop", "for", "each", "doseq", "dotimes", "binding",
|
|
1200
|
+
"if-let", "when-let", "if-some", "when-some", "when-first",
|
|
1201
|
+
]);
|
|
1202
|
+
// Adds the names bound by a pattern such as `x`, `*rest`, `[a b]` or
|
|
1203
|
+
// `{:keys [a]}`.
|
|
1204
|
+
function addPattern(state, node, type, names) {
|
|
1205
|
+
if (node.name == "VariableName") {
|
|
1206
|
+
const name = state.sliceDoc(node.from, node.to);
|
|
1207
|
+
if (name != "_" && !names.has(name))
|
|
1208
|
+
names.set(name, type);
|
|
1209
|
+
}
|
|
1210
|
+
else if (node.name == "Splat") {
|
|
1211
|
+
const name = state.sliceDoc(node.from + 1, node.to);
|
|
1212
|
+
if (!names.has(name))
|
|
1213
|
+
names.set(name, type);
|
|
1214
|
+
}
|
|
1215
|
+
else if (node.name == "Vector" || node.name == "Map" || node.name == "AssignTarget") {
|
|
1216
|
+
for (let child = node.firstChild; child; child = child.nextSibling)
|
|
1217
|
+
addPattern(state, child, type, names);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
// The parameters of `fn(a b)`, `fn [a b]` or `fn([a b] body)`.
|
|
1221
|
+
function addFnParams(state, fn, names) {
|
|
1222
|
+
var _a;
|
|
1223
|
+
const params = fn.getChild("ParamList") || fn.getChild("Vector");
|
|
1224
|
+
if (!params)
|
|
1225
|
+
return;
|
|
1226
|
+
const first = (_a = params.firstChild) === null || _a === void 0 ? void 0 : _a.nextSibling;
|
|
1227
|
+
if (params.name == "ParamList" && (first === null || first === void 0 ? void 0 : first.name) == "Vector")
|
|
1228
|
+
addPattern(state, first, "variable", names);
|
|
1229
|
+
else
|
|
1230
|
+
for (let child = params.firstChild; child; child = child.nextSibling)
|
|
1231
|
+
addPattern(state, child, "variable", names);
|
|
1232
|
+
}
|
|
1233
|
+
// The names bound by a binding word at the start of a key or a list. A
|
|
1234
|
+
// single vector holds name and value pairs, and otherwise the forms after
|
|
1235
|
+
// the word are the pairs.
|
|
1236
|
+
function addBindings(state, word, names) {
|
|
1237
|
+
if (!bindingWords.has(state.sliceDoc(word.from, word.to)))
|
|
1238
|
+
return;
|
|
1239
|
+
const forms = [];
|
|
1240
|
+
for (let child = word.nextSibling; child; child = child.nextSibling) {
|
|
1241
|
+
if (child.type.isError || child.name == "Comment" || child.name == ")")
|
|
1242
|
+
continue;
|
|
1243
|
+
forms.push(child);
|
|
1244
|
+
}
|
|
1245
|
+
const pairs = forms.length == 1 && forms[0].name == "Vector" ? vectorItems(forms[0]) : forms;
|
|
1246
|
+
for (let i = 0; i < pairs.length; i += 2)
|
|
1247
|
+
addPattern(state, pairs[i], "variable", names);
|
|
1248
|
+
}
|
|
1249
|
+
function vectorItems(vector) {
|
|
1250
|
+
const items = [];
|
|
1251
|
+
for (let child = vector.firstChild; child; child = child.nextSibling) {
|
|
1252
|
+
if (child.type.isError || child.name == "Comment" || /^[-+]?[\[\]]$/.test(child.name))
|
|
1253
|
+
continue;
|
|
1254
|
+
items.push(child);
|
|
1255
|
+
}
|
|
1256
|
+
return items;
|
|
1257
|
+
}
|
|
1258
|
+
// The names that a node makes visible inside itself.
|
|
1259
|
+
function addScope(state, node, names) {
|
|
1260
|
+
var _a, _b;
|
|
1261
|
+
switch (node.name) {
|
|
1262
|
+
case "Mapping":
|
|
1263
|
+
case "CompactMapping":
|
|
1264
|
+
for (let entry = node.firstChild; entry; entry = entry.nextSibling) {
|
|
1265
|
+
if (entry.name == "FunctionDefinition") {
|
|
1266
|
+
const name = entry.getChild("DefName");
|
|
1267
|
+
const text = name && state.sliceDoc(name.from, name.to);
|
|
1268
|
+
if (text && !names.has(text))
|
|
1269
|
+
names.set(text, "function");
|
|
1270
|
+
}
|
|
1271
|
+
else if (entry.name == "Assignment") {
|
|
1272
|
+
const target = entry.getChild("AssignTarget");
|
|
1273
|
+
const value = (_a = target === null || target === void 0 ? void 0 : target.nextSibling) === null || _a === void 0 ? void 0 : _a.nextSibling;
|
|
1274
|
+
if (target)
|
|
1275
|
+
addPattern(state, target, (value === null || value === void 0 ? void 0 : value.name) == "FnExpression" ? "function" : "variable", names);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
break;
|
|
1279
|
+
case "FunctionDefinition": {
|
|
1280
|
+
const params = node.getChild("ParamList");
|
|
1281
|
+
if (params)
|
|
1282
|
+
for (let child = params.firstChild; child; child = child.nextSibling)
|
|
1283
|
+
addPattern(state, child, "variable", names);
|
|
1284
|
+
break;
|
|
1285
|
+
}
|
|
1286
|
+
case "FnExpression":
|
|
1287
|
+
addFnParams(state, node, names);
|
|
1288
|
+
break;
|
|
1289
|
+
}
|
|
1290
|
+
// A key such as `fn(x):` or `loop [n 0]:` binds names for the whole entry,
|
|
1291
|
+
// and a list such as `(fn [x] ...)` or `(let [a 1] ...)` binds them for
|
|
1292
|
+
// the rest of the list.
|
|
1293
|
+
const holder = node.name == "Pair" || node.name == "ExplicitPair" ? node.getChild("Key") : node;
|
|
1294
|
+
if (!holder || node.name == "FnExpression")
|
|
1295
|
+
return;
|
|
1296
|
+
for (let child = holder.firstChild; child; child = child.nextSibling) {
|
|
1297
|
+
if (child.name == "FnExpression")
|
|
1298
|
+
addFnParams(state, child, names);
|
|
1299
|
+
}
|
|
1300
|
+
const first = ((_b = holder.firstChild) === null || _b === void 0 ? void 0 : _b.name) == "(" ? holder.firstChild.nextSibling : holder.firstChild;
|
|
1301
|
+
if ((first === null || first === void 0 ? void 0 : first.name) == "ControlKeyword" && (holder.name == "Key" || holder.name == "ParenthesizedExpression")) {
|
|
1302
|
+
addBindings(state, first, names);
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
/// Completes the functions, bindings and parameters defined in the file that
|
|
1306
|
+
/// are in scope at the cursor.
|
|
1307
|
+
const localCompletionSource = (context) => {
|
|
1308
|
+
const inner = language.syntaxTree(context.state).resolveInner(context.pos, -1);
|
|
1309
|
+
if (inNode(inner, dontComplete) || inDefinition(context))
|
|
1310
|
+
return null;
|
|
1311
|
+
const word = context.matchBefore(wordBefore);
|
|
1312
|
+
if (!word && !context.explicit)
|
|
1313
|
+
return null;
|
|
1314
|
+
const names = new Map();
|
|
1315
|
+
for (let node = inner; node; node = node.parent)
|
|
1316
|
+
addScope(context.state, node, names);
|
|
1317
|
+
// The name being typed is in the tree as a name of its own, and offering
|
|
1318
|
+
// it back as its own completion helps nobody.
|
|
1319
|
+
if (word)
|
|
1320
|
+
names.delete(word.text);
|
|
1321
|
+
const options = [...names].map(([label, type]) => ({ label, type, boost: 1 }));
|
|
1322
|
+
return { from: word ? word.from : context.pos, options, validFor: Identifier };
|
|
1323
|
+
};
|
|
1324
|
+
|
|
1325
|
+
// Folding an entry keeps its key line in view, which says what was folded
|
|
1326
|
+
// away.
|
|
1327
|
+
function foldBody(node, state) {
|
|
1328
|
+
const line = state.doc.lineAt(node.from);
|
|
1329
|
+
return node.to > line.to ? { from: line.to, to: node.to } : null;
|
|
1330
|
+
}
|
|
1331
|
+
// YAML's indentation decides where a block ends, so the tree can't say where
|
|
1332
|
+
// a new line belongs. The line above decides. A line that ends a key with
|
|
1333
|
+
// ":" or "::", starts a block scalar, or leaves a bracket open is followed by
|
|
1334
|
+
// one indented under it. Any other line is followed by one at its own
|
|
1335
|
+
// indentation.
|
|
1336
|
+
const opensBlock = /(:|::|[|>][-+0-9]*|\(|\[|\{)$/;
|
|
1337
|
+
const indentYamlscript = language.indentService.of((context, pos) => {
|
|
1338
|
+
const inside = language.syntaxTree(context.state).resolveInner(pos, -1).name;
|
|
1339
|
+
if (inside == "BlockScalar" || inside == "String")
|
|
1340
|
+
return null;
|
|
1341
|
+
let line = context.lineAt(pos, -1);
|
|
1342
|
+
while (!/\S/.test(line.text) && line.from > 0)
|
|
1343
|
+
line = context.lineAt(line.from - 1, -1);
|
|
1344
|
+
if (!/\S/.test(line.text))
|
|
1345
|
+
return 0;
|
|
1346
|
+
const code = line.text.replace(/(^|\s)#.*$/, "").trimEnd();
|
|
1347
|
+
const base = context.lineIndent(line.from);
|
|
1348
|
+
return opensBlock.test(code) ? base + context.unit : base;
|
|
1349
|
+
});
|
|
1350
|
+
const yamlscriptLanguage = language.LRLanguage.define({
|
|
1351
|
+
name: "yamlscript",
|
|
1352
|
+
parser: parser.configure({
|
|
1353
|
+
props: [
|
|
1354
|
+
language.foldNodeProp.add({
|
|
1355
|
+
"Pair Assignment FunctionDefinition ExplicitPair DataPair": foldBody,
|
|
1356
|
+
"SequenceItem DataItem": foldBody,
|
|
1357
|
+
"ArgList ParamList ParenthesizedExpression Vector Map Set AnonymousFunction": language.foldInside,
|
|
1358
|
+
}),
|
|
1359
|
+
highlight.styleTags({
|
|
1360
|
+
Comment: highlight.tags.lineComment,
|
|
1361
|
+
Tag: highlight.tags.meta,
|
|
1362
|
+
"defn defn- defmacro fn": highlight.tags.definitionKeyword,
|
|
1363
|
+
'ControlKeyword "=>"': highlight.tags.controlKeyword,
|
|
1364
|
+
Boolean: highlight.tags.bool,
|
|
1365
|
+
Nil: highlight.tags.null,
|
|
1366
|
+
Number: highlight.tags.number,
|
|
1367
|
+
"String BlockScalar PlainScalar": highlight.tags.string,
|
|
1368
|
+
"DataKey/PlainScalar": highlight.tags.propertyName,
|
|
1369
|
+
Character: highlight.tags.character,
|
|
1370
|
+
Regex: highlight.tags.regexp,
|
|
1371
|
+
Keyword: highlight.tags.atom,
|
|
1372
|
+
DefName: highlight.tags.definition(highlight.tags.function(highlight.tags.variableName)),
|
|
1373
|
+
"FunctionDefinition/ParamList/VariableName FnExpression/ParamList/VariableName FnExpression/Vector/VariableName": highlight.tags.definition(highlight.tags.variableName),
|
|
1374
|
+
"AssignTarget/VariableName AssignTarget/Vector/VariableName": highlight.tags.definition(highlight.tags.variableName),
|
|
1375
|
+
"CallExpression/VariableName ChainCall/FunctionName": highlight.tags.function(highlight.tags.variableName),
|
|
1376
|
+
"CallExpression/MemberExpression/PropertyName CallExpression/LeadingMember/PropertyName": highlight.tags.function(highlight.tags.propertyName),
|
|
1377
|
+
VariableName: highlight.tags.variableName,
|
|
1378
|
+
PropertyName: highlight.tags.propertyName,
|
|
1379
|
+
"Variable Splat": highlight.tags.special(highlight.tags.variableName),
|
|
1380
|
+
"Operator KeyOperator PostfixOperator": highlight.tags.operator,
|
|
1381
|
+
AssignOp: highlight.tags.definitionOperator,
|
|
1382
|
+
".": highlight.tags.derefOperator,
|
|
1383
|
+
'"\\\\\'"': highlight.tags.operator,
|
|
1384
|
+
'"(" ")" "\\\\("': highlight.tags.paren,
|
|
1385
|
+
'"[" "]" "-[" "+["': highlight.tags.squareBracket,
|
|
1386
|
+
'"{" "}" "-{" "+{" "\\\\{"': highlight.tags.brace,
|
|
1387
|
+
}),
|
|
1388
|
+
],
|
|
1389
|
+
}),
|
|
1390
|
+
languageData: {
|
|
1391
|
+
commentTokens: { line: "#" },
|
|
1392
|
+
closeBrackets: { brackets: ["(", "[", "{", '"', "'"] },
|
|
1393
|
+
},
|
|
1394
|
+
});
|
|
1395
|
+
/// YAMLScript language support, with completion for ys::std and clojure.core
|
|
1396
|
+
/// names, snippets, and the names defined in the file.
|
|
1397
|
+
function yamlscript() {
|
|
1398
|
+
return new language.LanguageSupport(yamlscriptLanguage, [
|
|
1399
|
+
indentYamlscript,
|
|
1400
|
+
yamlscriptLanguage.data.of({ autocomplete: localCompletionSource }),
|
|
1401
|
+
yamlscriptLanguage.data.of({ autocomplete: builtinCompletionSource }),
|
|
1402
|
+
]);
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
exports.builtinCompletionSource = builtinCompletionSource;
|
|
1406
|
+
exports.localCompletionSource = localCompletionSource;
|
|
1407
|
+
exports.parser = parser;
|
|
1408
|
+
exports.snippets = snippets;
|
|
1409
|
+
exports.yamlscript = yamlscript;
|
|
1410
|
+
exports.yamlscriptLanguage = yamlscriptLanguage;
|