@exercism/codemirror-lang-8th 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/dist/index.js ADDED
@@ -0,0 +1,2076 @@
1
+ import { ContextTracker, ExternalTokenizer, LRParser } from '@lezer/lr';
2
+ import { syntaxTree, LRLanguage, indentNodeProp, delimitedIndent, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language';
3
+ import { styleTags, tags } from '@lezer/highlight';
4
+ import { snippetCompletion } from '@codemirror/autocomplete';
5
+
6
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
7
+ const Word = 1,
8
+ Namespace = 2,
9
+ name = 58,
10
+ Number = 3,
11
+ Character = 4,
12
+ String = 5,
13
+ Regex = 6,
14
+ Boolean = 7,
15
+ Null = 8,
16
+ LineComment = 9,
17
+ BlockComment = 10,
18
+ StackEffect = 11,
19
+ defStart = 12,
20
+ defEnd = 13,
21
+ quoteOpen = 14,
22
+ quoteClose = 15,
23
+ arrayOpen = 16,
24
+ arrayClose = 17,
25
+ mapOpen = 18,
26
+ mapClose = 19,
27
+ comma = 20,
28
+ mapColon = 21,
29
+ tick = 22,
30
+ ifKeyword = 23,
31
+ elseKeyword = 24,
32
+ thenKeyword = 25,
33
+ exitThen = 26,
34
+ repeatKeyword = 27,
35
+ loopEnd = 28,
36
+ varKeyword = 29,
37
+ nsKeyword = 30,
38
+ withKeyword = 31,
39
+ endWith = 32,
40
+ needsKeyword = 33,
41
+ Keyword = 34;
42
+
43
+ // 8th splits its source at whitespace and then decides what each piece is, so
44
+ // this tokenizer reads every token for the grammar. Inside an array or a map,
45
+ // `,` and the closing bracket also end a token, so the context tracker below
46
+ // keeps a stack of the open brackets. The tokenizer also asks the parse state
47
+ // when the grammar wants a new name (after `:`, `var`, `ns:` and the like),
48
+ // because any text can be a name there.
49
+ function isSpace(ch) {
50
+ return ch < 0 || ch == 32 || (ch >= 9 && ch <= 13) || ch == 0xa0 || ch == 0xfeff;
51
+ }
52
+ // Inside an array or a map, 8th's JSON reader also ends a token at these.
53
+ function isJsonDelimiter(ch) {
54
+ return ch == 44 /* Ch.Comma */ || ch == 93 /* Ch.BracketR */ || ch == 125 /* Ch.BraceR */ || ch == 91 /* Ch.BracketL */ || ch == 123 /* Ch.BraceL */;
55
+ }
56
+ function tokenEnds(ch, inJson) {
57
+ return isSpace(ch) || (inJson && isJsonDelimiter(ch));
58
+ }
59
+ function rawLength(input, inJson) {
60
+ let i = 0;
61
+ while (!tokenEnds(input.peek(i), inJson))
62
+ i++;
63
+ return i;
64
+ }
65
+ function text(input, length) {
66
+ let result = "";
67
+ for (let i = 0; i < length; i++)
68
+ result += globalThis.String.fromCharCode(input.peek(i));
69
+ return result;
70
+ }
71
+ function lineEnd(input, from) {
72
+ let i = from;
73
+ for (let ch = input.peek(i); ch >= 0 && ch != 10 /* Ch.Newline */ && ch != 13 /* Ch.Return */; ch = input.peek(++i))
74
+ ;
75
+ return i;
76
+ }
77
+ function stringEnd(input) {
78
+ let i = 1;
79
+ for (;;) {
80
+ const ch = input.peek(i);
81
+ if (ch < 0)
82
+ return i;
83
+ i++;
84
+ if (ch == 92 /* Ch.Backslash */) {
85
+ if (input.peek(i) >= 0)
86
+ i++;
87
+ }
88
+ else if (ch == 34 /* Ch.Quote */) {
89
+ return i;
90
+ }
91
+ }
92
+ }
93
+ function blockCommentEnd(input) {
94
+ let i = 2;
95
+ for (;;) {
96
+ const ch = input.peek(i);
97
+ if (ch < 0)
98
+ return i;
99
+ i++;
100
+ if (ch == 42 /* Ch.Star */ && input.peek(i) == 41 /* Ch.ParenR */)
101
+ return i + 1;
102
+ }
103
+ }
104
+ // A regex runs from `/` to the next `/` outside a character class, on the
105
+ // same line, and can have flags after it: `/[^[:alpha:] ]+/`, `/abc/i`. A token
106
+ // such as `/2up` that has no closing slash is a word.
107
+ function regexEnd(input, inJson) {
108
+ if (isSpace(input.peek(1)))
109
+ return -1;
110
+ let i = 1;
111
+ let inClass = false;
112
+ for (;;) {
113
+ const ch = input.peek(i);
114
+ if (ch < 0 || ch == 10 /* Ch.Newline */ || ch == 13 /* Ch.Return */)
115
+ return -1;
116
+ if (ch == 92 /* Ch.Backslash */) {
117
+ i += 2;
118
+ }
119
+ else if (inClass && ch == 91 /* Ch.BracketL */ && input.peek(i + 1) == 58 /* Ch.Colon */) {
120
+ // A POSIX class such as `[:alpha:]` inside a character class.
121
+ let j = i + 2;
122
+ while (input.peek(j) >= 0 && !(input.peek(j) == 58 /* Ch.Colon */ && input.peek(j + 1) == 93 /* Ch.BracketR */)) {
123
+ if (input.peek(j) == 10 /* Ch.Newline */)
124
+ return -1;
125
+ j++;
126
+ }
127
+ i = j + 2;
128
+ }
129
+ else if (ch == 91 /* Ch.BracketL */ && !inClass) {
130
+ inClass = true;
131
+ i++;
132
+ if (input.peek(i) == 94 /* ^ */)
133
+ i++;
134
+ if (input.peek(i) == 93 /* Ch.BracketR */)
135
+ i++;
136
+ }
137
+ else if (ch == 93 /* Ch.BracketR */ && inClass) {
138
+ inClass = false;
139
+ i++;
140
+ }
141
+ else if (ch == 47 /* Ch.Slash */ && !inClass) {
142
+ i++;
143
+ while (/[a-zA-Z]/.test(globalThis.String.fromCharCode(input.peek(i))))
144
+ i++;
145
+ return tokenEnds(input.peek(i), inJson) ? i : -1;
146
+ }
147
+ else {
148
+ i++;
149
+ }
150
+ }
151
+ }
152
+ // 8th reads `$ff` as hex, and `1k`, `1g` and `1t` as a thousand, a billion
153
+ // and a trillion.
154
+ const numberPattern$1 = /^[-+]?(?:\$[0-9a-fA-F_]+|0[xX][0-9a-fA-F_]+|0[bB][01_]+|(?:\d[\d_]*(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?[kmgt]?)$/;
155
+ // A word with a namespace, such as `a:map`, `s:/` or `n:>roman`.
156
+ const qualifiedPattern = /^[A-Za-z_][A-Za-z0-9_]*:(?=.)/;
157
+ const keywords$1 = {
158
+ ":": defStart,
159
+ ";": defEnd,
160
+ "(": quoteOpen,
161
+ ")": quoteClose,
162
+ "'": tick,
163
+ if: ifKeyword,
164
+ "!if": ifKeyword,
165
+ else: elseKeyword,
166
+ then: thenKeyword,
167
+ ";then": exitThen,
168
+ repeat: repeatKeyword,
169
+ again: loopEnd,
170
+ while: loopEnd,
171
+ "while!": loopEnd,
172
+ until: loopEnd,
173
+ "until!": loopEnd,
174
+ var: varKeyword,
175
+ "var,": varKeyword,
176
+ constant: varKeyword,
177
+ "defer:": varKeyword,
178
+ "ns:": nsKeyword,
179
+ "with:": withKeyword,
180
+ ";with": endWith,
181
+ needs: needsKeyword,
182
+ break: Keyword,
183
+ ";;": Keyword,
184
+ ";;;": Keyword,
185
+ "locals:": Keyword,
186
+ true: Boolean,
187
+ false: Boolean,
188
+ null: Null,
189
+ };
190
+ function readComment(input, stack, from, effect) {
191
+ const end = lineEnd(input, from);
192
+ if (effect && stack.canShift(StackEffect)) {
193
+ input.acceptToken(StackEffect, end);
194
+ }
195
+ else {
196
+ input.acceptToken(LineComment, end);
197
+ }
198
+ }
199
+ class Brackets {
200
+ constructor(kind, parent, hash) {
201
+ this.kind = kind;
202
+ this.parent = parent;
203
+ this.hash = hash;
204
+ }
205
+ static push(kind, parent) {
206
+ return new Brackets(kind, parent, ((parent ? parent.hash : 0) * 3 + kind + 1) | 0);
207
+ }
208
+ }
209
+ const brackets$1 = new ContextTracker({
210
+ start: null,
211
+ shift(context, term) {
212
+ if (term == arrayOpen)
213
+ return Brackets.push(0 /* Bracket.Array */, context);
214
+ if (term == mapOpen)
215
+ return Brackets.push(1 /* Bracket.Map */, context);
216
+ if (term == quoteOpen)
217
+ return Brackets.push(2 /* Bracket.Quotation */, context);
218
+ if (term == arrayClose || term == mapClose || term == quoteClose)
219
+ return context ? context.parent : null;
220
+ return context;
221
+ },
222
+ hash: (context) => (context ? context.hash : 0),
223
+ strict: false,
224
+ });
225
+ const tokens = new ExternalTokenizer((input, stack) => {
226
+ const ch = input.next;
227
+ if (isSpace(ch))
228
+ return;
229
+ const context = stack.context;
230
+ const inJson = context != null && context.kind != 2 /* Bracket.Quotation */;
231
+ const inMap = context != null && context.kind == 1 /* Bracket.Map */;
232
+ // The rest of a word such as `a:map`, after its namespace.
233
+ if (input.peek(-1) == 58 /* Ch.Colon */ && !isSpace(input.peek(-2)) && stack.canShift(Word) && !stack.canShift(Number)) {
234
+ input.acceptToken(Word, Math.max(1, rawLength(input, inJson)));
235
+ return;
236
+ }
237
+ if (stack.canShift(name)) {
238
+ input.acceptToken(name, Math.max(1, rawLength(input, inJson)));
239
+ return;
240
+ }
241
+ if (ch == 34 /* Ch.Quote */) {
242
+ input.acceptToken(String, stringEnd(input));
243
+ return;
244
+ }
245
+ if (inJson) {
246
+ if (ch == 44 /* Ch.Comma */)
247
+ return input.acceptToken(comma, 1);
248
+ if (ch == 58 /* Ch.Colon */ && inMap)
249
+ return input.acceptToken(mapColon, 1);
250
+ }
251
+ if (ch == 93 /* Ch.BracketR */ && stack.canShift(arrayClose))
252
+ return input.acceptToken(arrayClose, 1);
253
+ if (ch == 125 /* Ch.BraceR */ && stack.canShift(mapClose))
254
+ return input.acceptToken(mapClose, 1);
255
+ if (ch == 91 /* Ch.BracketL */)
256
+ return input.acceptToken(arrayOpen, 1);
257
+ if (ch == 123 /* Ch.BraceL */)
258
+ return input.acceptToken(mapOpen, 1);
259
+ // A character such as `'a` or `']`.
260
+ if (ch == 39 /* Ch.Apostrophe */ && !isSpace(input.peek(1))) {
261
+ const size = input.peek(1) >= 0xd800 && input.peek(1) < 0xdc00 ? 3 : 2;
262
+ if (tokenEnds(input.peek(size), inJson) || isJsonDelimiter(input.peek(1))) {
263
+ input.acceptToken(Character, size);
264
+ return;
265
+ }
266
+ }
267
+ const length = Math.max(1, rawLength(input, inJson));
268
+ const raw = text(input, length);
269
+ // A key without quotes, as in `{ Mercury: 0.24 }`.
270
+ if (inMap && length > 1 && raw.endsWith(":"))
271
+ return input.acceptToken(Word, length - 1);
272
+ // `;:` ends one definition and starts the next, so it is read as `;` and
273
+ // then `:`.
274
+ if (raw == ";:")
275
+ return input.acceptToken(defEnd, 1);
276
+ if (raw == "\\" || raw == "--")
277
+ return readComment(input, stack, length, raw == "\\" && hasDashes(input, length));
278
+ if (raw == "SED:")
279
+ return readComment(input, stack, length, true);
280
+ if (raw == "(*")
281
+ return input.acceptToken(BlockComment, blockCommentEnd(input));
282
+ // `G:if` and `G:(` are the same words as `if` and `(`.
283
+ const bare = raw.startsWith("G:") ? raw.slice(2) : raw;
284
+ const keyword = Object.prototype.hasOwnProperty.call(keywords$1, bare) ? keywords$1[bare] : -1;
285
+ if (keyword >= 0)
286
+ return input.acceptToken(keyword, length);
287
+ if (ch == 47 /* Ch.Slash */ && length > 1) {
288
+ const end = regexEnd(input, inJson);
289
+ if (end > 0)
290
+ return input.acceptToken(Regex, end);
291
+ }
292
+ if (numberPattern$1.test(raw))
293
+ return input.acceptToken(Number, length);
294
+ const qualified = qualifiedPattern.exec(raw);
295
+ if (qualified)
296
+ return input.acceptToken(Namespace, qualified[0].length);
297
+ input.acceptToken(Word, length);
298
+ }, { contextual: true });
299
+ // A stack effect comment shows what the word takes and leaves, as in
300
+ // `\ a b -- c`.
301
+ function hasDashes(input, from) {
302
+ const end = lineEnd(input, from);
303
+ for (let i = from; i < end - 1; i++) {
304
+ if (input.peek(i) == 45 && input.peek(i + 1) == 45)
305
+ return true;
306
+ }
307
+ return false;
308
+ }
309
+
310
+ // This file was generated by lezer-generator. You probably shouldn't edit it.
311
+ const parser = LRParser.deserialize({
312
+ version: 14,
313
+ states: ")`Q]QROOO!pQRO'#DSO$SQRO'#DUO$aQRO'#DVO$hQRO'#DWO$mQRO'#DYO$rQRO'#D[O$wQRO'#D]O$|QRO'#D_O%TQRO'#D`O%_QRO'#DaOOQP'#Dm'#DmOOQP'#Dl'#DlO%lQRO'#DQO!pQRO'#DbOOQP'#Dk'#DkOOQP'#Dc'#DcQ]QROOOOQP'#DT'#DTOOQP,59n,59nOOQP,59p,59pO%qQRO,59pO%{QRO,59pOOQP'#Dd'#DdOOQP,59q,59qO&YQRO,59qOOQP'#DX'#DXOOQP,59r,59rOOQP'#DZ'#DZOOQP,59t,59tOOQP,59v,59vOOQP'#D^'#D^OOQP,59w,59wOOQP,59y,59yO&aQRO,59yOOQP'#De'#DeO&hQRO,59zOOQP,59z,59zOOQP'#Df'#DfO&rQRO,59{OOQP,59{,59{OOQP'#DR'#DRO'PQRO,59lOOQP,59|,59|OOQP-E7a-E7aOOQP1G/[1G/[O'ZQRO1G/[O'ZQRO1G/[OOQP-E7b-E7bOOQP1G/]1G/]OOQP1G/e1G/eOOQP-E7c-E7cOOQP1G/f1G/fOOQP-E7d-E7dOOQP1G/g1G/gO'eQRO1G/WOOQP1G/W1G/WO'eQRO1G/WOOQP7+$v7+$vO'lQRO7+$vOOQP7+$r7+$rO'vQRO7+$rOOQP<<Hb<<HbOOQP<<H^<<H^",
314
+ stateData: "'}~O!^OSXOSYOS~OPZOQUORZOSZOTZOUZOVZOWZO[]O^WO`XObYOfVOgQOkROmSOn^OoPOp[OqTOr[O~O![bO~OPZOQUORZOSZOTZOUZOVZOWZO^WO`XObYOfVOgQOkROmSOoPOp[OqTOr[O~OheOidOjdO~P!uOlhO~P!uO![jO~O![lO~OPnO~O![oO~O_qO~P!uOauOdsO~P!uOcxOdvOevO~P!uO![yO~Oi}Oj}O~P!uOh!POi}Oj}O~P!uOl!RO~P!uO_!SO~P!uOa!UOdsO~P!uOc!WOdvOevO~P!uOZ!ZO]!YO~P!uOi![Oj![O~P!uO]!^O~P!uOi!`Oj!`O~P!uO]!aO~P!uO",
315
+ goto: "%k!bPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP!c!g!j#Q!j!j!j#W!j#Z#^#^#t#^#^#^!c#w#}$m$sPPPP$y$}!jT_OaRz]y[OQRWXYaefirtwz!O!P!X!Z!]!_QcPR{^RkSRmTyZOQRWXYaefirtwz!O!P!X!Z!]!_RpVQaOR|aQfQQiRQrWQ!Oe^!Qfir!O!X!]!_Q!XzQ!]!PR!_!ZQtXR!TtQwYR!VwT`OaS_OalgQRWefirz!O!P!X!Z!]!_SsXtTvYw",
316
+ nodeNames: "⚠ Word Namespace Number Character String Regex Boolean Null LineComment BlockComment StackEffect : ; ( ) [ ] { } , MapColon ' if else then ;then repeat LoopEnd DefinitionKeyword ns: with: ;with needs Keyword Program Definition DefName WithDeclaration NamespaceName Conditional Loop VariableDefinition VariableName Needs ModulePath QualifiedWord TickedWord WordName Quotation Array Map NamespaceDeclaration",
317
+ maxTerm: 63,
318
+ context: brackets$1,
319
+ skippedNodes: [0,9,10],
320
+ repeatNodeCount: 4,
321
+ tokenData: "!f~RYX^qpqq#y#zq$f$gq#BY#BZq$IS$I_q$I|$JOq$JT$JUq$KV$KWq&FU&FVq~vY!^~X^qpqq#y#zq$f$gq#BY#BZq$IS$I_q$I|$JOq$JT$JUq$KV$KWq&FU&FVq",
322
+ tokenizers: [tokens, 0],
323
+ topRules: {"Program":[0,35]},
324
+ tokenPrec: 0
325
+ });
326
+
327
+ // Generated by scripts/extract-words.py from https://8th-dev.com/words.html.
328
+ // Each word is [name, stack effect] or [name, stack effect, library it needs].
329
+ const namespaces = {
330
+ "G": {
331
+ title: "Global",
332
+ words: [
333
+ ["!", "x v -- | v x --"],
334
+ ["!if", "--"],
335
+ ["#!", "--"],
336
+ ["##", "n --"],
337
+ ["#if", "f --"],
338
+ ["#ifdef", "<var> --"],
339
+ ["#ifeval", "<expr> --"],
340
+ ["'", "<name> -- w"],
341
+ ["(", "--"],
342
+ ["(*", "<*)> --"],
343
+ ["(:)", "s --"],
344
+ ["(code)", "-- used allocated"],
345
+ ["(defer)", "s --"],
346
+ ["(dump)", "x -- s"],
347
+ ["(getc)", "-- n"],
348
+ ["(gets)", "-- s"],
349
+ ["(interp)", "--"],
350
+ ["(log)", "s --"],
351
+ ["(needs)", "s --"],
352
+ ["(parseln)", "<text> -- s"],
353
+ ["(putc)", "n --"],
354
+ ["(puts)", "s --"],
355
+ ["(stat)", "n -- a"],
356
+ ["(with)", "s --"],
357
+ [")", "-- w"],
358
+ ["+hook", "w -- n"],
359
+ ["+ref", "x -- x"],
360
+ [",#", "n --"],
361
+ ["--", "--"],
362
+ ["-----BEGIN", "<...> --", "crypto/pgp"],
363
+ ["-Inf", "-- n"],
364
+ ["-Inf?", "x -- x T", "math/isa"],
365
+ ["-hook", "n --"],
366
+ ["-ref", "x -- x"],
367
+ ["-rot", "a b c -- c a b"],
368
+ [".", "x --"],
369
+ [".#", "n --"],
370
+ [".hook", "--"],
371
+ [".needs", "--"],
372
+ [".r", "--"],
373
+ [".s", "--"],
374
+ [".s-truncate", "T --"],
375
+ [".stats", "--", "utils/stats"],
376
+ [".ver", "--"],
377
+ [".with", "--"],
378
+ ["0;", "x -- x | false --"],
379
+ ["2dip", "a b c w -- w(a) b c", "combinators/2dip"],
380
+ ["2drop", "a b c d -- a b"],
381
+ ["2dup", "a b -- a b a b"],
382
+ ["2nip", "a b c -- c"],
383
+ ["2over", "a b c d -- a b c d a b"],
384
+ ["2swap", "a b c d -- c d a b"],
385
+ ["2tuck", "a b c d -- c d a b c d"],
386
+ ["3drop", "a b c d -- a"],
387
+ ["3dup", "a b c -- a b c a b c"],
388
+ ["3rev", "a b c -- c b a"],
389
+ ["4drop", "x1 x2 x3 x4 --", "stack/3drop"],
390
+ ["8thdt?", "-- s"],
391
+ ["8thsku?", "-- n"],
392
+ ["8thver?", "-- s"],
393
+ ["8thvernum?", "-- n"],
394
+ [":", "<name> --"],
395
+ [";", "--"],
396
+ [";;", "--"],
397
+ [";;;", "--"],
398
+ [";then", "--"],
399
+ [";with", "--"],
400
+ [">clip", "x --"],
401
+ [">clip-mime", "m -- T"],
402
+ [">json", "x -- s"],
403
+ [">kind", "x -- n"],
404
+ [">n", "s -- n | b -- n | n -- n | T -- n"],
405
+ [">r", "x -- { x }"],
406
+ [">s", "x -- s"],
407
+ ["?:", "x1 x2 -- x'"],
408
+ ["?@", "x1 x2 -- x3"],
409
+ ["@", "v -- x"],
410
+ ["BITMAP:", "bits <name>, bits2 , ... ; --", "utils/bitmap"],
411
+ ["ENUM:", "n <name>... ; --", "utils/enums"],
412
+ ["FLAG:", "n <name>... ; --", "utils/enums"],
413
+ ["I", "-- n"],
414
+ ["Inf", "-- n"],
415
+ ["Inf?", "x -- x T", "math/isa"],
416
+ ["J", "-- n"],
417
+ ["K", "-- n"],
418
+ ["NaN", "-- n"],
419
+ ["NaN?", "x -- x T", "math/isa"],
420
+ ["SED-CHECK", "T --", "debug/sed"],
421
+ ["SED:", "<stack diagram> --", "debug/sed"],
422
+ ["TODO:", "--"],
423
+ ["X", "n -- n"],
424
+ ["\\", "--"],
425
+ ["_dup", "a b -- a a b"],
426
+ ["_swap", "a b c -- b a c"],
427
+ ["actor:", "x w <name> --", "utils/actor"],
428
+ ["again", "--"],
429
+ ["ahead", "--"],
430
+ ["all-words", "-- a"],
431
+ ["and", "T T -- T"],
432
+ ["apropos", "<text> --"],
433
+ ["argc", "-- n"],
434
+ ["args", "n -- s | null -- a"],
435
+ ["array?", "x -- x T"],
436
+ ["assert", "x --"],
437
+ ["base", "n -- n'"],
438
+ ["base>n", "s n -- n'"],
439
+ ["bi", "x w1 w2 -- w1(x) w2(x)", "combinators/bi"],
440
+ ["bits", "-- n"],
441
+ ["break", "--"],
442
+ ["break?", "-- T"],
443
+ ["breakif", "x -- x"],
444
+ ["build?", "-- s"],
445
+ ["buildver?", "-- s"],
446
+ ["bye", "--"],
447
+ ["c/does", "x dw cw <name> --", "utils/create-does"],
448
+ ["case", "s m -- | n a -- | m s -- | a n --"],
449
+ ["case:", "--", "utils/case"],
450
+ ["caseof", "a n -- x | n a -- x | m s -- x | s m -- x"],
451
+ ["catch", "w -- x true | w --false"],
452
+ ["chdir", "s --"],
453
+ ["clip-mime-types", "-- a"],
454
+ ["clip-mime>", "s -- b"],
455
+ ["clip-mime?", "s -- T"],
456
+ ["clip>", "-- s"],
457
+ ["clone", "x1 -- x1 x2"],
458
+ ["clone-shallow", "x1 -- x1 x2"],
459
+ ["cold", "--"],
460
+ ["compile", "w --"],
461
+ ["compile?", "w --"],
462
+ ["compiling?", "-- n"],
463
+ ["conflict", "s -- T"],
464
+ ["const", "x1 -- x2"],
465
+ ["constant", "x <name> --"],
466
+ ["container?", "x -- x T"],
467
+ ["counting-allocations", "T --"],
468
+ ["cr", "--"],
469
+ ["critical:", "--"],
470
+ ["critical;", "--"],
471
+ ["curlang", "-- v"],
472
+ ["curry", "x w -- w'"],
473
+ ["curry:", "x w <name> -- w'"],
474
+ ["decimal", "--"],
475
+ ["default:", "--", "utils/case"],
476
+ ["defer:", "<name> --"],
477
+ ["deferred:", "w <name> --"],
478
+ ["deg>rad", "n -- n'"],
479
+ ["depth", "-- n"],
480
+ ["die", "n --"],
481
+ ["dip", "a b w -- w(a) b", "combinators/dip"],
482
+ ["drop", "a b -- a"],
483
+ ["dstack", "-- st"],
484
+ ["dump", "x --"],
485
+ ["dup", "x -- x x"],
486
+ ["dup>r", "x -- x {x}"],
487
+ ["dup?", "x -- x x | null -- null"],
488
+ ["e#", "T --"],
489
+ ["else", "--"],
490
+ ["enum:", "n <name>... enum; --", "utils/enums"],
491
+ ["error?", "-- n"],
492
+ ["eval", "s --"],
493
+ ["eval!", "s -- T"],
494
+ ["eval0", "s --"],
495
+ ["exit", "n --"],
496
+ ["expect", "x n -- x T | x a -- x T", "utils/expect"],
497
+ ["extra!", "x x' -- x"],
498
+ ["extra@", "x -- x x'"],
499
+ ["false", "-- T"],
500
+ ["fnv", "s -- n"],
501
+ ["fourth", "a b c d -- a b c d a"],
502
+ ["free", "x --"],
503
+ ["func:", "param s <name>"],
504
+ ["getc", "-- n"],
505
+ ["getcwd", "-- s"],
506
+ ["getenv", "s -- s'"],
507
+ ["gets", "-- s"],
508
+ ["goto", "n --"],
509
+ ["handler", "x -- T"],
510
+ ["header", "s --"],
511
+ ["help", "<name> --"],
512
+ ["help_db", "-- v", "utils/help"],
513
+ ["here", "-- n"],
514
+ ["hex", "--"],
515
+ ["i:", "--"],
516
+ ["i;", "--"],
517
+ ["if", "--"],
518
+ ["if;", "x --"],
519
+ ["immutable", "x <name> --"],
520
+ ["isa?", "x n -- x T"],
521
+ ["items-used", "-- n", "utils/stats"],
522
+ ["jcall", "X a -- x"],
523
+ ["jclass", "s -- X"],
524
+ ["jmethod", "X name params -- X'"],
525
+ ["json!", "ma s x -- x"],
526
+ ["json-8th>", "s -- x | b -- x"],
527
+ ["json-nesting", "n --"],
528
+ ["json-pretty", "n --"],
529
+ ["json-throw", "T --"],
530
+ ["json>", "s -- x"],
531
+ ["json@", "ma s -- ma x true | ma s -- ma false"],
532
+ ["k32", "-- n"],
533
+ ["keep", "a b c w -- a w(b,c) c", "combinators/keep"],
534
+ ["l:", "<name> --", "utils/latebind"],
535
+ ["last", "-- w"],
536
+ ["lib", "s <name> -- | a --"],
537
+ ["libbin", "<name> --"],
538
+ ["libc", "-- n"],
539
+ ["libimg", "<libname> --", "img/load"],
540
+ ["literal", "x --"],
541
+ ["locals:", "--"],
542
+ ["lock", "x -- x"],
543
+ ["lock-to", "x n -- x T"],
544
+ ["locked?", "x -- x T"],
545
+ ["log", "x --"],
546
+ ["logl", "x n --"],
547
+ ["long-days", "-- v"],
548
+ ["long-months", "-- v"],
549
+ ["longjmp", "n --"],
550
+ ["lookup", "m s -- x | a n -- x | s m -- x | n a -- x"],
551
+ ["loop", "w low hi --"],
552
+ ["loop-", "w low hi --"],
553
+ ["map?", "x -- x T"],
554
+ ["mark", "x T -- x"],
555
+ ["mark?", "x -- x T"],
556
+ ["mobile?", "-- T"],
557
+ ["mutex", "-- X"],
558
+ ["mutex-lock", "X T --"],
559
+ ["n#", "n --"],
560
+ ["name>os", "s -- n", "utils/os-names"],
561
+ ["name>sem", "s -- x"],
562
+ ["ndrop", "a1 a2... aN N --", "stack/utils"],
563
+ ["needs", "<name> --"],
564
+ ["needs-throws", "-- v"],
565
+ ["needs[", "<libs...>] --"],
566
+ ["new", "n -- x"],
567
+ ["next-arg", "-- x", "utils/args-common"],
568
+ ["next-num-var", "v --", "utils/args-common"],
569
+ ["next-var", "v --", "utils/args-common"],
570
+ ["nip", "a b -- b"],
571
+ ["noop", "--"],
572
+ ["not", "T -- T"],
573
+ ["nothrow", "w -- x"],
574
+ ["ns", "ns --"],
575
+ ["ns:", "<name> --"],
576
+ ["ns>ls", "n -- s"],
577
+ ["ns>s", "n -- s | s -- s'"],
578
+ ["ns?", "-- s"],
579
+ ["null", "-- null"],
580
+ ["null;", "x -- x | null --"],
581
+ ["null?", "x -- x T"],
582
+ ["nullvar", "<name> --"],
583
+ ["number?", "x -- x T"],
584
+ ["of:", "x --", "utils/case"],
585
+ ["off", "v --"],
586
+ ["on", "v --"],
587
+ ["onexit", "w --"],
588
+ ["only", "n --"],
589
+ ["op!", "v w --"],
590
+ ["or", "T T -- T"],
591
+ ["os", "-- n"],
592
+ ["os-names", "-- a"],
593
+ ["os>long-name", "n -- s", "utils/os-names"],
594
+ ["os>name", "n -- s"],
595
+ ["over", "a b -- a b a"],
596
+ ["p:", "--"],
597
+ ["pack", "a s -- b"],
598
+ ["parse", "n <text> -- s | x -- s"],
599
+ ["parse-csv", "m -- m"],
600
+ ["parse-date", "T --"],
601
+ ["parsech", "<text> -- s"],
602
+ ["parseln", "<text> -- s"],
603
+ ["parsews", "<text> -- s"],
604
+ ["pick", "n -- x"],
605
+ ["poke", "x y --", "stack/utils"],
606
+ ["pool-clear", "n --"],
607
+ ["pool-clear-all", "--"],
608
+ ["prior", "w1 -- w2"],
609
+ ["private", "--"],
610
+ ["process-args", "m --", "utils/args"],
611
+ ["process-args-fancy", "m T -- m", "utils/args-fancy"],
612
+ ["process-args-help", "--", "utils/args-fancy"],
613
+ ["prompt", "s -- s'"],
614
+ ["public", "--"],
615
+ ["putc", "n --"],
616
+ ["puts", "s --"],
617
+ ["quote", "<char> -- s"],
618
+ ["r!", "x1 {x2} -- {x1}"],
619
+ ["r>", "{ x } -- x"],
620
+ ["r@", "{ x } -- x { x }"],
621
+ ["rad>deg", "n -- n'"],
622
+ ["rand-float", "-- n", "rand/float"],
623
+ ["rand-float-signed", "-- n", "rand/float"],
624
+ ["rand-jit", "-- n"],
625
+ ["rand-jsf", "-- n"],
626
+ ["rand-native", "-- n"],
627
+ ["rand-normal", "mean sigma -- n", "rand/normal"],
628
+ ["rand-pcg", "-- n"],
629
+ ["rand-pcg-seed", "n1 n2 -- | null --"],
630
+ ["rand-range", "low high -- n", "rand/range"],
631
+ ["rand-select", "s --", "rand/util"],
632
+ ["randbuf-pcg", "n -- b"],
633
+ ["random", "-- n"],
634
+ ["rdrop", "{ x -- }"],
635
+ ["recurse", "--"],
636
+ ["recurse-stack", "n --"],
637
+ ["ref@", "x -- x n"],
638
+ ["reg!", "s x -- T"],
639
+ ["reg@", "s -- x"],
640
+ ["regbin@", "s -- b n"],
641
+ ["remaining-args", "-- v", "utils/args-common"],
642
+ ["repeat", "--"],
643
+ ["requires", "<resources> --"],
644
+ ["reset", "--"],
645
+ ["roll", "n --"],
646
+ ["rop!", "w --"],
647
+ ["rot", "a b c -- b c a"],
648
+ ["rpick", "n -- x", "stack/rstack"],
649
+ ["rreset", "--"],
650
+ ["rroll", "n --", "stack/rstack"],
651
+ ["rstack", "-- st"],
652
+ ["rswap", "{x y -- y x}"],
653
+ ["rusage", "-- m"],
654
+ ["rxchg", "x \\ y -- y \\ x"],
655
+ ["s>ns", "s -- n"],
656
+ ["same?", "x y -- T"],
657
+ ["scriptdir", "-- s"],
658
+ ["scriptfile", "-- a"],
659
+ ["sem", "s n -- X"],
660
+ ["sem-post", "X --"],
661
+ ["sem-rm", "X --"],
662
+ ["sem-wait", "X --"],
663
+ ["sem-wait?", "X -- T"],
664
+ ["sem>name", "X -- X s"],
665
+ ["semi-throw", "T --"],
666
+ ["set-wipe", "s -- s | b -- b"],
667
+ ["setenv", "var val --"],
668
+ ["setjmp", "w -- n"],
669
+ ["settings!", "s x --", "utils/settings"],
670
+ ["settings![]", "[key,val,...] --", "utils/settings"],
671
+ ["settings-clear", "--", "utils/settings"],
672
+ ["settings-db-name", "-- s", "utils/settings"],
673
+ ["settings-gather", "a -- s", "utils/settings"],
674
+ ["settings-load", "--", "utils/settings"],
675
+ ["settings-save", "--", "utils/settings"],
676
+ ["settings-save-these", "a --", "utils/settings"],
677
+ ["settings-ungather", "s -- T", "utils/settings"],
678
+ ["settings@", "s -- x", "utils/settings"],
679
+ ["settings@?", "s x -- x'", "utils/settings"],
680
+ ["settings@[]", "[key,...] -- [val,...]", "utils/settings"],
681
+ ["sh", "s w --"],
682
+ ["sh!", "s -- n"],
683
+ ["sh!to", "s n -- n'"],
684
+ ["sh$", "s w --"],
685
+ ["short-days", "-- v"],
686
+ ["short-months", "-- v"],
687
+ ["sleep", "n --"],
688
+ ["sleep-msec", "n --"],
689
+ ["sleep-nsec", "n --"],
690
+ ["sleep-until", "d --", "utils/sleep"],
691
+ ["slog", "x s --"],
692
+ ["space", "--"],
693
+ ["stack-check", "T --"],
694
+ ["stack-size", "n --"],
695
+ ["step", "n --"],
696
+ ["sthrow", "x s --"],
697
+ ["string?", "x -- x T"],
698
+ ["struct:", "-- str", "utils/structs"],
699
+ ["swap", "a b -- b a"],
700
+ ["tab-hook", "s -- a"],
701
+ ["tell-conflict", "-- v"],
702
+ ["tempdir", "-- s"],
703
+ ["tempfilename", "-- s"],
704
+ ["then", "--"],
705
+ ["third", "a b c -- a b c a"],
706
+ ["throw", "x --"],
707
+ ["thrownull", "x y -- x"],
708
+ ["times", "w n --"],
709
+ ["toggle", "v -- T"],
710
+ ["tri", "x w1 w2 w3 -- w1(x) w2(x) w3(x)", "combinators/tri"],
711
+ ["true", "-- T"],
712
+ ["tuck", "a b -- b a b"],
713
+ ["type-check", "T --"],
714
+ ["typeassert", "n1 n2 --"],
715
+ ["uid", "x -- x s"],
716
+ ["uname", "-- m"],
717
+ ["unlock", "x -- x"],
718
+ ["unpack", "s s -- a n | b s -- a n | s n s -- a n | b n s -- a n"],
719
+ ["until", "x -- x"],
720
+ ["until!", "x --"],
721
+ ["var", "<name> --"],
722
+ ["var,", "x <name> --"],
723
+ ["while", "x -- x"],
724
+ ["while!", "x --"],
725
+ ["with:", "<name> --"],
726
+ ["word?", "x -- x T"],
727
+ ["words", "--", "utils/words"],
728
+ ["words-like", "s -- a | r -- a | null -- a", "utils/words"],
729
+ ["words/", "<filter> --", "utils/words"],
730
+ ["xchg", "x v -- x'"],
731
+ ["xor", "T T -- T"],
732
+ ],
733
+ },
734
+ "a": {
735
+ title: "Array",
736
+ words: [
737
+ ["!", "a n x -- a"],
738
+ ["+", "a1 a2 -- a1"],
739
+ ["-", "a n -- a | a a' -- a"],
740
+ ["/", "a n -- a1 a2 | a w -- a1 a2"],
741
+ ["2each", "a1 a2 w -- a1 a2"],
742
+ ["2len", "a1 a2 -- a1 a2 n1 n2"],
743
+ ["2map", "a1 a2 w -- a'"],
744
+ ["2map+", "a1 a2 w n1 n2 -- a'"],
745
+ ["2map=", "a1 a2 w -- a1"],
746
+ ["2reduce", "a1 a2 w x -- x'"],
747
+ ["<>", "a n1 n2 -- a"],
748
+ ["=", "a1 a2 w -- a1 a2 T"],
749
+ ["@", "a n -- a x | a a1 -- a a2"],
750
+ ["@?", "a n x -- a x' | a1 a2 x -- a a2"],
751
+ ["[]!", "a n x -- a"],
752
+ ["_@", "a n -- x"],
753
+ ["_len", "a -- n"],
754
+ ["_push", "a x --"],
755
+ ["all", "a w -- T", "python/any"],
756
+ ["any", "a w -- T", "python/any"],
757
+ ["bsearch", "a x w -- a n"],
758
+ ["centroid", "a -- a'", "array/centroid"],
759
+ ["clear", "a -- a"],
760
+ ["close", "x1 x2 x3 ... xN n -- a"],
761
+ ["cluster-hier", "a1 n1 w n2 -- a1 a2"],
762
+ ["cluster-kmeans", "a1 n1 n2 -- a1 a2"],
763
+ ["cmp", "a1 a2 w -- a1 a2 n", "array/cmp"],
764
+ ["diff", "a1 a2 w -- a1"],
765
+ ["dot", "a1 a2 w1 w2 -- x"],
766
+ ["each", "a w -- a"],
767
+ ["each!", "a w -- a"],
768
+ ["each-par", "a w n -- a", "array/parallel"],
769
+ ["each-slice", "a w n -- a", "array/each-slice"],
770
+ ["exists?", "a n -- a T"],
771
+ ["filter", "a w -- a'"],
772
+ ["filter-par", "a w n -- a'", "array/parallel"],
773
+ ["generate", "w n1 n2 -- a | w -- a"],
774
+ ["group", "a w -- m"],
775
+ ["indexof", "a x w -- a n"],
776
+ ["insert", "a1 a2 n -- a3 | a1 x n -- a3"],
777
+ ["intersect", "a1 a2 w -- a3"],
778
+ ["join", "a sep -- s"],
779
+ ["len", "a -- a n"],
780
+ ["map", "a w -- a'"],
781
+ ["map+", "a w n1 n2 -- a'"],
782
+ ["map-par", "a w n -- a'", "array/parallel"],
783
+ ["map=", "a w -- a"],
784
+ ["maxlen", "a -- n", "array/maxlen"],
785
+ ["mean", "a -- a n", "math/mean"],
786
+ ["mean&variance", "a -- a a'", "math/mean"],
787
+ ["merge", "a1 a2 w -- a3"],
788
+ ["new", "-- a"],
789
+ ["op!", "a n w -- a"],
790
+ ["open", "a -- x1 x2 x3 ... xN"],
791
+ ["pca-reduce", "a n -- a'"],
792
+ ["pigeon", "a1 a2 x w -- x'"],
793
+ ["pivot", "a -- a'"],
794
+ ["pop", "a -- a x"],
795
+ ["push", "a x -- a | x a -- a"],
796
+ ["push-n", "a x n -- a", "array/pushn"],
797
+ ["qsort", "a w -- a"],
798
+ ["randeach", "a w -- a"],
799
+ ["reduce", "a w x -- x'"],
800
+ ["reduce+", "a w x n1 n2 -- x'"],
801
+ ["remove", "a x -- a n"],
802
+ ["rev", "a -- a"],
803
+ ["rindexof", "a x w -- a n"],
804
+ ["search", "a w -- a n"],
805
+ ["shift", "a -- a x"],
806
+ ["shuffle", "a -- a"],
807
+ ["slice", "a n1 n2 -- a'"],
808
+ ["slice+", "a n1 n2 step -- a'"],
809
+ ["slide", "a x -- a"],
810
+ ["smear", "a n -- a"],
811
+ ["sort", "a w -- a"],
812
+ ["split", "a n -- a'"],
813
+ ["squash", "a -- a'"],
814
+ ["umap-reduce", "a m -- a'"],
815
+ ["union", "a1 a2 w -- a3"],
816
+ ["uniq", "a w -- a'"],
817
+ ["unzip", "a -- a'"],
818
+ ["when", "a --"],
819
+ ["when!", "a --"],
820
+ ["when-n", "x a --"],
821
+ ["x", "a1 a2 w -- a3"],
822
+ ["x-each", "a1 a2 w -- a1 a2"],
823
+ ["xchg", "a n x -- a x'"],
824
+ ["y", "a w -- a'"],
825
+ ["zip", "a1 a2 -- a3 a4 ..."],
826
+ ],
827
+ },
828
+ "b": {
829
+ title: "Buffer",
830
+ words: [
831
+ ["!", "b n1 n2 -- b'"],
832
+ ["+", "b1 b2 -- b3"],
833
+ ["/", "b n -- a | b a1 -- a2"],
834
+ ["1+", "b n -- b"],
835
+ ["1-", "b n -- b"],
836
+ ["<>", "b n1 n1 -- b"],
837
+ ["=", "b1 b2 -- T"],
838
+ [">base16", "s -- s | b -- s"],
839
+ [">base32", "s -- s | b -- s"],
840
+ [">base64", "b -- s | s -- s"],
841
+ [">base85", "s -- s | b -- s"],
842
+ [">hex", "s -- b"],
843
+ [">mpack", "x -- b T"],
844
+ ["@", "b n -- b n'"],
845
+ ["ICONVLIBS", "-- a"],
846
+ ["append", "b1 b2 -- b1"],
847
+ ["base16>", "s -- b"],
848
+ ["base32>", "s -- b"],
849
+ ["base64>", "s -- b"],
850
+ ["base85>", "s -- b"],
851
+ ["bit!", "b n1 n2 -- b"],
852
+ ["bit@", "b n -- b n'"],
853
+ ["clear", "b -- b"],
854
+ ["compress", "b -- b'"],
855
+ ["conv", "b from to -- b' | b from to -- null"],
856
+ ["each", "b w --"],
857
+ ["each!", "b w --"],
858
+ ["each-slice", "b n w --"],
859
+ ["expand", "b n -- b'"],
860
+ ["fill", "b n -- b' | b n s -- b' | b n b2 -- b'"],
861
+ ["getb", "b -- b n", "buf/getb"],
862
+ ["hex>", "b -- s"],
863
+ ["len", "b -- b n"],
864
+ ["mem>", "n size -- b"],
865
+ ["move", "b dst src n -- b"],
866
+ ["mpack-compat", "T --"],
867
+ ["mpack-date", "T --"],
868
+ ["mpack-ignore", "T --"],
869
+ ["mpack>", "b -- x T"],
870
+ ["n!", "b n1 n2 T n3 -- b"],
871
+ ["n+", "b n1 n2 -- b"],
872
+ ["n@", "b n1 n2 T -- b n'"],
873
+ ["new", "x -- b"],
874
+ ["op", "source key w -- b"],
875
+ ["op!", "b n w -- b"],
876
+ ["pad", "b n -- b'", "buf/pad"],
877
+ ["rev", "b -- b'"],
878
+ ["search", "haystack needle -- haystack n | haystack ofs needle -- haystack n"],
879
+ ["shmem", "s n T -- b"],
880
+ ["slice", "b1 n1 n2 -- b2"],
881
+ ["splice", "b1 b2 n -- b'"],
882
+ ["ungetb", "b n -- b", "buf/getb"],
883
+ ["unpad", "b -- b'", "buf/pad"],
884
+ ["writable", "b T -- b"],
885
+ ["xor", "b n -- b' | b1 b2 -- b'"],
886
+ ],
887
+ },
888
+ "c": {
889
+ title: "Complex",
890
+ words: [
891
+ ["*", "c1 c2 -- c3", "math/complex"],
892
+ ["+", "c1 c2 -- c3", "math/complex"],
893
+ ["=", "c1 c2 -- T", "math/complex"],
894
+ [">polar", "c -- c'", "math/complex"],
895
+ [">ri", "c -- real imag", "math/complex"],
896
+ ["^", "c n -- c'", "math/complex"],
897
+ ["abs", "c -- n", "math/complex"],
898
+ ["arg", "c -- n", "math/complex"],
899
+ ["conj", "c -- c'", "math/complex"],
900
+ ["im", "c -- im", "math/complex"],
901
+ ["log", "c -- c'", "math/complex"],
902
+ ["n>", "n -- c", "math/complex"],
903
+ ["new", "real imag -- c | a -- c", "math/complex"],
904
+ ["polar>", "n1 n2 -- c", "math/complex"],
905
+ ["re", "c -- re", "math/complex"],
906
+ ],
907
+ },
908
+ "con": {
909
+ title: "Console",
910
+ words: [
911
+ [">redir", "--", "console/redirect"],
912
+ ["accept", "n a -- s"],
913
+ ["accept-nl", "T --"],
914
+ ["accept-pwd", "n -- s"],
915
+ ["alert", "--"],
916
+ ["ansi?", "-- T"],
917
+ ["black", "--", "console/loaded"],
918
+ ["blue", "--", "console/loaded"],
919
+ ["clreol", "--"],
920
+ ["cls", "--"],
921
+ ["ctrld-empty", "T --"],
922
+ ["cyan", "--", "console/loaded"],
923
+ ["down", "--"],
924
+ ["file>history", "T s --", "console/history"],
925
+ ["free", "--"],
926
+ ["getxy", "-- row col"],
927
+ ["gotoxy", "row col --"],
928
+ ["green", "--", "console/loaded"],
929
+ ["history-handler", "w --", "console/history"],
930
+ ["history>file", "s --", "console/history"],
931
+ ["init", "-- T"],
932
+ ["key", "-- n"],
933
+ ["key?", "-- T"],
934
+ ["left", "--"],
935
+ ["load-history", "a T --"],
936
+ ["magenta", "--", "console/loaded"],
937
+ ["max-history", "n --"],
938
+ ["onBlack", "--", "console/loaded"],
939
+ ["onBlue", "--", "console/loaded"],
940
+ ["onCyan", "--", "console/loaded"],
941
+ ["onGreen", "--", "console/loaded"],
942
+ ["onMagenta", "--", "console/loaded"],
943
+ ["onRed", "--", "console/loaded"],
944
+ ["onWhite", "--", "console/loaded"],
945
+ ["onYellow", "--", "console/loaded"],
946
+ ["print", "s --"],
947
+ ["red", "--", "console/loaded"],
948
+ ["redir>", "-- s", "console/redirect"],
949
+ ["redir?", "-- T"],
950
+ ["right", "--"],
951
+ ["save-history", "w -- | null --"],
952
+ ["size?", "-- col row"],
953
+ ["up", "--"],
954
+ ["white", "--", "console/loaded"],
955
+ ["yellow", "--", "console/loaded"],
956
+ ],
957
+ },
958
+ "cr": {
959
+ title: "Crypto",
960
+ words: [
961
+ [">aes128gcm", "b key -- b' | s key -- b", "crypto/aes128gcm"],
962
+ [">aes256gcm", "sb sb2 -- b | sb sb2 -- b"],
963
+ [">cp", "sb sb2 -- b"],
964
+ [">cpe", "sb b b2 -- b3"],
965
+ [">decrypt", "s key -- cr | b key -- cr | s key iv aad tag -- cr | b key iv aad tag -- cr | m -- cr"],
966
+ [">edbox", "s b -- b2 | b b2 -- b2"],
967
+ [">encrypt", "s key -- cr | b key -- cr | s key iv aad -- cr | b key iv aad -- cr | m -- cr"],
968
+ [">nbuf", "num -- buf", "crypto/totp"],
969
+ [">rsabox", "sb b -- b'"],
970
+ [">uuid", "b -- s"],
971
+ ["aad?", "-- T"],
972
+ ["aes128box-sig", "item key -- b", "crypto/aes128gcm"],
973
+ ["aes128gcm>", "b key -- b' T", "crypto/aes128gcm"],
974
+ ["aes256box-sig", "-- b"],
975
+ ["aes256gcm>", "b b2 -- b'"],
976
+ ["aesgcm", "--"],
977
+ ["blakehash", "--"],
978
+ ["chacha20box-sig", "-- b"],
979
+ ["chachapoly", "--"],
980
+ ["cipher!", "s --"],
981
+ ["cipher@", "-- s"],
982
+ ["ciphers", "-- a"],
983
+ ["cp>", "b b2 -- b'"],
984
+ ["cpe>", "b b2 b3 -- b'"],
985
+ ["decrypt", "--"],
986
+ ["decrypt+", "s cr -- cr | b cr -- cr"],
987
+ ["decrypt>", "cr -- b | cr -- tag b"],
988
+ ["ebox-sig", "b -- b'"],
989
+ ["ecc-curves", "-- a"],
990
+ ["ecc-genkey", "n -- priv pub"],
991
+ ["ecc-secret", "priv pub -- b"],
992
+ ["ecc-sign", "priv hash -- sig"],
993
+ ["ecc-verify", "pub hash sig -- T"],
994
+ ["ed25519", "-- priv pub"],
995
+ ["ed25519-secret", "priv pub -- b"],
996
+ ["ed25519-sign", "priv hash -- sig"],
997
+ ["ed25519-verify", "pub hash sig -- T"],
998
+ ["edbox-sig", "-- b"],
999
+ ["edbox>", "b sb b2 -- T"],
1000
+ ["encrypt", "--"],
1001
+ ["encrypt+", "s cr -- cr | b cr -- cr"],
1002
+ ["encrypt>", "cr -- b | cr -- tag b"],
1003
+ ["ensurekey", "s n -- b | b n -- b"],
1004
+ ["genkey", "pwd salt iter -- key"],
1005
+ ["hash", "s -- cr | b -- cr"],
1006
+ ["hash!", "s --"],
1007
+ ["hash+", "s cr -- cr | b cr -- cr"],
1008
+ ["hash>b", "cr -- b"],
1009
+ ["hash>s", "cr -- s"],
1010
+ ["hash@", "-- s"],
1011
+ ["hashes", "-- a"],
1012
+ ["hmac", "s key -- cr | b key -- cr"],
1013
+ ["hotp", "b n1 n2 -- s", "crypto/totp"],
1014
+ ["iv?", "-- T"],
1015
+ ["pem-read", "s -- m | b -- m"],
1016
+ ["pem-write", "name header b filename -- T"],
1017
+ ["pwd-valid?", "s m -- T", "crypto/password"],
1018
+ ["pwd/", "s -- m", "crypto/password"],
1019
+ ["pwd>hash", "s n -- salt hash", "crypto/password"],
1020
+ ["rand", "-- n"],
1021
+ ["randbuf", "n -- b"],
1022
+ ["randkey", "-- b"],
1023
+ ["random-salt", "n -- s", "crypto/password"],
1024
+ ["restore", "X --"],
1025
+ ["root-certs", "-- v", "crypto/root-certs"],
1026
+ ["rsa_decrypt", "b s -- b' | b b -- b'"],
1027
+ ["rsa_encrypt", "b s -- b' | b b -- b'"],
1028
+ ["rsa_sign", "hash key -- b"],
1029
+ ["rsa_verify", "hash key sig -- T"],
1030
+ ["rsabox-sig", "-- b"],
1031
+ ["rsabox>", "b sb b2 -- T"],
1032
+ ["rsagenkey", "n -- priv pub"],
1033
+ ["save", "-- X"],
1034
+ ["sbox-sig", "b -- b'"],
1035
+ ["sha1-hmac", "msg key -- hash", "crypto/totp"],
1036
+ ["shard", "s n m -- a | b n m -- a"],
1037
+ ["tag?", "-- T"],
1038
+ ["totp", "b n1 n2 -- s", "crypto/totp"],
1039
+ ["totp-epoch", "-- var", "crypto/totp"],
1040
+ ["totp-time-step", "-- var", "crypto/totp"],
1041
+ ["unshard", "a -- b"],
1042
+ ["uuid", "-- s"],
1043
+ ["uuid>", "s -- b"],
1044
+ ["validate-pgp-sig", "fname -- ok", "crypto/pgp"],
1045
+ ["validate-pwd", "pwd salt hash -- T", "crypto/password"],
1046
+ ],
1047
+ },
1048
+ "d": {
1049
+ title: "Date",
1050
+ words: [
1051
+ ["(.time)", "n -- s", "date/utils"],
1052
+ ["+", "d n -- d'"],
1053
+ ["+day", "d1 n -- d2", "date/utils"],
1054
+ ["+hour", "d1 n -- d2", "date/utils"],
1055
+ ["+min", "d1 min -- d2", "date/utils"],
1056
+ ["+msec", "d n -- d'"],
1057
+ ["-", "d1 d2 -- n"],
1058
+ [".time", "n --", "date/utils"],
1059
+ ["/", "d -- a"],
1060
+ ["=", "d1 d2 -- T"],
1061
+ [">fixed", "d -- n"],
1062
+ [">hmds", "n -- s | d -- s", "date/format"],
1063
+ [">hmds:", "n -- s | d -- s", "date/format"],
1064
+ [">msec", "d -- n"],
1065
+ [">unix", "d -- n"],
1066
+ [">ymd", "d1 -- y m d", "date/utils"],
1067
+ ["?=", "d1 d2 n -- T", "date/approx"],
1068
+ ["Fri", "-- 5", "date/utils"],
1069
+ ["Mon", "-- 1", "date/utils"],
1070
+ ["Sat", "-- 6", "date/utils"],
1071
+ ["Sun", "-- 0", "date/utils"],
1072
+ ["Thu", "-- 4", "date/utils"],
1073
+ ["Tue", "-- 2", "date/utils"],
1074
+ ["Wed", "-- 3", "date/utils"],
1075
+ ["adjust-dst", "d n -- d", "date/dst"],
1076
+ ["alarm", "d m -- | d --", "date/alarm"],
1077
+ ["approx!", "d n -- d"],
1078
+ ["approx?", "d -- d n"],
1079
+ ["approximates!", "a --", "date/approx"],
1080
+ ["between", "d1 d2 d3 -- T"],
1081
+ ["cmp", "d1 d2 -- n"],
1082
+ ["d.", "d --", "date/utils"],
1083
+ ["daylight-db", "-- db", "date/daylight"],
1084
+ ["default-now", "T --"],
1085
+ ["doy", "d -- day-in-year", "date/utils"],
1086
+ ["dst-ofs", "s d -- n", "date/daylight"],
1087
+ ["dst?", "d n -- d f", "date/dst"],
1088
+ ["dstinfo", "s -- a | n -- a", "date/daylight"],
1089
+ ["dstquery", "s start end -- a", "date/daylight"],
1090
+ ["dstzones?", "-- a", "date/daylight"],
1091
+ ["elapsed-timer", "n -- elapsed", "utils/elapsed"],
1092
+ ["elapsed-timer-hmds", "n T -- s", "utils/elapsed"],
1093
+ ["elapsed-timer-msec", "n -- msecs", "utils/elapsed"],
1094
+ ["elapsed-timer-seconds", "n -- secs", "utils/elapsed"],
1095
+ ["first-dow", "d1 dow -- d2", "date/utils"],
1096
+ ["fixed>", "n -- d"],
1097
+ ["fixed>dow", "n -- n", "date/utils"],
1098
+ ["fixed>iso", "n -- yy ww dd"],
1099
+ ["format", "s d -- s' | d s -- s'"],
1100
+ ["iso>fixed", "yy ww dd -- n"],
1101
+ ["join", "a -- d"],
1102
+ ["last-dow", "d1 dow -- d2", "date/utils"],
1103
+ ["last-month", "d1 -- d2", "date/utils"],
1104
+ ["last-week", "d1 -- d2", "date/utils"],
1105
+ ["last-year", "d1 -- d2", "date/utils"],
1106
+ ["leap?", "d -- d T"],
1107
+ ["mdays", "d -- d n"],
1108
+ ["msec", "-- n"],
1109
+ ["msec>", "n -- d"],
1110
+ ["new", "-- d"],
1111
+ ["next-dow", "d1 dow -- d2", "date/utils"],
1112
+ ["next-month", "d1 -- d2", "date/utils"],
1113
+ ["next-week", "d1 -- d2", "date/utils"],
1114
+ ["next-year", "d1 -- d2", "date/utils"],
1115
+ ["parse", "s -- d"],
1116
+ ["parse-approx", "s -- d|null", "date/approx"],
1117
+ ["parse-range", "s -- a|null", "date/range"],
1118
+ ["prev-dow", "d1 dow -- d2", "date/utils"],
1119
+ ["relative", "d1 d2 -- s T", "date/relative"],
1120
+ ["rfc5322", "d -- s", "date/rfc"],
1121
+ ["start-timer", "n --", "utils/elapsed"],
1122
+ ["ticks", "-- n"],
1123
+ ["ticks/sec", "-- n"],
1124
+ ["timer", "m -- X"],
1125
+ ["timer-ctrl", "X m --"],
1126
+ ["tzadjust", "d n -- d'"],
1127
+ ["unix>", "n -- d"],
1128
+ ["unknown", "-- d"],
1129
+ ["unknown?", "d -- d T"],
1130
+ ["updatetz", "n --"],
1131
+ ["year@", "d -- d y", "date/utils"],
1132
+ ["ymd", "d -- d s", "date/utils"],
1133
+ ["ymd>", "y m d -- d1", "date/utils"],
1134
+ ],
1135
+ },
1136
+ "f": {
1137
+ title: "File",
1138
+ words: [
1139
+ ["/", "s -- a"],
1140
+ [">posix", "s -- s'"],
1141
+ ["abspath", "f -- s | s -- s'"],
1142
+ ["absrel", "f s -- s | s1 s2 -- s3", "file/absrel"],
1143
+ ["append", "f -- f"],
1144
+ ["associate", "ext desc longdesc app --"],
1145
+ ["atime", "f -- f d"],
1146
+ ["autodel", "f -- f"],
1147
+ ["canwrite?", "s -- T"],
1148
+ ["chmod", "f n -- | f s -- | s n -- | s s' --"],
1149
+ ["close", "f --"],
1150
+ ["copy", "src dest -- T"],
1151
+ ["copyasset", "src dest -- T"],
1152
+ ["copydir", "src dest -- T"],
1153
+ ["create", "s -- f"],
1154
+ ["ctime", "f -- f d"],
1155
+ ["dir?", "s -- T"],
1156
+ ["dname", "s -- s'"],
1157
+ ["eachbuf", "f w n -- f | s w n --"],
1158
+ ["eachline", "f w -- f | s w --"],
1159
+ ["enssep", "s -- s'"],
1160
+ ["eof?", "f -- f T"],
1161
+ ["epub-meta", "s -- m", "file/epub"],
1162
+ ["exec", "s --"],
1163
+ ["exists?", "s -- T"],
1164
+ ["expand", "s -- s'"],
1165
+ ["expand-home", "s -- s'"],
1166
+ ["flush", "f -- f"],
1167
+ ["fname", "s -- s'"],
1168
+ ["getb", "f -- f n", "file/getc"],
1169
+ ["getc", "f -- f n", "file/getc"],
1170
+ ["getline", "f -- f s"],
1171
+ ["getmod", "f -- n | s -- n"],
1172
+ ["glob", "s -- a | s w -- a"],
1173
+ ["glob-links", "T --"],
1174
+ ["glob-nocase", "T --"],
1175
+ ["globfilter", "s a T -- a'", "file/globfilter"],
1176
+ ["gunz", "readcb writecb -- n"],
1177
+ ["homedir", "-- s"],
1178
+ ["homedir!", "s --"],
1179
+ ["include", "s --"],
1180
+ ["ioctl", "f req x -- f x' n | f null"],
1181
+ ["join", "a -- s"],
1182
+ ["launch", "s params --"],
1183
+ ["link", "orig link -- T"],
1184
+ ["link>", "s -- s'"],
1185
+ ["link?", "s -- T"],
1186
+ ["lock", "f ofs len x -- f T"],
1187
+ ["mkdir", "s -- T | a -- T"],
1188
+ ["mmap", "s T -- b"],
1189
+ ["mmap-range", "s T start end -- b"],
1190
+ ["mmap-range?", "b -- b start end"],
1191
+ ["mtime", "f -- f d"],
1192
+ ["mv", "oldname newname -- T"],
1193
+ ["name@", "f -- f s"],
1194
+ ["open", "s -- f | n -- f"],
1195
+ ["open!", "s -- f"],
1196
+ ["open-ro", "s -- f"],
1197
+ ["popen", "s T -- f"],
1198
+ ["popen3", "s -- a"],
1199
+ ["prepend", "x s --", "file/prepend"],
1200
+ ["print", "s --", "file/print"],
1201
+ ["read", "f s n -- f s n | f b n -- f b n | f n -- f b n"],
1202
+ ["read-buf", "f n -- f b"],
1203
+ ["read?", "f s n -- f s n"],
1204
+ ["relpath", "f s -- s' | name s -- s'"],
1205
+ ["rglob", "s -- a | s w -- a"],
1206
+ ["rm", "s -- T | a -- T"],
1207
+ ["rmdir", "s -- T | a -- T"],
1208
+ ["seek", "f n -- f"],
1209
+ ["sep", "-- n"],
1210
+ ["size", "f -- f n | s -- s n"],
1211
+ ["slurp", "s -- b | f -- b"],
1212
+ ["slurp-csv", "s a T -- m | s1 s2 T -- m", "file/slurp-csv"],
1213
+ ["slurp-null", "s --", "file/slurp-csv"],
1214
+ ["slurp-num", "T --", "file/slurp-csv"],
1215
+ ["slurp-sep", "s --", "file/slurp-csv"],
1216
+ ["sparse?", "f -- T | s -- T"],
1217
+ ["spit", "x s --"],
1218
+ ["stderr", "-- f"],
1219
+ ["stdin", "-- f"],
1220
+ ["stdout", "-- f"],
1221
+ ["tell", "f -- f n"],
1222
+ ["tempfile", "-- f"],
1223
+ ["tilde", "T --"],
1224
+ ["tilde?", "-- T"],
1225
+ ["times", "s d1 d2 -- | s n1 n2 --"],
1226
+ ["tmpspit", "x -- s"],
1227
+ ["trash", "s -- T"],
1228
+ ["truncate", "f n -- f | s n -- s"],
1229
+ ["ungetb", "f b -- f", "file/getc"],
1230
+ ["ungetc", "f n -- f", "file/getc"],
1231
+ ["unzip", "f s T -- f"],
1232
+ ["unzip-entry", "f s n T -- f"],
1233
+ ["watch", "m -- X"],
1234
+ ["write", "f s -- f n | f b -- f n"],
1235
+ ["writen", "f s n -- f n | f b n -- f n"],
1236
+ ["zip+", "f s x -- f"],
1237
+ ["zip@", "f x -- f b"],
1238
+ ["zipentry", "f n -- f d n' s"],
1239
+ ["zipnew", "-- f"],
1240
+ ["zipopen", "s -- f | b -- f"],
1241
+ ["zipsave", "f s --"],
1242
+ ],
1243
+ },
1244
+ "h": {
1245
+ title: "Heap",
1246
+ words: [
1247
+ ["+", "h1 h2 -- h1"],
1248
+ [">a", "h -- a"],
1249
+ ["@", "h n -- h x"],
1250
+ ["clear", "h -- h"],
1251
+ ["cmp!", "h w -- h"],
1252
+ ["len", "h -- h n"],
1253
+ ["max!", "h T -- h"],
1254
+ ["new", "w -- h"],
1255
+ ["peek", "h -- h x"],
1256
+ ["pop", "h -- h x"],
1257
+ ["push", "h x -- h"],
1258
+ ["unique", "h T -- h"],
1259
+ ],
1260
+ },
1261
+ "m": {
1262
+ title: "Map",
1263
+ words: [
1264
+ ["!", "m s x -- m | m n x -- m"],
1265
+ ["!?", "m s x -- m"],
1266
+ ["+", "m1 m2 -- m1"],
1267
+ ["+?", "m m2 -- m"],
1268
+ ["-", "m s -- m | m a -- m"],
1269
+ ["<>", "m s1 s2 -- m"],
1270
+ ["=", "m1 m2 w -- m1 m2 T"],
1271
+ [">arr", "m -- a"],
1272
+ ["@", "m s -- m x | m n -- m x | m a -- m a'"],
1273
+ ["@?", "m s x -- m x' | m a x -- m a'"],
1274
+ ["[]!", "m s x -- m"],
1275
+ ["_!", "m x key -- m"],
1276
+ ["_@", "m s -- x"],
1277
+ ["_@?", "m s x -- x' | m a x -- a'"],
1278
+ ["accumulate", "m1 m2 -- m1", "map/accumulate"],
1279
+ ["alias", "m s1 s2 -- m"],
1280
+ ["arr>", "a -- m"],
1281
+ ["bitmap", "m a n -- n'"],
1282
+ ["clear", "m -- m"],
1283
+ ["data", "m -- m m'"],
1284
+ ["each", "m w -- m"],
1285
+ ["exists?", "m s -- m T | m a -- m T"],
1286
+ ["filter", "m w -- m'"],
1287
+ ["ic", "m T -- m"],
1288
+ ["iter", "m a w -- m", "map/iter"],
1289
+ ["iter-all", "m a w -- m", "map/iter-all"],
1290
+ ["iter-sorted", "m w1 w2 -- m", "map/iter-sorted"],
1291
+ ["iter-sorted-vals", "m w1 w2 -- m", "map/iter-sorted"],
1292
+ ["keys", "m -- m a"],
1293
+ ["len", "m -- m n"],
1294
+ ["map", "m w -- m'"],
1295
+ ["merge", "m1 m2 -- m1", "map/merge"],
1296
+ ["new", "-- m"],
1297
+ ["op!", "m s w -- m | m a w -- m"],
1298
+ ["open", "m -- a1 a2"],
1299
+ ["probe-size", "n --"],
1300
+ ["slice", "m a -- m'"],
1301
+ ["vals", "m -- m a"],
1302
+ ["xchg", "m s x -- m x'"],
1303
+ ["zip", "a1 a2 -- m"],
1304
+ ],
1305
+ },
1306
+ "mat": {
1307
+ title: "Matrix",
1308
+ words: [
1309
+ ["!", "mat a n -- mat | n1 n2... nN n mat -- mat"],
1310
+ ["*", "mat1 mat2 -- mat3"],
1311
+ ["+", "mat1 mat2 -- mat3"],
1312
+ ["=", "mat1 mat2 -- T"],
1313
+ ["@", "mat a -- mat n | n1 n2... nN mat -- mat n"],
1314
+ ["affine", "a -- mat"],
1315
+ ["col", "mat n -- mat'"],
1316
+ ["data", "mat -- mat a"],
1317
+ ["det", "mat -- n"],
1318
+ ["dim?", "mat -- mat a"],
1319
+ ["get-n", "mat n -- mat n' | mat n -- mat c"],
1320
+ ["ident", "n -- mat"],
1321
+ ["inv", "mat -- mat'"],
1322
+ ["m.", "mat --"],
1323
+ ["minor", "mat n1 n2 -- mat'"],
1324
+ ["n*", "mat n -- mat"],
1325
+ ["new", "a1 a2 -- mat"],
1326
+ ["new-minor", "mat -- mat'"],
1327
+ ["rotate", "n -- mat", "math/affine"],
1328
+ ["row", "mat n -- mat'"],
1329
+ ["same-size?", "mat1 mat2 -- mat1 mat2 T"],
1330
+ ["scale", "x y -- mat", "math/affine"],
1331
+ ["shear", "x y -- mat", "math/affine"],
1332
+ ["trans", "mat -- mat'"],
1333
+ ["translate", "x y -- mat", "math/affine"],
1334
+ ["xform", "pt mat -- a | a mat -- a'"],
1335
+ ],
1336
+ },
1337
+ "n": {
1338
+ title: "Number",
1339
+ words: [
1340
+ ["!", "n -- n!", "math/factorial"],
1341
+ ["*", "n1 n2 -- n3 | a n -- a' | a1 a2 -- a3"],
1342
+ ["*/", "n x y -- n'"],
1343
+ ["+", "n1 n2 -- n3 | a n -- a' | a1 a2 -- a3"],
1344
+ ["+!", "n v --"],
1345
+ ["-", "n1 n2 -- n3 | a n -- a' | a1 a2 -- a3"],
1346
+ ["/", "n1 n2 -- n3 | a n -- a' | a1 a2 -- a3"],
1347
+ ["/mod", "n1 n2 -- rem quo"],
1348
+ ["1+", "n -- n'"],
1349
+ ["1-", "n -- n'"],
1350
+ ["<", "n1 n2 -- T"],
1351
+ ["=", "n1 n2 -- T"],
1352
+ [">", "n1 n2 -- T"],
1353
+ [">bool", "n -- T"],
1354
+ ["BIGE", "-- e", "math/big"],
1355
+ ["BIGPI", "-- n", "math/big"],
1356
+ ["E", "-- n"],
1357
+ ["PI", "-- n"],
1358
+ ["^", "n1 n2 -- n3"],
1359
+ ["_mod", "x y -- n", "math/fmod"],
1360
+ ["abs", "n -- n'"],
1361
+ ["acos", "n -- n'"],
1362
+ ["acosd", "cos(n) -- n", "math/trigd"],
1363
+ ["acosh", "n -- n'"],
1364
+ ["andor", "n1 n2 n3 -- n4"],
1365
+ ["asin", "n -- n'"],
1366
+ ["asind", "sin(n) -- n", "math/trigd"],
1367
+ ["asinh", "n -- n'"],
1368
+ ["atan", "n -- n'"],
1369
+ ["atan2", "x y -- n"],
1370
+ ["atand", "tan(n) -- n", "math/trigd"],
1371
+ ["atanh", "n -- n'"],
1372
+ ["band", "n1 n2 -- n3"],
1373
+ ["between", "n low hi -- T"],
1374
+ ["bfloat", "n -- n'"],
1375
+ ["bic", "n1 n2 -- n3"],
1376
+ ["bint", "n -- n'"],
1377
+ ["binv", "n -- n'"],
1378
+ ["bits?", "n -- n'"],
1379
+ ["bnot", "n -- n'"],
1380
+ ["bor", "n1 n2 -- n3"],
1381
+ ["bxor", "n1 n2 -- n3"],
1382
+ ["cast", "n bits T -- n2"],
1383
+ ["ceil", "n -- n'"],
1384
+ ["clamp", "n low hi -- n'"],
1385
+ ["clz?", "n -- n'"],
1386
+ ["cmp", "n1 n2 -- n3"],
1387
+ ["comb", "p k -- comb(p,k)", "math/comb-perm"],
1388
+ ["cos", "n -- n'"],
1389
+ ["cosd", "n -- cos(n)", "math/trigd"],
1390
+ ["cosh", "n -- n'"],
1391
+ ["ctz?", "n -- n'"],
1392
+ ["distance", "a1 a2 -- n"],
1393
+ ["emod", "x y -- n", "math/fmod"],
1394
+ ["erf", "n -- n'"],
1395
+ ["erfc", "n -- n'"],
1396
+ ["exp", "n -- n'"],
1397
+ ["expand-range", "s -- a", "math/range"],
1398
+ ["expm1", "n -- n'"],
1399
+ ["expmod", "n1 n2 n3 -- n4"],
1400
+ ["float", "n -- n'"],
1401
+ ["floor", "n -- n'"],
1402
+ ["fmod", "n1 n2 -- n3"],
1403
+ ["frac", "n -- n'"],
1404
+ ["gcd", "n1 n2 -- n'"],
1405
+ ["int", "n -- n'"],
1406
+ ["invmod", "n1 n2 -- n3"],
1407
+ ["kind?", "n -- n n'"],
1408
+ ["lcm", "n1 n2 -- n'"],
1409
+ ["lerp", "lo hi t -- n"],
1410
+ ["ln", "n -- n'"],
1411
+ ["ln1p", "n -- n'"],
1412
+ ["lnerp", "lo hi t -- n"],
1413
+ ["logistic", "n -- n'", "math/sigmoid"],
1414
+ ["manhattan-distance", "a1 a2 -- n"],
1415
+ ["max", "n1 n2 -- n | a -- n"],
1416
+ ["mean&stddev", "a -- a a'"],
1417
+ ["median", "a -- a n", "math/median"],
1418
+ ["min", "n1 n2 -- n | a -- n"],
1419
+ ["minmax-normal", "a -- a"],
1420
+ ["mod", "n1 n2 -- n3"],
1421
+ ["neg", "n -- n'"],
1422
+ ["odd?", "n -- n'"],
1423
+ ["parity?", "n -- n'"],
1424
+ ["perm", "p k -- perm(p,k)", "math/comb-perm"],
1425
+ ["prime?", "n -- n T"],
1426
+ ["quantize", "val quantum -- qval", "math/quantize"],
1427
+ ["quantize!", "n --", "math/quantize"],
1428
+ ["r+", "n { n1 } -- { n2 }"],
1429
+ ["range", "low high -- a | high low -- a", "math/range"],
1430
+ ["rot32l", "n1 cnt -- n2", "math/rot"],
1431
+ ["rot32r", "n1 cnt -- n2", "math/rot"],
1432
+ ["round", "n -- n'"],
1433
+ ["round2", "n1 n2 -- n3"],
1434
+ ["rounding", "s --"],
1435
+ ["running-variance", "a n -- a", "math/mean"],
1436
+ ["running-variance-finalize", "a -- a'", "math/mean"],
1437
+ ["sgn", "n -- n'"],
1438
+ ["shl", "n1 n2 -- n'"],
1439
+ ["shr", "n1 n2 -- n'"],
1440
+ ["sin", "n -- n'"],
1441
+ ["sincos", "n -- n1 n2"],
1442
+ ["sind", "n -- sin(n)", "math/trigd"],
1443
+ ["sinh", "n -- n'"],
1444
+ ["sqr", "n -- n'"],
1445
+ ["sqrt", "n -- n'"],
1446
+ ["tan", "n -- n'"],
1447
+ ["tand", "n -- tan(n)", "math/trigd"],
1448
+ ["tanh", "n -- n'"],
1449
+ ["trunc", "n -- n'"],
1450
+ ["zscore-normal", "a -- a"],
1451
+ ["~=", "n1 n2 eps -- T"],
1452
+ ],
1453
+ },
1454
+ "o": {
1455
+ title: "Object",
1456
+ words: [
1457
+ ["!", "o s x -- o"],
1458
+ ["+", "o m -- o | o o' -- o"],
1459
+ ["+?", "o m | o | o o' | o"],
1460
+ ["???", "s --"],
1461
+ ["@", "o s -- o x | o a -- o a'"],
1462
+ ["class", "o -- o s"],
1463
+ ["exec", "o ... s --"],
1464
+ ["isa", "o s -- o T"],
1465
+ ["method", "o s w | o m -- o"],
1466
+ ["mutate", "o -- o"],
1467
+ ["new", "o s -- o'"],
1468
+ ["super", "--"],
1469
+ ],
1470
+ },
1471
+ "os": {
1472
+ title: "OS",
1473
+ words: [
1474
+ ["POSIX", "-- T"],
1475
+ ["chroot", "s -- T"],
1476
+ ["devname", "x -- name"],
1477
+ ["disk-stat", "s -- a"],
1478
+ ["docker?", "-- T", "utils/docker"],
1479
+ ["env", "-- m"],
1480
+ ["fork", "-- n"],
1481
+ ["lang", "-- s"],
1482
+ ["locales", "-- a"],
1483
+ ["notify", "m --", "os/notify"],
1484
+ ["power-state", "-- (as of 22.01"],
1485
+ ["region", "-- s"],
1486
+ ["system", "s -- n"],
1487
+ ["waitpid", "n -- n'"],
1488
+ ],
1489
+ },
1490
+ "q": {
1491
+ title: "Queue",
1492
+ words: [
1493
+ ["+", "q q2 -- q"],
1494
+ [">a", "q -- a"],
1495
+ ["clear", "q -- q"],
1496
+ ["len", "q -- q n"],
1497
+ ["new", "n -- q"],
1498
+ ["notify", "q -- q"],
1499
+ ["overwrite", "q T -- q"],
1500
+ ["peek", "q -- q x"],
1501
+ ["pick", "q n -- q x"],
1502
+ ["pop", "q -- q x"],
1503
+ ["push", "q x -- q"],
1504
+ ["remove", "q x -- q n"],
1505
+ ["shift", "q -- q x"],
1506
+ ["size", "q -- q n"],
1507
+ ["slide", "q x -- q"],
1508
+ ["throwing", "q T -- q"],
1509
+ ["wait", "q n -- q"],
1510
+ ],
1511
+ },
1512
+ "r": {
1513
+ title: "Regex",
1514
+ words: [
1515
+ ["++match", "r -- r n"],
1516
+ ["+/", "s r -- a"],
1517
+ ["+match", "r -- r n"],
1518
+ ["/", "s r -- a"],
1519
+ ["@", "r n -- r s | r a -- r a'"],
1520
+ ["_@", "r n -- s | r a -- a'"],
1521
+ ["len", "r -- r n"],
1522
+ ["match", "x r -- r n"],
1523
+ ["match[]", "x r -- a", "regex/match"],
1524
+ ["matchall[]", "x r -- a", "regex/match"],
1525
+ ["new", "s -- r"],
1526
+ ["rx", "r -- r s"],
1527
+ ["str", "r -- r s"],
1528
+ ],
1529
+ },
1530
+ "rat": {
1531
+ title: "Rational",
1532
+ words: [
1533
+ ["*", "r1 r2 -- r1*r2", "math/rational"],
1534
+ ["+", "r1 r2 -- r1+r2", "math/rational"],
1535
+ ["-", "r1 r2 -- r1-r2", "math/rational"],
1536
+ ["/", "r1 r2 -- r1/r2", "math/rational"],
1537
+ [">n", "r -- n", "math/rational"],
1538
+ [">s", "r -- s", "math/rational"],
1539
+ ["new", "num denom -- rat", "math/rational"],
1540
+ ["proper", "r -- n r", "math/rational"],
1541
+ ],
1542
+ },
1543
+ "s": {
1544
+ title: "String",
1545
+ words: [
1546
+ ["!", "s n1 n2 -- s'"],
1547
+ ["*", "s n -- s'"],
1548
+ ["+", "s s2 -- s' | s n -- s'"],
1549
+ ["-", "s n1 n2 -- s'"],
1550
+ ["/", "s n -- a | s a1 -- a2 | s pat -- a | s null -- a"],
1551
+ ["/scripts", "s -- a"],
1552
+ ["/ws", "s -- a"],
1553
+ ["2len", "s1 s2 -- s1 s2 n1 n2"],
1554
+ ["<+", "s s2 -- s' | s n -- s'"],
1555
+ ["<>", "s n1 n2 -- s'"],
1556
+ ["=", "s1 s2 -- T"],
1557
+ ["=ic", "s1 s2 -- T"],
1558
+ [">base64", "s -- s'"],
1559
+ [">ucs2", "s -- b"],
1560
+ ["?", "s1 s2 -- s3"],
1561
+ ["@", "s n -- s n'"],
1562
+ ["_len", "s -- n"],
1563
+ ["append", "s1 s2 -- s1 | s n -- s"],
1564
+ ["base64>", "s -- s'"],
1565
+ ["begins?", "s1 s2 -- T | b1 b2 -- T"],
1566
+ ["clear", "s -- s"],
1567
+ ["cmp", "s1 s2 -- n"],
1568
+ ["cmpi", "s1 s2 -- n"],
1569
+ ["compress", "s -- b | b -- b"],
1570
+ ["count-match", "s s1 -- s n"],
1571
+ ["days!", "short long --"],
1572
+ ["dist", "s1 s2 T -- n"],
1573
+ ["each", "s w --"],
1574
+ ["each!", "s w --"],
1575
+ ["eachline", "s w -- | b w --"],
1576
+ ["escape", "s1 s2 s3 -- s'"],
1577
+ ["expand", "s n -- s' | b n -- b'"],
1578
+ ["expand-env", "s -- s'"],
1579
+ ["fill", "s rep -- s' | s n -- s'"],
1580
+ ["fold", "s T -- s'"],
1581
+ ["gen-uid", "n -- s", "rand/ident"],
1582
+ ["globmatch", "s1 s2 -- T"],
1583
+ ["hexupr", "T --"],
1584
+ ["html-escape", "s -- s'"],
1585
+ ["insert", "s1 s2 n -- s3"],
1586
+ ["intl", "s -- s'", "string/i18n"],
1587
+ ["intl!", "m --", "string/i18n"],
1588
+ ["lang", "s --", "string/i18n"],
1589
+ ["lc", "s -- s'"],
1590
+ ["lc?", "s -- s T | n -- n T"],
1591
+ ["len", "s -- s n"],
1592
+ ["lsub", "s n -- s'"],
1593
+ ["ltrim", "s -- s'"],
1594
+ ["map", "s w -- s'"],
1595
+ ["months!", "short long --"],
1596
+ ["n>", "n -- s | a -- s"],
1597
+ ["new", "n -- s | s -- s' | b -- s"],
1598
+ ["norm", "s n -- s'"],
1599
+ ["propercase", "s -- s'"],
1600
+ ["reduce", "s w x -- x'"],
1601
+ ["repinsert", "s n s2 -- s'", "string/repinsert"],
1602
+ ["replace", "s pat rep -- s'"],
1603
+ ["replace!", "s pat rep -- s'"],
1604
+ ["rev", "s -- s'"],
1605
+ ["rsearch", "haystack needle -- haystack n | haystack ofs needle -- haystack n"],
1606
+ ["rsub", "s n -- s'"],
1607
+ ["rtl", "s -- s'"],
1608
+ ["rtrim", "s -- s'"],
1609
+ ["scan-match", "s s1 s2 -- s n"],
1610
+ ["script?", "s -- s m"],
1611
+ ["search", "haystack needle -- haystack n | haystack ofs needle -- haystack n"],
1612
+ ["size", "s -- s n"],
1613
+ ["slice", "s n1 n2 -- s'"],
1614
+ ["soundex", "s -- s'"],
1615
+ ["strfmap", "m a m2 -- m s", "string/strfmap"],
1616
+ ["strfmt", "a fmt -- s | x1 x2 ... xn fmt -- s"],
1617
+ ["term", "s n -- s'"],
1618
+ ["text-wrap", "s font n -- a"],
1619
+ ["tr", "s1 s2 s3 -- s"],
1620
+ ["transform", "s -- s'", "string/transform"],
1621
+ ["trim", "s -- s'"],
1622
+ ["tsub", "s x -- s'", "string/tsub"],
1623
+ ["uc", "s -- s'"],
1624
+ ["uc?", "s -- s T | n -- n T"],
1625
+ ["ucs2>", "b -- s"],
1626
+ ["utf8?", "s -- s T"],
1627
+ ["zt", "s -- s"],
1628
+ ],
1629
+ },
1630
+ "set": {
1631
+ title: "Sets",
1632
+ words: [
1633
+ [">a", "set -- set a", "types/set"],
1634
+ ["add", "set x -- set", "types/set"],
1635
+ ["add[]", "set a -- set", "types/set"],
1636
+ ["del", "set x -- set", "types/set"],
1637
+ ["difference", "set1 set2 -- set3", "types/set"],
1638
+ ["has", "set x -- set T", "types/set"],
1639
+ ["intersect", "set1 set2 -- set3", "types/set"],
1640
+ ["new", "w -- set", "types/set"],
1641
+ ["union", "set1 set2 -- set3", "types/set"],
1642
+ ],
1643
+ },
1644
+ "st": {
1645
+ title: "Stack",
1646
+ words: [
1647
+ ["+", "st st2 -- st | null st2 --"],
1648
+ [".", "st --"],
1649
+ [">a", "st -- a"],
1650
+ ["clear", "st -- st"],
1651
+ ["dot-depth", "-- v"],
1652
+ ["len", "st -- st n"],
1653
+ ["list", "st n -- a"],
1654
+ ["ndrop", "st n -- st"],
1655
+ ["new", "n -- st"],
1656
+ ["op!", "st w --"],
1657
+ ["peek", "st -- st x"],
1658
+ ["pick", "st n -- st x"],
1659
+ ["pop", "st -- st x"],
1660
+ ["push", "st x -- st"],
1661
+ ["roll", "st n -- st"],
1662
+ ["shift", "st -- st x"],
1663
+ ["size", "st -- st n"],
1664
+ ["slide", "st x -- st"],
1665
+ ["swap", "st -- st"],
1666
+ ["throwing", "st T -- st"],
1667
+ ],
1668
+ },
1669
+ "t": {
1670
+ title: "Task",
1671
+ words: [
1672
+ ["!", "x s --"],
1673
+ ["@", "s -- x | a -- a'"],
1674
+ ["by-name", "s -- a"],
1675
+ ["curtask", "-- t"],
1676
+ ["def-queue", "n --"],
1677
+ ["def-stack", "n --"],
1678
+ ["done?", "t -- t T"],
1679
+ ["dtor", "w --"],
1680
+ ["err!", "n s --"],
1681
+ ["err?", "-- m"],
1682
+ ["errno?", "-- m"],
1683
+ ["extra", "-- x"],
1684
+ ["getq", "-- q"],
1685
+ ["handler", "w --"],
1686
+ ["handler@", "-- w"],
1687
+ ["kill", "t n --"],
1688
+ ["list", "-- a"],
1689
+ ["main", "-- t"],
1690
+ ["max-exceptions", "n --"],
1691
+ ["name!", "s --"],
1692
+ ["name@", "-- s"],
1693
+ ["notify", "t --"],
1694
+ ["parent", "-- t"],
1695
+ ["pop", "-- x"],
1696
+ ["priority", "t n --"],
1697
+ ["push", "t x --"],
1698
+ ["push!", "t x --"],
1699
+ ["q-notify", "t -- t"],
1700
+ ["q-wait", "n --"],
1701
+ ["qlen", "-- n"],
1702
+ ["result", "t -- t x"],
1703
+ ["set-affinity", "n -- | a --"],
1704
+ ["setq", "q --"],
1705
+ ["task", "w -- t | m -- t"],
1706
+ ["task-n", "xn... x2 x1 n w -- t | xn... x2 x1 m -- t"],
1707
+ ["task-stop", "--"],
1708
+ ["ticks", "-- n"],
1709
+ ["to?", "-- T"],
1710
+ ["wait", "t -- | a --"],
1711
+ ["yield", "--"],
1712
+ ],
1713
+ },
1714
+ "w": {
1715
+ title: "Word",
1716
+ words: [
1717
+ ["!", "x s --"],
1718
+ ["(is)", "w s --"],
1719
+ ["@", "s -- x | a -- x"],
1720
+ ["alias:", "w <name> --"],
1721
+ ["cb", "w s -- X"],
1722
+ ["deprecate", "w --"],
1723
+ ["dlcall", "w -- x | w n -- x"],
1724
+ ["dlopen", "s -- X | b -- X"],
1725
+ ["dlsym", "X s nm s2 -- X w"],
1726
+ ["exec", "w --"],
1727
+ ["exec?", "s -- T"],
1728
+ ["ffifail", "s --"],
1729
+ ["find", "s -- w"],
1730
+ ["forget", "s -- | n --"],
1731
+ ["is", "w <name> --"],
1732
+ ["name", "w -- w s"],
1733
+ ["restore", "w --"],
1734
+ ["undo", "w --"],
1735
+ ["xt", "w -- n"],
1736
+ ["xt>", "n -- w"],
1737
+ ],
1738
+ },
1739
+ "app": {
1740
+ title: "Application",
1741
+ words: [
1742
+ ["8thdir", "-- s"],
1743
+ ["asset", "s -- b"],
1744
+ ["atrun", "m --", "lin/atrun"],
1745
+ ["basedir", "-- s"],
1746
+ ["basename", "-- v"],
1747
+ ["config-file-name", "s -- s", "utils/config-file"],
1748
+ ["current", "--"],
1749
+ ["datadir", "-- s"],
1750
+ ["display-moved", "n --"],
1751
+ ["exename", "-- s"],
1752
+ ["localechanged", "--"],
1753
+ ["lowmem", "--"],
1754
+ ["main", "--"],
1755
+ ["meta!", "m --"],
1756
+ ["meta@", "s -- s'"],
1757
+ ["name", "-- v"],
1758
+ ["onback", "--"],
1759
+ ["oncrash", "w --"],
1760
+ ["opts!", "s x --"],
1761
+ ["opts@", "s -- x"],
1762
+ ["orientation", "n --"],
1763
+ ["orientation!", "n --"],
1764
+ ["pid", "-- n"],
1765
+ ["post-main", "--"],
1766
+ ["pre-main", "--"],
1767
+ ["privdir", "-- s"],
1768
+ ["quiet?", "-- T"],
1769
+ ["raise", "n -- | s --"],
1770
+ ["read-config", "s -- m", "utils/config-file"],
1771
+ ["read-config-map", "s -- m", "utils/config-file"],
1772
+ ["read-config-var", "s name -- x", "utils/config-file"],
1773
+ ["read-config-vars", "s a --", "utils/config-file"],
1774
+ ["request-perm", "s -- T"],
1775
+ ["restart", "--"],
1776
+ ["resumed", "--"],
1777
+ ["save-config-vars", "s a --", "utils/config-file"],
1778
+ ["signal", "s --"],
1779
+ ["standalone", "-- v"],
1780
+ ["standalone!", "T --"],
1781
+ ["subdir", "s -- s'"],
1782
+ ["suspended", "T --"],
1783
+ ["sysquit", "-- T"],
1784
+ ["terminated", "--"],
1785
+ ["theme?", "-- n"],
1786
+ ["themechanged", "--"],
1787
+ ["ticks", "-- n"],
1788
+ ["timeout", "n --", "utils/timeout"],
1789
+ ["trap", "n T --"],
1790
+ ],
1791
+ },
1792
+ "tree": {
1793
+ title: "Trees",
1794
+ words: [
1795
+ ["add", "tree x -- tree"],
1796
+ ["binary", "w -- tree"],
1797
+ ["bk", "w n -- tree"],
1798
+ ["btree", "w n -- tree"],
1799
+ ["cmp!", "tree w -- tree"],
1800
+ ["data", "X -- x"],
1801
+ ["del", "tree x -- tree"],
1802
+ ["find", "tree x -- tree X"],
1803
+ ["iter", "tree w n -- tree"],
1804
+ ["next", "X -- X'"],
1805
+ ["nodes", "tree X -- tree a"],
1806
+ ["parent", "X -- X'"],
1807
+ ["parse", "s -- tree"],
1808
+ ["prev", "X -- X'"],
1809
+ ["root", "tree -- tree X"],
1810
+ ["search", "tree x n -- tree a"],
1811
+ ["trie", "w T -- tree"],
1812
+ ],
1813
+ },
1814
+ "gr": {
1815
+ title: "Graph",
1816
+ words: [
1817
+ ["+edge", "gr n1 n2 n3 -- gr | gr n1 n2 n3 x -- gr"],
1818
+ ["+edge+w", "gr n1 n2 n3 n4 -- gr | gr n1 n2 n3 n4 x -- gr"],
1819
+ ["+node", "gr x -- gr"],
1820
+ ["connect", "gr -- gr"],
1821
+ ["each", "gr w T -- gr"],
1822
+ ["edges", "gr -- gr a"],
1823
+ ["edges!", "gr a -- gr"],
1824
+ ["info", "gr -- gr m"],
1825
+ ["m!", "gr s x -- gr"],
1826
+ ["m@", "gr s -- gr x"],
1827
+ ["neighbors", "gr n -- gr a"],
1828
+ ["new", "m -- gr"],
1829
+ ["node-edges", "gr n -- gr a"],
1830
+ ["nodes", "gr -- gr a"],
1831
+ ["search", "gr n1 n2 w -- gr a"],
1832
+ ["traverse", "gr T n w -- gr"],
1833
+ ["weight!", "gr w -- gr"],
1834
+ ],
1835
+ },
1836
+ };
1837
+
1838
+ // Nothing is offered inside these, or while a new name is being typed.
1839
+ const dontComplete = new Set([
1840
+ "String",
1841
+ "Regex",
1842
+ "Character",
1843
+ "LineComment",
1844
+ "BlockComment",
1845
+ "StackEffect",
1846
+ "DefName",
1847
+ "VariableName",
1848
+ "NamespaceName",
1849
+ "ModulePath",
1850
+ ]);
1851
+ // These words are followed by a new name, such as `: square` or `var count`.
1852
+ const beforeName = /(^|\s)(:|var,?|constant|defer:|ns:|with:|needs)\s+$/;
1853
+ const numberPattern = /^[-+]?(\d[\d_]*(\.\d*)?|\.\d+)([eE][-+]?\d+)?$/;
1854
+ const namespacePrefix = /^([A-Za-z_][A-Za-z0-9_]*):/;
1855
+ const keywords = new Set([
1856
+ ":", ";", "if", "!if", "else", "then", ";then", "repeat", "again", "while", "while!", "until",
1857
+ "until!", "break", ";;", "var", "var,", "constant", "defer:", "ns:", "with:", ";with", "needs",
1858
+ "locals:", "true", "false", "null",
1859
+ ]);
1860
+ function inside(node, names) {
1861
+ for (let cur = node; cur; cur = cur.parent)
1862
+ if (names.has(cur.name))
1863
+ return true;
1864
+ return false;
1865
+ }
1866
+ const brackets = new Set(["Array", "Map", "Quotation"]);
1867
+ // Inside an array or a map, `,` and brackets end a word as well as spaces.
1868
+ function inJson(node) {
1869
+ for (let cur = node; cur; cur = cur.parent)
1870
+ if (brackets.has(cur.name))
1871
+ return cur.name != "Quotation";
1872
+ return false;
1873
+ }
1874
+ /// The word before the cursor, if the cursor is somewhere that a word can go.
1875
+ function wordBefore(context) {
1876
+ const inner = syntaxTree(context.state).resolveInner(context.pos, -1);
1877
+ if (inside(inner, dontComplete))
1878
+ return null;
1879
+ const line = context.state.doc.lineAt(context.pos);
1880
+ const before = line.text.slice(0, context.pos - line.from);
1881
+ let text = /\S*$/.exec(before)[0];
1882
+ if (inJson(inner)) {
1883
+ const cut = Math.max(text.lastIndexOf(","), text.lastIndexOf("["), text.lastIndexOf("{"));
1884
+ if (cut >= 0)
1885
+ text = text.slice(cut + 1);
1886
+ }
1887
+ else if (/^[\[{]/.test(text)) {
1888
+ text = text.slice(1);
1889
+ }
1890
+ if (/^["']/.test(text))
1891
+ return null;
1892
+ if (beforeName.test(before.slice(0, before.length - text.length)))
1893
+ return null;
1894
+ if (!context.explicit && (!text || numberPattern.test(text)))
1895
+ return null;
1896
+ return { from: context.pos - text.length, text };
1897
+ }
1898
+ const snippets = [
1899
+ [":", "word definition", ": ${name} \\ ${a} -- ${b}\n\t${}\n;"],
1900
+ ["if", "if then", "if\n\t${}\nthen"],
1901
+ ["if", "if else then", "if\n\t${}\nelse\n\t${}\nthen"],
1902
+ ["!if", "if not then", "!if\n\t${}\nthen"],
1903
+ ["if", "if ;then, which leaves the word", "if ${} ;then"],
1904
+ ["repeat", "repeat while", "repeat\n\t${}\nwhile"],
1905
+ ["repeat", "repeat again, with break", "repeat\n\t${}\n\t${test} if break then\nagain"],
1906
+ ["loop", "( ) low high loop", "( ${} ) ${1} ${10} loop"],
1907
+ ["times", "( ) n times", "( ${} ) ${n} times"],
1908
+ ["var", "variable", "var ${name}"],
1909
+ ["constant", "constant", "constant ${name}"],
1910
+ ["needs", "load a library", "needs ${path}"],
1911
+ ["with:", "namespace block", "with: ${n}\n\t${}\n;with"],
1912
+ ["a:each", "( ) a:each", "( ${} ) a:each"],
1913
+ ["a:map", "( ) a:map", "( ${} ) a:map"],
1914
+ ["a:filter", "( ) a:filter", "( ${} ) a:filter"],
1915
+ ["a:reduce", "( ) initial a:reduce", "( ${} ) ${0} a:reduce"],
1916
+ ["m:each", "( ) m:each", "( ${} ) m:each"],
1917
+ ["m:map", "( ) m:map", "( ${} ) m:map"],
1918
+ ["s:each", "( ) s:each", "( ${} ) s:each"],
1919
+ ];
1920
+ function snippetOption([label, detail, body]) {
1921
+ return snippetCompletion(body, { label, detail, type: "keyword", boost: -1 });
1922
+ }
1923
+ function wordOption(label, effect, needs) {
1924
+ const detail = needs ? `${effect} (needs ${needs})` : effect;
1925
+ return { label, detail, type: keywords.has(label) ? "keyword" : "function" };
1926
+ }
1927
+ // Each namespace's words, with the namespace in the label, and its snippets.
1928
+ const namespaceOptions = new Map();
1929
+ for (const [ns, { words }] of Object.entries(namespaces)) {
1930
+ const options = words.map(([name, effect, needs]) => wordOption(`${ns}:${name}`, effect, needs));
1931
+ for (const snippet of snippets)
1932
+ if (snippet[0].startsWith(ns + ":"))
1933
+ options.push(snippetOption(snippet));
1934
+ namespaceOptions.set(ns, options);
1935
+ }
1936
+ // The words outside any namespace, the namespaces themselves, and the
1937
+ // snippets for the common forms.
1938
+ const globalOptions = [
1939
+ ...namespaces.G.words.map(([name, effect, needs]) => wordOption(name, effect, needs)),
1940
+ ...Object.entries(namespaces)
1941
+ .filter(([ns]) => ns != "G")
1942
+ .map(([ns, { title }]) => ({ label: ns + ":", detail: `${title} words`, type: "namespace", boost: -2 })),
1943
+ ...snippets.filter(([label]) => !namespacePrefix.test(label) || label.endsWith(":")).map(snippetOption),
1944
+ ];
1945
+ /// Completes 8th's words. After a namespace such as `a:`, it offers the words
1946
+ /// in that namespace. Elsewhere it offers the words outside any namespace, the
1947
+ /// namespaces and the snippets.
1948
+ const builtinCompletionSource = (context) => {
1949
+ const word = wordBefore(context);
1950
+ if (!word)
1951
+ return null;
1952
+ const ns = namespacePrefix.exec(word.text);
1953
+ const options = (ns && namespaceOptions.get(ns[1])) || globalOptions;
1954
+ return { from: word.from, options, validFor: ns ? /^[A-Za-z_][A-Za-z0-9_]*:\S*$/ : /^[^\s:]*$/ };
1955
+ };
1956
+ function effectText(state, node) {
1957
+ if (!node)
1958
+ return undefined;
1959
+ return state.sliceDoc(node.from, node.to).replace(/^(\\|SED:)\s*/, "").trim() || undefined;
1960
+ }
1961
+ /// The words, variables and constants defined in the file before `pos`. A word
1962
+ /// can call itself, so a definition's name counts from the name onwards.
1963
+ function localNames(state, pos) {
1964
+ const found = new Map();
1965
+ syntaxTree(state).iterate({
1966
+ enter(node) {
1967
+ var _a;
1968
+ if (node.from >= pos)
1969
+ return false;
1970
+ if (node.name == "DefName" && node.to < pos) {
1971
+ const label = state.sliceDoc(node.from, node.to);
1972
+ const effect = effectText(state, ((_a = node.node.nextSibling) === null || _a === void 0 ? void 0 : _a.name) == "StackEffect" ? node.node.nextSibling : null);
1973
+ found.set(label, { label, type: "function", detail: effect });
1974
+ }
1975
+ else if (node.name == "VariableName" && node.to < pos) {
1976
+ const label = state.sliceDoc(node.from, node.to);
1977
+ const keyword = node.node.prevSibling ? state.sliceDoc(node.node.prevSibling.from, node.node.prevSibling.to) : "";
1978
+ found.set(label, { label, type: keyword == "constant" ? "constant" : "variable" });
1979
+ }
1980
+ return undefined;
1981
+ },
1982
+ });
1983
+ return [...found.values()];
1984
+ }
1985
+ /// Completes the words, variables and constants defined earlier in the file.
1986
+ const localCompletionSource = (context) => {
1987
+ const word = wordBefore(context);
1988
+ if (!word)
1989
+ return null;
1990
+ const options = localNames(context.state, word.from);
1991
+ if (!options.length)
1992
+ return null;
1993
+ return { from: word.from, options, validFor: /^\S*$/ };
1994
+ };
1995
+
1996
+ // The body of a block goes one unit in from the line that opens it, and the
1997
+ // word that closes it goes back to that line's indentation:
1998
+ //
1999
+ // : leap-year? \ n -- T
2000
+ // dup 4 n:mod 0 n:= if
2001
+ // ...
2002
+ // then
2003
+ // ;
2004
+ function blockIndent(closing) {
2005
+ return (context) => closing.test(context.textAfter) ? context.baseIndent : context.baseIndent + context.unit;
2006
+ }
2007
+ // Folds a block from the end of its opening line to the word that closes it.
2008
+ function foldBlock(open, closers) {
2009
+ return (node) => {
2010
+ const first = open(node);
2011
+ const last = node.lastChild;
2012
+ if (!first || !last || !closers.includes(last.name) || last.from <= first.to)
2013
+ return null;
2014
+ return { from: first.to, to: last.from };
2015
+ };
2016
+ }
2017
+ const eighthLanguage = LRLanguage.define({
2018
+ name: "8th",
2019
+ parser: parser.configure({
2020
+ props: [
2021
+ indentNodeProp.add({
2022
+ Definition: blockIndent(/^\s*;(\s|$)/),
2023
+ Conditional: blockIndent(/^\s*(else|then|;then)(\s|$)/),
2024
+ Loop: blockIndent(/^\s*(again|while!?|until!?)(\s|$)/),
2025
+ Quotation: delimitedIndent({ closing: ")", align: false }),
2026
+ Array: delimitedIndent({ closing: "]" }),
2027
+ Map: delimitedIndent({ closing: "}" }),
2028
+ }),
2029
+ foldNodeProp.add({
2030
+ Definition: foldBlock((node) => { var _a; return (_a = node.getChild("StackEffect")) !== null && _a !== void 0 ? _a : node.getChild("DefName"); }, [";"]),
2031
+ Conditional: foldBlock((node) => node.firstChild, ["then", ";then"]),
2032
+ Loop: foldBlock((node) => node.firstChild, ["LoopEnd"]),
2033
+ "Quotation Array Map": foldInside,
2034
+ BlockComment: (node) => ({ from: node.from + 2, to: node.to - 2 }),
2035
+ }),
2036
+ styleTags({
2037
+ LineComment: tags.lineComment,
2038
+ BlockComment: tags.blockComment,
2039
+ StackEffect: tags.docComment,
2040
+ Number: tags.number,
2041
+ String: tags.string,
2042
+ Regex: tags.regexp,
2043
+ Character: tags.character,
2044
+ Boolean: tags.bool,
2045
+ Null: tags.null,
2046
+ DefName: tags.definition(tags.function(tags.variableName)),
2047
+ VariableName: tags.definition(tags.variableName),
2048
+ "NamespaceName ModulePath Namespace": tags.namespace,
2049
+ "Word WordName": tags.function(tags.variableName),
2050
+ 'if else then ";then" repeat LoopEnd Keyword': tags.controlKeyword,
2051
+ '":" ";" DefinitionKeyword': tags.definitionKeyword,
2052
+ '"ns:" "with:" ";with" needs': tags.moduleKeyword,
2053
+ "'": tags.operator,
2054
+ "( )": tags.paren,
2055
+ "[ ]": tags.squareBracket,
2056
+ "{ }": tags.brace,
2057
+ ", MapColon": tags.separator,
2058
+ }),
2059
+ ],
2060
+ }),
2061
+ languageData: {
2062
+ commentTokens: { line: "\\", block: { open: "(*", close: "*)" } },
2063
+ closeBrackets: { brackets: ["(", "[", "{", '"'] },
2064
+ indentOnInput: /^\s*(;|else|then|;then|again|while!?|until!?|\)|\]|\})$/,
2065
+ },
2066
+ });
2067
+ /// 8th language support, with completion for 8th's words by namespace,
2068
+ /// snippets, and the words and variables defined in the file.
2069
+ function eighth() {
2070
+ return new LanguageSupport(eighthLanguage, [
2071
+ eighthLanguage.data.of({ autocomplete: builtinCompletionSource }),
2072
+ eighthLanguage.data.of({ autocomplete: localCompletionSource }),
2073
+ ]);
2074
+ }
2075
+
2076
+ export { builtinCompletionSource, eighth, eighthLanguage, localCompletionSource, namespaces, parser, snippets };