@exercism/codemirror-lang-nim 0.0.0-stage → 1.0.1

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/dist/index.cjs ADDED
@@ -0,0 +1,818 @@
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 BlockComment = 1,
10
+ newline = 201,
11
+ skipNewline = 202,
12
+ indent = 203,
13
+ dedent = 204,
14
+ callParen = 2,
15
+ indexBracket = 3,
16
+ RawString = 4,
17
+ op0 = 5,
18
+ op1 = 6,
19
+ op2 = 7,
20
+ op5 = 8,
21
+ op6 = 9,
22
+ op7 = 10,
23
+ op8 = 11,
24
+ op9 = 12,
25
+ op10 = 13,
26
+ prefixOp = 14,
27
+ eq = 15,
28
+ colon = 16,
29
+ dot = 17,
30
+ star = 18,
31
+ pragmaClose = 19,
32
+ ParenR = 31,
33
+ ParenL = 32,
34
+ PragmaOpen = 49,
35
+ BraceR = 50,
36
+ BracketR = 79,
37
+ BracketL = 80,
38
+ BraceL = 82;
39
+
40
+ const lf = 10, cr = 13, space = 32, tab = 9, hash = 35, quote = 34, apostrophe = 39,
41
+ backtick = 96, parenOpen = 40, parenClose = 41, bracketOpen = 91, bracketClose = 93,
42
+ braceOpen = 123, braceClose = 125, dotChar = 46, underscore = 95;
43
+
44
+ function isIdentChar(ch) {
45
+ return (ch >= 48 && ch <= 57) || (ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122) ||
46
+ ch == underscore || ch >= 0xa1;
47
+ }
48
+
49
+ function isIdentStart(ch) {
50
+ return (ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122) || ch == underscore || ch >= 0xa1;
51
+ }
52
+
53
+ function isLineBreak(ch) {
54
+ return ch == lf || ch == cr;
55
+ }
56
+
57
+ const operatorChars = new Set("=+-*/<>@$~&%|!?^.:\\".split("").map((c) => c.charCodeAt(0)));
58
+
59
+ // A context records how deep the current block is indented, and whether the
60
+ // parser is inside brackets. Inside brackets, line breaks don't end
61
+ // statements, apart from the body of a `proc` written inside a call, which
62
+ // gets a block of its own (an "inner" block).
63
+ const cx_Bracketed = 1, cx_Block = 2, cx_Inner = 4;
64
+
65
+ class Context {
66
+ constructor(parent, indent, flags) {
67
+ this.parent = parent;
68
+ this.indent = indent;
69
+ this.flags = flags;
70
+ this.hash = (parent ? (parent.hash + parent.hash) << 8 : 0) + indent + (indent << 4) + flags + (flags << 6);
71
+ }
72
+ }
73
+
74
+ const topContext = new Context(null, 0, 0);
75
+
76
+ // Skips a `#[ ... ]#` comment, which may be nested. `peek(i)` returns the
77
+ // character at offset `i`, and `i` points at the `#`. Returns the offset
78
+ // just after the comment.
79
+ function skipBlockComment(peek, i) {
80
+ i += 2;
81
+ for (let depth = 1; ; ) {
82
+ const ch = peek(i);
83
+ if (ch < 0) return i;
84
+ if (ch == hash && peek(i + 1) == bracketOpen) {
85
+ depth++;
86
+ i += 2;
87
+ } else if (ch == bracketClose && peek(i + 1) == hash) {
88
+ i += 2;
89
+ if (--depth == 0) return i;
90
+ } else i++;
91
+ }
92
+ }
93
+
94
+ // Finds the next line that holds code, starting at offset `i` (the start of
95
+ // a line). Blank lines and lines holding only a comment are passed over.
96
+ // Returns the line's indentation and the offset of its first character, or
97
+ // `eof: true` if there is no such line.
98
+ function nextCodeLine(peek, i) {
99
+ for (;;) {
100
+ let depth = 0;
101
+ for (;;) {
102
+ const ch = peek(i);
103
+ if (ch == space) depth++;
104
+ else if (ch == tab) depth += 8 - (depth % 8);
105
+ else break;
106
+ i++;
107
+ }
108
+ let ch = peek(i);
109
+ if (ch < 0) return { depth: 0, start: i, eof: true };
110
+ if (ch == hash && peek(i + 1) == bracketOpen) {
111
+ i = skipBlockComment(peek, i);
112
+ while (peek(i) == space || peek(i) == tab) i++;
113
+ ch = peek(i);
114
+ if (ch < 0) return { depth: 0, start: i, eof: true };
115
+ if (!isLineBreak(ch) && ch != hash) return { depth, start: i, eof: false };
116
+ }
117
+ if (ch == hash) {
118
+ while (peek(i) >= 0 && !isLineBreak(peek(i))) i++;
119
+ ch = peek(i);
120
+ if (ch < 0) return { depth: 0, start: i, eof: true };
121
+ }
122
+ if (isLineBreak(ch)) {
123
+ i++;
124
+ if (ch == cr && peek(i) == lf) i++;
125
+ continue;
126
+ }
127
+ return { depth, start: i, eof: false };
128
+ }
129
+ }
130
+
131
+ function wordAt(peek, i) {
132
+ let word = "";
133
+ while (isIdentChar(peek(i)) && word.length < 10) word += String.fromCharCode(peek(i++));
134
+ return isIdentChar(peek(i)) ? "" : word;
135
+ }
136
+
137
+ // A line starting with one of these words carries on the statement above it
138
+ // when it is indented to the same depth, as in `if ...` followed by `else:`.
139
+ const continuationWords = new Set(["elif", "else", "of", "except", "finally"]);
140
+
141
+ // True if the line ending at offset 0 (the line break) holds nothing but
142
+ // spaces and maybe a comment.
143
+ function lineIsBlank(input) {
144
+ let first = -1;
145
+ for (let i = -1; ; i--) {
146
+ const ch = input.peek(i);
147
+ if (ch < 0 || isLineBreak(ch)) break;
148
+ if (ch != space && ch != tab) first = ch;
149
+ }
150
+ return first < 0 || first == hash;
151
+ }
152
+
153
+ function afterLineBreak(input) {
154
+ return input.next == cr && input.peek(1) == lf ? 2 : 1;
155
+ }
156
+
157
+ const newlines = new lr.ExternalTokenizer(
158
+ (input, stack) => {
159
+ const context = stack.context;
160
+ const next = input.next;
161
+
162
+ if (next < 0) {
163
+ if (context.flags & cx_Block && stack.canShift(dedent)) input.acceptToken(dedent);
164
+ return;
165
+ }
166
+
167
+ // The body of a `proc` inside a call ends where the call's bracket
168
+ // closes, even on the same line.
169
+ if (context.flags & cx_Inner && (next == parenClose || next == bracketClose || next == braceClose)) {
170
+ if (stack.canShift(dedent)) input.acceptToken(dedent);
171
+ return;
172
+ }
173
+
174
+ if (!isLineBreak(next)) return;
175
+ const breakLength = afterLineBreak(input);
176
+ const peek = (i) => input.peek(i);
177
+
178
+ if (lineIsBlank(input)) {
179
+ input.acceptToken(skipNewline, breakLength);
180
+ return;
181
+ }
182
+
183
+ const line = nextCodeLine(peek, breakLength);
184
+
185
+ if (context.flags & cx_Bracketed) {
186
+ if (!line.eof && line.depth > context.indent && stack.canShift(indent)) input.acceptToken(indent, breakLength);
187
+ else input.acceptToken(skipNewline, breakLength);
188
+ return;
189
+ }
190
+
191
+ if (context.flags & cx_Block && line.depth < context.indent && stack.canShift(dedent)) {
192
+ input.acceptToken(dedent);
193
+ return;
194
+ }
195
+
196
+ if (!line.eof) {
197
+ // A line starting with `.name` continues a chain of calls.
198
+ if (line.depth > context.indent && peek(line.start) == dotChar && isIdentStart(peek(line.start + 1))) {
199
+ input.acceptToken(skipNewline, breakLength);
200
+ return;
201
+ }
202
+ if (line.depth > context.indent && stack.canShift(indent)) {
203
+ input.acceptToken(indent, breakLength);
204
+ return;
205
+ }
206
+ if (line.depth == context.indent && continuationWords.has(wordAt(peek, line.start))) {
207
+ input.acceptToken(skipNewline, breakLength);
208
+ return;
209
+ }
210
+ }
211
+
212
+ if (stack.canShift(newline)) input.acceptToken(newline, breakLength);
213
+ else input.acceptToken(skipNewline, breakLength);
214
+ },
215
+ { contextual: true, fallback: true }
216
+ );
217
+
218
+ // Nim tells a call `f(x)` from a command `f (x)` by the space before the
219
+ // bracket. The same goes for `a[i]` and `fmt"..."`.
220
+ const adjacent = new lr.ExternalTokenizer(
221
+ (input, stack) => {
222
+ const next = input.next;
223
+ const prev = input.peek(-1);
224
+ const touching = isIdentChar(prev) || prev == parenClose || prev == bracketClose ||
225
+ prev == braceClose || prev == quote || prev == apostrophe || prev == backtick;
226
+ if (!touching) return;
227
+ if (next == parenOpen) {
228
+ if (stack.canShift(callParen)) input.acceptToken(callParen, 1);
229
+ } else if (next == bracketOpen) {
230
+ if (stack.canShift(indexBracket)) input.acceptToken(indexBracket, 1);
231
+ } else if (next == quote && isIdentChar(prev) && stack.canShift(RawString)) {
232
+ // A string right after a name is raw: `""` stands for a quote, and a
233
+ // backslash is just a backslash.
234
+ if (input.peek(1) == quote && input.peek(2) == quote) {
235
+ input.advance(3);
236
+ for (;;) {
237
+ if (input.next < 0) break;
238
+ if (input.next == quote && input.peek(1) == quote && input.peek(2) == quote) {
239
+ input.advance(3);
240
+ while (input.next == quote) input.advance();
241
+ break;
242
+ }
243
+ input.advance();
244
+ }
245
+ } else {
246
+ input.advance();
247
+ for (;;) {
248
+ if (input.next < 0 || isLineBreak(input.next)) break;
249
+ if (input.next == quote) {
250
+ input.advance();
251
+ if (input.next == quote) input.advance();
252
+ else break;
253
+ } else input.advance();
254
+ }
255
+ }
256
+ input.acceptToken(RawString);
257
+ }
258
+ },
259
+ { contextual: true }
260
+ );
261
+
262
+ const blockComment = new lr.ExternalTokenizer((input) => {
263
+ if (input.next != hash || input.peek(1) != bracketOpen) return;
264
+ const end = skipBlockComment((i) => input.peek(i), 0);
265
+ input.acceptToken(BlockComment, end);
266
+ });
267
+
268
+ // Nim decides an operator's precedence from its first character, with two
269
+ // exceptions: one ending in `=` assigns, and one ending in `->`, `=>` or
270
+ // `~>` is an arrow and binds most loosely.
271
+ function operatorTerm(text) {
272
+ if (text == "=") return eq;
273
+ if (text == ":") return colon;
274
+ if (text == ".") return dot;
275
+ if (text == "*") return star;
276
+ const last = text.length - 1;
277
+ if (text[last] == ">" && (text[last - 1] == "-" || text[last - 1] == "=" || text[last - 1] == "~")) return op0;
278
+ if (text[last] == "=" && !"<>!=~?".includes(text[0])) return op1;
279
+ switch (text[0]) {
280
+ case "$": case "^": return op10;
281
+ case "*": case "%": case "\\": case "/": return op9;
282
+ case "+": case "-": case "~": case "|": return op8;
283
+ case "&": return op7;
284
+ case ".": return op6;
285
+ case "=": case "<": case ">": case "!": return op5;
286
+ default: return op2;
287
+ }
288
+ }
289
+
290
+ const operators = new lr.ExternalTokenizer((input) => {
291
+ if (!operatorChars.has(input.next)) return;
292
+ if (input.next == dotChar && input.peek(1) == braceClose) {
293
+ input.acceptToken(pragmaClose, 2);
294
+ return;
295
+ }
296
+ const prev = input.peek(-1);
297
+ let text = "";
298
+ while (operatorChars.has(input.next)) {
299
+ // `name*: T` marks a field as exported: the `*` and the `:` are two
300
+ // tokens, as they are in Nim.
301
+ if (text == "*" && input.next == 58) break;
302
+ text += String.fromCharCode(input.next);
303
+ input.advance();
304
+ }
305
+ // As in Nim, an operator with space (or an opening bracket) before it and
306
+ // none after it is unary, so `echo -1` passes `-1` to `echo`.
307
+ const term = operatorTerm(text);
308
+ if (term != eq && term != colon && term != dot && term != star && term != op1 &&
309
+ (prev < 0 || prev == space || prev == tab || isLineBreak(prev) || prev == parenOpen ||
310
+ prev == bracketOpen || prev == braceOpen || prev == 44 || prev == 59) &&
311
+ input.next != space && input.next != tab && !isLineBreak(input.next) && input.next >= 0) {
312
+ input.acceptToken(prefixOp);
313
+ return;
314
+ }
315
+ input.acceptToken(term);
316
+ });
317
+
318
+ // The depth of the line that an `indent` token at `pos` opens.
319
+ function indentAfter(input, pos) {
320
+ const peek = (i) => {
321
+ const s = input.read(pos + i, pos + i + 1);
322
+ return s.length ? s.charCodeAt(0) : -1;
323
+ };
324
+ return nextCodeLine(peek, 0).depth;
325
+ }
326
+
327
+ const opening = new Set([ParenL, BracketL, BraceL, PragmaOpen, callParen, indexBracket]);
328
+ const closing = new Set([ParenR, BracketR, BraceR, pragmaClose]);
329
+
330
+ const trackIndent = new lr.ContextTracker({
331
+ start: topContext,
332
+ shift(context, term, stack, input) {
333
+ if (term == indent) {
334
+ const flags = context.flags & (cx_Bracketed | cx_Inner) ? cx_Block | cx_Inner : cx_Block;
335
+ return new Context(context, indentAfter(input, stack.pos), flags);
336
+ }
337
+ if (term == dedent) return context.parent || context;
338
+ if (opening.has(term)) return new Context(context, context.indent, cx_Bracketed);
339
+ if (closing.has(term) && context.flags & cx_Bracketed) return context.parent;
340
+ return context;
341
+ },
342
+ hash(context) {
343
+ return context.hash;
344
+ },
345
+ });
346
+
347
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
348
+ const spec_identifier = {__proto__:null,true:58, false:58, nil:60, proc:70, var:82, ref:84, ptr:86, distinct:88, out:90, static:92, if:112, elif:118, else:122, of:126, except:130, as:132, finally:138, when:142, case:146, try:152, block:156, div:182, mod:184, shl:186, shr:188, and:190, or:192, xor:194, not:196, in:198, is:200, type:202, addr:204, tuple:206, object:208, enum:210, notin:220, isnot:222, cast:226, let:236, const:238, return:248, break:252, continue:256, discard:260, raise:264, yield:268, for:272, while:276, defer:280, func:322, method:324, iterator:326, template:328, macro:330, converter:332, import:338, from:342, include:346, export:350, mixin:354, bind:356};
349
+ const parser = lr.LRParser.deserialize({
350
+ version: 14,
351
+ states: "!0WO$tQkOOOOQ_'#Ct'#CtO&SQkO'#D^OOQR'#G}'#G}O&^QkO'#C}O&tQkO'#EPO&{QkO'#ERO*UQoO'#GvO*]QkO'#ElOOQ_'#Gw'#GwOOQR'#Gv'#GvOOQR'#Cs'#CsOOQR'#Gu'#GuO+aQcO'#FrO+iQkO'#GVOOQR'#Gt'#GtO+zQkO'#GkO.cQcO'#GsO.cQcO'#GsQOQcOOO/`QoO'#DOO*]QkO'#DeO*]QkO'#DtO*]QkO'#DvO/jQkO'#DyO/oQkO'#D{O/zQgO'#EpO0SQgO'#ErO0[QcO'#EuO0jQkO'#E{O1mQcO'#E}OOQR'#FP'#FPO2eQkO'#FRO3hQkO'#FTO4kQkO'#FVO5nQcO'#FXO*]QkO'#FZO/jQkO'#F]O/jQkO'#F_O5yQcO'#FaOOQR'#H['#H[O*]QkO'#FzO*]QkO'#F|O*]QkO'#GOO*]QkO'#GQO$lQcO'#GSOOQ_,59x,59xO6UQkO,59xO6^QoO'#G|OOQZ'#G|'#G|OOQZ'#G{'#G{O8cQkO'#GzO8tQoO'#DOOOQ_,59i,59iO9hQcO,59iOOQ_,5:k,5:kO9mQcO,5:kOOQ_,5:m,5:mO9rQcO,5:mO9wQkO'#Dg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&^Q)k(sQ)r(xQ)y)]Q*])sQ*w*sR+O*vQ!PQQ!WSQ!YTQ![UQ$Q!^R$U!a[!TQSTU!^!aV%z#w%{'rb!SQSTU!^!a#w%{'rQ$r!xQ%y#vQ&c$sQ(V&fQ)a(WQ)e(aR){)bpYO`mpqr!]!l#|$e%f'R(k(l)g*PQ!WSR$Q!^d%P#O#P$|$}%Q%Y%Z&i&j&uT&l%R&mQ#oyQ#q{Q#r|Q&p%UQ&s%VQ'n%vR+R*zQ%a#UR(f&{Q#[lQ%i#ZR(n'WU#Wl#Z'WR'P%dQ#dsQ%h#XR%m#eV#kw#l'hQ'c%qR)O'gR)p(uS)n(u*WQ+V+SR+W+UW)m(u*W+S+UQ*Z)qR*g*TQ(|'fQ)t({Q*b)uV*n*^*_*pV]O`#|Q$i!rS&Z$j$kR'{&[W$f!r$j$k&[S&W$g$hS'y&X&]S)Z'z'|R)x)[R#t}",
354
+ nodeNames: "⚠ BlockComment ( [ RawString Arrow UpdateOp Operator CompareOp RangeOp ArithOp ArithOp ArithOp ArithOp ArithOp = : . * .} LineComment DocComment Program ExpressionStatement VariableName Number String TripleString Char Boolean nil ) ( ParenthesizedExpression ProcExpression proc ParamList Param ParameterName Type TypeModifier var ref ptr distinct out static ProcType Pragma {. } ; , Block NamedArgument IfExpression if Body ElifBranch elif ElseBranch else OfBranch of ExceptBranch except as VariableDefinition FinallyBranch finally WhenExpression when CaseExpression case CaseBody TryExpression try BlockExpression block ] [ ArrayExpression { SetExpression CallExpression ArgList IndexExpression CallString MemberExpression PropertyName PropertyName div mod shl shr and or xor not in is type addr tuple object enum CommandCall CommandArgs UnaryExpression BinaryExpression notin isnot CastExpression cast TupleType FieldName AssignStatement VarSection let const VariableDeclaration TupleDeclaration SectionBody ReturnStatement return BreakStatement break ContinueStatement continue DiscardStatement discard RaiseStatement raise YieldStatement yield ForStatement for WhileStatement while DeferStatement defer StaticStatement BlockCall TypeSection TypeDefinition TypeName GenericParams TypeParam TypeParameter ObjectType ObjectBody FieldDeclaration RecordCase RecordCaseBody RecordBranch EnumType EnumMember EnumBody TupleBlock SectionBody RoutineDeclaration func method iterator template macro converter FunctionName ImportStatement import FromImportStatement from IncludeStatement include ExportStatement export MixinStatement mixin bind PragmaStatement",
355
+ maxTerm: 233,
356
+ context: trackIndent,
357
+ nodeProps: [
358
+ ["isolate", -4,20,21,26,27,""],
359
+ ["group", -22,23,116,117,123,125,127,129,131,133,135,137,139,141,142,143,160,168,170,172,174,176,179,"Statement",-19,24,25,26,27,28,29,30,33,81,83,84,86,87,88,106,108,109,112,114,"Expression"],
360
+ ["openedBy", 31,"(",50,"{",79,"["],
361
+ ["closedBy", 32,")",80,"]",82,"}"]
362
+ ],
363
+ skippedNodes: [0,1,20,21],
364
+ repeatNodeCount: 20,
365
+ tokenData: "6W~RfXY!gpq!grs!rst&qwx(exy*[yz*a|}*f!Q!R*k!R![/R!]!^3o!c!}3t!}#O4f#P#Q4k#R#S3t#S#T4p#T#o3t#o#p5t#q#r6R$g;'S3t;'S;=`4`<%lO3t~!lQ%f~XY!gpq!g~!uWOY#_Zr#_rs%Rs#O#_#O#P$P#P;'S#_;'S;=`${<%lO#_~#bWOY#_Zr#_rs#zs#O#_#O#P$P#P;'S#_;'S;=`${<%lO#_~$POj~~$SRO;'S#_;'S;=`$];=`O#_~$`XOY#_Zr#_rs#zs#O#_#O#P$P#P;'S#_;'S;=`${;=`<%l#_<%lO#_~%OP;=`<%l#_~%WPj~rs%Z~%^TOr%Zrs%ms;'S%Z;'S;=`&k<%lO%Z~%pTOr%Zrs&Ps;'S%Z;'S;=`&k<%lO%Z~&STOr%Zrs&cs;'S%Z;'S;=`&k<%lO%Z~&hPk~rs&c~&nP;=`<%l%Z~&vVd~OY']Z]']^s']st'wt;'S'];'S;=`'q<%lO']~'bTd~OY']Z]']^;'S'];'S;=`'q<%lO']~'tP;=`<%l']~(OTe~d~OY'wZ]'w^;'S'w;'S;=`(_<%lO'w~(bP;=`<%l'w~(hVOY(}Zw(}x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P;=`<%l3t~4kO!r~~4pO!q~~4sTOY5SZ#S5S#T;'S5S;'S;=`5n<%lO5S~5VUOY5SZ#S5S#S#T5i#T;'S5S;'S;=`5n<%lO5S~5nO%m~~5qP;=`<%l5S~5yP!t~!O!P5|~6RO!R~~6WO!S~",
366
+ tokenizers: [blockComment, newlines, adjacent, operators, 0],
367
+ topRules: {"Program":[0,22]},
368
+ specialized: [{term: 212, get: (value) => spec_identifier[value] || -1}],
369
+ tokenPrec: 6366
370
+ });
371
+
372
+ /// Snippets for the constructs people type most often.
373
+ const snippets = [
374
+ autocomplete.snippetCompletion("proc ${name}(${params}): ${type} =\n\t${}", {
375
+ label: "proc",
376
+ detail: "definition",
377
+ type: "keyword",
378
+ }),
379
+ autocomplete.snippetCompletion("func ${name}(${params}): ${type} =\n\t${}", {
380
+ label: "func",
381
+ detail: "definition",
382
+ type: "keyword",
383
+ }),
384
+ autocomplete.snippetCompletion("iterator ${name}(${params}): ${type} =\n\t${}", {
385
+ label: "iterator",
386
+ detail: "definition",
387
+ type: "keyword",
388
+ }),
389
+ autocomplete.snippetCompletion("if ${condition}:\n\t${}", {
390
+ label: "if",
391
+ detail: "block",
392
+ type: "keyword",
393
+ }),
394
+ autocomplete.snippetCompletion("if ${condition}:\n\t${}\nelse:\n\t${}", {
395
+ label: "if",
396
+ detail: "/ else block",
397
+ type: "keyword",
398
+ }),
399
+ autocomplete.snippetCompletion("elif ${condition}:\n\t${}", {
400
+ label: "elif",
401
+ detail: "branch",
402
+ type: "keyword",
403
+ }),
404
+ autocomplete.snippetCompletion("case ${value}\nof ${pattern}:\n\t${}\nelse:\n\t${}", {
405
+ label: "case",
406
+ detail: "block",
407
+ type: "keyword",
408
+ }),
409
+ autocomplete.snippetCompletion("for ${item} in ${items}:\n\t${}", {
410
+ label: "for",
411
+ detail: "loop",
412
+ type: "keyword",
413
+ }),
414
+ autocomplete.snippetCompletion("for ${i} in 0 ..< ${n}:\n\t${}", {
415
+ label: "for",
416
+ detail: "range loop",
417
+ type: "keyword",
418
+ }),
419
+ autocomplete.snippetCompletion("while ${condition}:\n\t${}", {
420
+ label: "while",
421
+ detail: "loop",
422
+ type: "keyword",
423
+ }),
424
+ autocomplete.snippetCompletion("try:\n\t${}\nexcept ${ValueError}:\n\t${}", {
425
+ label: "try",
426
+ detail: "/ except block",
427
+ type: "keyword",
428
+ }),
429
+ autocomplete.snippetCompletion("type\n\t${Name} = object\n\t\t${field}: ${type}", {
430
+ label: "type",
431
+ detail: "object",
432
+ type: "keyword",
433
+ }),
434
+ autocomplete.snippetCompletion("type\n\t${Name} = enum\n\t\t${}", {
435
+ label: "type",
436
+ detail: "enum",
437
+ type: "keyword",
438
+ }),
439
+ ];
440
+ function words(list, type) {
441
+ return list.split(" ").map((label) => ({ label, type }));
442
+ }
443
+ const keywords = words("addr and as asm bind block break case cast concept const continue converter defer discard distinct div do " +
444
+ "elif else enum except export finally for from func if import in include interface is isnot iterator let " +
445
+ "macro method mixin mod not notin object of or out proc ptr raise ref return shl shr static template try " +
446
+ "tuple type using var when while xor yield", "keyword");
447
+ const constants = words("true false nil", "constant");
448
+ const types = words("int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float float32 float64 bool char string cstring " +
449
+ "byte seq array set openArray varargs range Natural Positive void auto typedesc untyped typed " +
450
+ "Table OrderedTable CountTable HashSet Option Deque", "type");
451
+ // The procs of Nim's `system` module that solutions use most, then the most
452
+ // used ones from `strutils`, `sequtils`, `math`, `algorithm`, `tables` and
453
+ // `sets`.
454
+ const system = "echo len high low add inc dec ord chr newSeq newSeqOfCap newString newException max min abs assert " +
455
+ "doAssert items pairs mitems mpairs countup countdown contains find delete insert pop setLen sizeof typeof " +
456
+ "succ pred swap isNil toInt toFloat quit readLine";
457
+ const library = "split splitLines splitWhitespace join strip repeat replace parseInt parseFloat toUpperAscii toLowerAscii " +
458
+ "isUpperAscii isLowerAscii isDigit isAlphaAscii isSpaceAscii startsWith endsWith count align fmt format " +
459
+ "toSeq map filter mapIt filterIt allIt anyIt foldl zip concat deduplicate sum prod floorDiv floorMod " +
460
+ "euclDiv euclMod sqrt pow sort sorted reversed reverse initTable toTable newTable getOrDefault hasKey " +
461
+ "initHashSet toHashSet incl excl";
462
+ const builtins = words(system + " " + library, "function");
463
+ const modules = words("algorithm bitops deques math options random re sequtils sets strformat strutils sugar tables times unicode", "namespace");
464
+ // Common procs offered after a dot, because `x.len` calls `len(x)`.
465
+ const methods = words("len high low add contains find delete insert pop setLen ord chr toInt toFloat items pairs mitems " + library, "method");
466
+ const Identifier = /^[\w¡-￿]+$/;
467
+ const definitionNodes = new Set([
468
+ "FunctionName",
469
+ "VariableDefinition",
470
+ "ParameterName",
471
+ "TypeName",
472
+ "TypeParameter",
473
+ "FieldName",
474
+ "EnumMember",
475
+ ]);
476
+ const textNodes = new Set(["String", "TripleString", "RawString", "Char", "LineComment", "DocComment", "BlockComment"]);
477
+ const importNodes = new Set(["ImportStatement", "FromImportStatement"]);
478
+ const cache = new WeakMap();
479
+ function indentation(text) {
480
+ let n = 0;
481
+ while (n < text.length && (text[n] == " " || text[n] == "\t"))
482
+ n++;
483
+ return n;
484
+ }
485
+ // A block's node ends with its last statement, but its names stay in scope
486
+ // on the lines below that are blank or indented further than the line that
487
+ // opened the block. That covers a cursor on a fresh line at the end of a
488
+ // block.
489
+ function blockEnd(doc, block) {
490
+ const header = indentation(doc.lineAt(block.from).text);
491
+ let end = block.to;
492
+ for (let n = doc.lineAt(block.to).number + 1; n <= doc.lines; n++) {
493
+ const line = doc.line(n);
494
+ if (/\S/.test(line.text) && indentation(line.text) <= header)
495
+ break;
496
+ end = line.to;
497
+ }
498
+ return end;
499
+ }
500
+ // The end of a node's scope, following its indented block if it has one.
501
+ function extendedEnd(doc, node) {
502
+ let last = node.lastChild;
503
+ if ((last === null || last === void 0 ? void 0 : last.name) == "Body")
504
+ last = last.lastChild;
505
+ return (last === null || last === void 0 ? void 0 : last.name) == "Block" ? Math.max(node.to, blockEnd(doc, last)) : node.to;
506
+ }
507
+ // Names declared at the top of the file last to its end. Names declared in
508
+ // a block last to the end of the block.
509
+ function scopeEnd(doc, node) {
510
+ for (let p = node.parent; p; p = p.parent) {
511
+ if (p.name == "Block")
512
+ return blockEnd(doc, p);
513
+ if (p.name == "Program")
514
+ break;
515
+ }
516
+ return doc.length;
517
+ }
518
+ function collect(state, tree) {
519
+ const cached = cache.get(tree);
520
+ if (cached)
521
+ return cached;
522
+ const doc = state.doc;
523
+ const names = { definitions: [], fields: new Set(), procs: new Set() };
524
+ const define = (node, type, from, to) => {
525
+ const label = doc.sliceString(node.from, node.to);
526
+ if (Identifier.test(label))
527
+ names.definitions.push({ label, type, at: node.from, from, to });
528
+ };
529
+ tree.iterate({
530
+ enter: (ref) => {
531
+ var _a, _b, _c, _d;
532
+ const node = ref.node;
533
+ switch (node.name) {
534
+ case "FunctionName": {
535
+ // A proc can call itself, so its name is in scope from where it
536
+ // is written.
537
+ define(node, "function", node.from, scopeEnd(doc, node));
538
+ names.procs.add(doc.sliceString(node.from, node.to));
539
+ break;
540
+ }
541
+ case "ParameterName":
542
+ case "TypeParameter": {
543
+ // Param > ParamList > the proc, or TypeParam > GenericParams > the
544
+ // proc or type.
545
+ const owner = (_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.parent;
546
+ if (owner)
547
+ define(node, node.name == "TypeParameter" ? "type" : "variable", owner.from, extendedEnd(doc, owner));
548
+ break;
549
+ }
550
+ case "VariableDefinition": {
551
+ const parent = node.parent;
552
+ if (parent.name == "ForStatement" || parent.name == "ExceptBranch") {
553
+ const body = parent.getChild("Body");
554
+ if (body)
555
+ define(node, "variable", body.from, extendedEnd(doc, parent));
556
+ }
557
+ else if (parent.name == "VariableDeclaration" || parent.name == "TupleDeclaration") {
558
+ const section = ((_c = parent.parent) === null || _c === void 0 ? void 0 : _c.name) == "SectionBody" ? parent.parent.parent : parent.parent;
559
+ const isConst = ((_d = section.firstChild) === null || _d === void 0 ? void 0 : _d.name) == "const";
560
+ define(node, isConst ? "constant" : "variable", parent.to, scopeEnd(doc, section));
561
+ }
562
+ break;
563
+ }
564
+ case "TypeName":
565
+ define(node, "type", node.from, scopeEnd(doc, node));
566
+ break;
567
+ case "EnumMember":
568
+ define(node, "enum", node.to, scopeEnd(doc, node));
569
+ break;
570
+ case "FieldName":
571
+ names.fields.add(doc.sliceString(node.from, node.to));
572
+ break;
573
+ case "RoutineDeclaration":
574
+ case "ProcExpression": {
575
+ // A proc with a return type has an implicit `result` variable.
576
+ const body = node.getChild("Block");
577
+ if (node.getChild("Type") && body)
578
+ names.definitions.push({ label: "result", type: "variable", at: -1, from: body.from, to: blockEnd(doc, body) });
579
+ break;
580
+ }
581
+ }
582
+ },
583
+ });
584
+ cache.set(tree, names);
585
+ return names;
586
+ }
587
+ function wordBefore(context) {
588
+ return context.matchBefore(/[\w¡-￿]*$/);
589
+ }
590
+ function inside(node, names) {
591
+ for (let n = node; n; n = n.parent)
592
+ if (names.has(n.name))
593
+ return true;
594
+ return false;
595
+ }
596
+ // True when the word at the cursor follows a dot, as in `xs.le`.
597
+ function afterDot(context, from) {
598
+ return /[^.]\.\s*$/.test(context.state.sliceDoc(Math.max(0, from - 10), from));
599
+ }
600
+ // `mapIt`, `filterIt` and friends name their argument `it`.
601
+ function inItCall(state, node) {
602
+ for (let n = node; n; n = n.parent) {
603
+ if (n.name == "ArgList" || n.name == "CommandArgs") {
604
+ const callee = n.prevSibling;
605
+ if (callee && /It$/.test(state.sliceDoc(callee.from, callee.to)))
606
+ return true;
607
+ }
608
+ }
609
+ return false;
610
+ }
611
+ function skip(node) {
612
+ return inside(node, textNodes) || inside(node, definitionNodes);
613
+ }
614
+ /// Completes names declared in the file (procs, variables, parameters,
615
+ /// types and enum members), each only where it is in scope. After a dot it
616
+ /// offers the fields and procs declared in the file.
617
+ const localCompletionSource = (context) => {
618
+ const tree = language.syntaxTree(context.state);
619
+ const inner = tree.resolveInner(context.pos, -1);
620
+ if (skip(inner) || inside(inner, importNodes))
621
+ return null;
622
+ const word = wordBefore(context);
623
+ if (word.from == word.to && !context.explicit)
624
+ return null;
625
+ const names = collect(context.state, tree);
626
+ if (afterDot(context, word.from)) {
627
+ const options = [
628
+ ...[...names.fields].map((label) => ({ label, type: "property" })),
629
+ ...[...names.procs].map((label) => ({ label, type: "function" })),
630
+ ];
631
+ return { from: word.from, options, validFor: Identifier };
632
+ }
633
+ const seen = new Set();
634
+ const options = [];
635
+ for (const def of names.definitions) {
636
+ if (context.pos < def.from || context.pos > def.to)
637
+ continue;
638
+ if (def.at <= context.pos && context.pos <= def.at + def.label.length)
639
+ continue;
640
+ if (seen.has(def.label))
641
+ continue;
642
+ seen.add(def.label);
643
+ options.push({ label: def.label, type: def.type });
644
+ }
645
+ if (inItCall(context.state, inner))
646
+ options.push({ label: "it", type: "variable" });
647
+ return { from: word.from, options, validFor: Identifier };
648
+ };
649
+ const globalCompletion = autocomplete.completeFromList([...snippets, ...keywords, ...constants, ...types, ...builtins]);
650
+ const moduleCompletion = autocomplete.completeFromList(modules);
651
+ const methodCompletion = autocomplete.completeFromList(methods);
652
+ /// Completes keywords, snippets, built-in types and common standard library
653
+ /// procs. In an `import` it offers the standard library's modules, and after
654
+ /// a dot the common procs that are called that way.
655
+ const nimCompletion = (context) => {
656
+ const inner = language.syntaxTree(context.state).resolveInner(context.pos, -1);
657
+ if (skip(inner))
658
+ return null;
659
+ const word = wordBefore(context);
660
+ if (inside(inner, importNodes))
661
+ return moduleCompletion(context);
662
+ if (afterDot(context, word.from))
663
+ return methodCompletion(context);
664
+ return globalCompletion(context);
665
+ };
666
+
667
+ // Names inside a type annotation are types, as in `seq[Table[string, int]]`.
668
+ const typeNames = [
669
+ "Type/VariableName",
670
+ "Type/IndexExpression/VariableName",
671
+ "Type/IndexExpression/IndexExpression/VariableName",
672
+ "Type/IndexExpression/IndexExpression/IndexExpression/VariableName",
673
+ "Type/MemberExpression/PropertyName",
674
+ "Type/IndexExpression/MemberExpression/PropertyName",
675
+ ].join(" ");
676
+ // A block starts at the line break after its header, so it folds from the
677
+ // end of the header line.
678
+ function foldBlock(node) {
679
+ return node.to > node.from + 1 ? { from: node.from, to: node.to } : null;
680
+ }
681
+ const brackets = new Set([
682
+ "ArgList", "ParenthesizedExpression", "ParamList", "ArrayExpression", "IndexExpression",
683
+ "GenericParams", "TupleType", "SetExpression", "Pragma", "CastExpression",
684
+ ]);
685
+ const closers = new Set([")", "]", "}", ".}"]);
686
+ // True when `pos` sits inside a bracket that is still open there.
687
+ function inOpenBracket(state, pos) {
688
+ for (let node = language.syntaxTree(state).resolveInner(pos, -1); node; node = node.parent) {
689
+ if (!brackets.has(node.name) || node.from >= pos)
690
+ continue;
691
+ const last = node.lastChild;
692
+ if (!last || !closers.has(last.name) || last.from >= pos)
693
+ return true;
694
+ }
695
+ return false;
696
+ }
697
+ // The branch keywords, and the words that start the lines they line up with.
698
+ const branchOwners = {
699
+ elif: /^(if|elif|when)\b/,
700
+ else: /^(if|elif|when|of|case|except|try)\b/,
701
+ of: /^(of|case)\b/,
702
+ except: /^(try|except)\b/,
703
+ finally: /^(try|except)\b/,
704
+ };
705
+ function stripComment(text) {
706
+ return text.replace(/\s+#[^"']*$/, "").replace(/^\s*#.*$/, "").trimEnd();
707
+ }
708
+ // Nim marks blocks by indentation alone, and while a block is being typed
709
+ // its tree is incomplete. So inside blocks the indentation comes from the
710
+ // lines above: a line that ends with `:` or `=` (as in `if x:` or
711
+ // `proc f() =`), or opens a section such as `type`, indents the next line.
712
+ // A branch keyword such as `else` lines up with the nearest line above that
713
+ // it belongs to. Inside brackets the tree decides.
714
+ const nimIndent = language.indentService.of((context, pos) => {
715
+ var _a;
716
+ if (inOpenBracket(context.state, pos))
717
+ return undefined;
718
+ const doc = context.state.doc;
719
+ const line = doc.lineAt(pos);
720
+ let prev = null;
721
+ for (let n = line.number - 1; n >= 1; n--) {
722
+ const l = doc.line(n);
723
+ if (/\S/.test(l.text) && !/^\s*#/.test(l.text)) {
724
+ prev = l;
725
+ break;
726
+ }
727
+ }
728
+ if (!prev)
729
+ return 0;
730
+ const prevIndent = context.lineIndent(prev.from);
731
+ const keyword = (_a = /^\s*(elif|else|of|except|finally)\b/.exec(context.textAfterPos(pos))) === null || _a === void 0 ? void 0 : _a[1];
732
+ if (keyword) {
733
+ for (let n = line.number - 1; n >= 1; n--) {
734
+ const l = doc.line(n);
735
+ const indent = context.lineIndent(l.from);
736
+ if (indent <= prevIndent && branchOwners[keyword].test(l.text.trim()))
737
+ return indent;
738
+ }
739
+ return prevIndent;
740
+ }
741
+ const text = stripComment(prev.text);
742
+ if (/(^|[^=<>!+\-*\/%&|^~:.])[:=]$/.test(text) ||
743
+ /\b(object|enum|tuple)(\s+of\s+\w+)?$/.test(text) ||
744
+ /^\s*(type|var|let|const|import)$/.test(text))
745
+ return prevIndent + context.unit;
746
+ return prevIndent;
747
+ });
748
+ const nimLanguage = language.LRLanguage.define({
749
+ name: "nim",
750
+ parser: parser.configure({
751
+ props: [
752
+ language.indentNodeProp.add({
753
+ "ArgList ParenthesizedExpression ParamList": language.delimitedIndent({ closing: ")" }),
754
+ "ArrayExpression IndexExpression GenericParams TupleType": language.delimitedIndent({ closing: "]" }),
755
+ SetExpression: language.delimitedIndent({ closing: "}" }),
756
+ Pragma: language.delimitedIndent({ closing: ".}" }),
757
+ }),
758
+ language.foldNodeProp.add({
759
+ "Block SectionBody ObjectBody EnumBody CaseBody": foldBlock,
760
+ }),
761
+ highlight.styleTags({
762
+ "if elif else case of when while for break continue return yield raise try except finally defer block": highlight.tags.controlKeyword,
763
+ "proc func method iterator template macro converter": highlight.tags.definitionKeyword,
764
+ "type var let const object enum tuple distinct": highlight.tags.definitionKeyword,
765
+ "import export include from": highlight.tags.moduleKeyword,
766
+ "and or not xor in notin is isnot div mod shl shr cast addr as": highlight.tags.operatorKeyword,
767
+ "discard static ref ptr out mixin bind": highlight.tags.keyword,
768
+ Boolean: highlight.tags.bool,
769
+ nil: highlight.tags.null,
770
+ Number: highlight.tags.number,
771
+ "String TripleString": highlight.tags.string,
772
+ RawString: highlight.tags.special(highlight.tags.string),
773
+ Char: highlight.tags.character,
774
+ LineComment: highlight.tags.lineComment,
775
+ DocComment: highlight.tags.docComment,
776
+ BlockComment: highlight.tags.blockComment,
777
+ VariableName: highlight.tags.variableName,
778
+ "CallExpression/VariableName CommandCall/VariableName CallString/VariableName": highlight.tags.function(highlight.tags.variableName),
779
+ "CallExpression/MemberExpression/PropertyName CommandCall/MemberExpression/PropertyName": highlight.tags.function(highlight.tags.propertyName),
780
+ PropertyName: highlight.tags.propertyName,
781
+ FunctionName: highlight.tags.function(highlight.tags.definition(highlight.tags.variableName)),
782
+ "VariableDefinition ParameterName": highlight.tags.definition(highlight.tags.variableName),
783
+ "TypeName TypeParameter": highlight.tags.definition(highlight.tags.typeName),
784
+ FieldName: highlight.tags.definition(highlight.tags.propertyName),
785
+ EnumMember: highlight.tags.constant(highlight.tags.definition(highlight.tags.variableName)),
786
+ [typeNames]: highlight.tags.typeName,
787
+ "ArithOp RangeOp Operator Arrow \"*\"": highlight.tags.operator,
788
+ CompareOp: highlight.tags.compareOperator,
789
+ UpdateOp: highlight.tags.updateOperator,
790
+ "=": highlight.tags.definitionOperator,
791
+ ". :": highlight.tags.punctuation,
792
+ "{. .}": highlight.tags.meta,
793
+ "( )": highlight.tags.paren,
794
+ "[ ]": highlight.tags.squareBracket,
795
+ "{ }": highlight.tags.brace,
796
+ ", ;": highlight.tags.separator,
797
+ }),
798
+ ],
799
+ }),
800
+ languageData: {
801
+ commentTokens: { line: "#", block: { open: "#[", close: "]#" } },
802
+ closeBrackets: { brackets: ["(", "[", "{", '"', "'", "`"] },
803
+ indentOnInput: /^\s*(elif|else|of|except|finally)\b/,
804
+ },
805
+ });
806
+ function nim() {
807
+ return new language.LanguageSupport(nimLanguage, [
808
+ nimIndent,
809
+ nimLanguage.data.of({ autocomplete: localCompletionSource }),
810
+ nimLanguage.data.of({ autocomplete: nimCompletion }),
811
+ ]);
812
+ }
813
+
814
+ exports.localCompletionSource = localCompletionSource;
815
+ exports.nim = nim;
816
+ exports.nimCompletion = nimCompletion;
817
+ exports.nimLanguage = nimLanguage;
818
+ exports.snippets = snippets;