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