@exercism/codemirror-lang-lisp 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/CHANGELOG.md +94 -0
- package/LICENSE +21 -0
- package/README.md +324 -2
- package/dist/index.cjs +1883 -0
- package/dist/index.d.cts +123 -0
- package/dist/index.d.ts +123 -0
- package/dist/index.js +1861 -0
- package/package.json +57 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,1861 @@
|
|
|
1
|
+
import { ExternalTokenizer, LRParser } from '@lezer/lr';
|
|
2
|
+
import { syntaxTree, LRLanguage, indentNodeProp, foldNodeProp, foldInside, LanguageSupport } from '@codemirror/language';
|
|
3
|
+
import { styleTags, tags } from '@lezer/highlight';
|
|
4
|
+
import { completeFromList, snippetCompletion } from '@codemirror/autocomplete';
|
|
5
|
+
|
|
6
|
+
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
7
|
+
const Comment = 1,
|
|
8
|
+
Number = 2,
|
|
9
|
+
Boolean = 3,
|
|
10
|
+
questionChar = 59,
|
|
11
|
+
lfeClauseBinder = 60,
|
|
12
|
+
lfeClauseFunctionBinder = 61,
|
|
13
|
+
lfeDefiner = 62,
|
|
14
|
+
lfeSpecialForm = 63,
|
|
15
|
+
symbolName = 69,
|
|
16
|
+
Dialect_lfe = 0;
|
|
17
|
+
|
|
18
|
+
const semicolon = 59, hash = 35, pipe = 124, newline = 10, question = 63, backslash = 92;
|
|
19
|
+
// Both comment forms come from here, and they come from the same tokenizer for
|
|
20
|
+
// the reason Lua's do: `#|` has to be recognised before `#` can be read as the
|
|
21
|
+
// start of anything else, and a rule that ran second would already have lost.
|
|
22
|
+
//
|
|
23
|
+
// `#| |#` nests, in Common Lisp and in every Scheme since R6RS, so its closer
|
|
24
|
+
// has to be matched against a depth counter rather than against a pattern. A
|
|
25
|
+
// regular expression would end the comment at the first `|#` and leave the tail
|
|
26
|
+
// of an outer comment to be parsed as code.
|
|
27
|
+
//
|
|
28
|
+
// An unterminated comment runs to the end of the file rather than being
|
|
29
|
+
// rejected, which is what one looks like while its opener is being typed.
|
|
30
|
+
const comments = /*@__PURE__*/new ExternalTokenizer((input) => {
|
|
31
|
+
if (input.next == semicolon) {
|
|
32
|
+
for (;;) {
|
|
33
|
+
const ch = input.next;
|
|
34
|
+
if (ch == newline || ch < 0)
|
|
35
|
+
break;
|
|
36
|
+
input.advance();
|
|
37
|
+
}
|
|
38
|
+
input.acceptToken(Comment);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (input.next != hash || input.peek(1) != pipe)
|
|
42
|
+
return;
|
|
43
|
+
let depth = 0;
|
|
44
|
+
for (;;) {
|
|
45
|
+
const ch = input.next;
|
|
46
|
+
if (ch < 0)
|
|
47
|
+
break;
|
|
48
|
+
if (ch == hash && input.peek(1) == pipe) {
|
|
49
|
+
depth++;
|
|
50
|
+
input.advance(2);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (ch == pipe && input.peek(1) == hash) {
|
|
54
|
+
depth--;
|
|
55
|
+
input.advance(2);
|
|
56
|
+
if (depth == 0)
|
|
57
|
+
break;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
input.advance();
|
|
61
|
+
}
|
|
62
|
+
input.acceptToken(Comment);
|
|
63
|
+
});
|
|
64
|
+
// The characters that end a symbol, as `symbolChar` in the grammar says.
|
|
65
|
+
function endsSymbol(ch) {
|
|
66
|
+
return ch < 0 || " \t\r\n\f()[]{}\"';`,".includes(String.fromCharCode(ch));
|
|
67
|
+
}
|
|
68
|
+
// After a bare `?` these are not read as a character, because `?` is an
|
|
69
|
+
// ordinary symbol in other dialects and `(list ?)` must still close its list.
|
|
70
|
+
// Emacs Lisp style escapes them anyway (`?\(`). Braces are allowed, since
|
|
71
|
+
// Emacs Lisp code writes `?{` bare.
|
|
72
|
+
function refusedAfterQuestion(ch) {
|
|
73
|
+
return " \t\r\n\f()[]\";".includes(String.fromCharCode(ch));
|
|
74
|
+
}
|
|
75
|
+
// Integers, ratios, decimals, and the radix and exactness prefixes. `1+` is
|
|
76
|
+
// not a number, because the whole run of symbol characters has to match.
|
|
77
|
+
const exponent = "(?:[eEdDsSfFlL][+-]?\\d+)?";
|
|
78
|
+
const numberPattern = /*@__PURE__*/new RegExp(`^(?:[+-]?(?:\\d+(?:/\\d+)?${exponent}|\\d+\\.\\d*${exponent}|\\.\\d+${exponent})` +
|
|
79
|
+
`|#[xX][+-]?[0-9a-fA-F]+|#[bB][+-]?[01]+|#[oO][+-]?[0-7]+|#[dD][+-]?\\d+` +
|
|
80
|
+
`|#[eEiI][+-]?\\d+(?:\\.\\d*)?${exponent})$`);
|
|
81
|
+
// `#t` and `#f`, and Racket's longer `#true` and `#false`.
|
|
82
|
+
const booleanPattern = /^#(?:[tT](?:rue)?|[fF](?:alse)?)$/;
|
|
83
|
+
// Reads an Emacs Lisp character after its `?`: `?a`, `?\s`, `?\(`, `?\C-a`
|
|
84
|
+
// and `?\^M`. Returns the length after the `?`, or -1 when there is none.
|
|
85
|
+
function characterLength(input) {
|
|
86
|
+
let i = 1;
|
|
87
|
+
const next = () => {
|
|
88
|
+
const ch = input.peek(i);
|
|
89
|
+
// A character outside the Basic Multilingual Plane takes two code units.
|
|
90
|
+
i += ch >= 0xd800 && ch < 0xdc00 ? 2 : 1;
|
|
91
|
+
};
|
|
92
|
+
const first = input.peek(i);
|
|
93
|
+
if (first < 0 || refusedAfterQuestion(first))
|
|
94
|
+
return -1;
|
|
95
|
+
if (first != backslash) {
|
|
96
|
+
next();
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
// An escape, then the rest of a name such as `?\C-a` or `?\M-\C-x`.
|
|
100
|
+
do {
|
|
101
|
+
if (input.peek(i) == backslash) {
|
|
102
|
+
i++;
|
|
103
|
+
if (input.peek(i) < 0 || input.peek(i) == newline)
|
|
104
|
+
return -1;
|
|
105
|
+
}
|
|
106
|
+
next();
|
|
107
|
+
} while (!endsSymbol(input.peek(i)));
|
|
108
|
+
}
|
|
109
|
+
return endsSymbol(input.peek(i)) ? i : -1;
|
|
110
|
+
}
|
|
111
|
+
const atoms = /*@__PURE__*/new ExternalTokenizer((input) => {
|
|
112
|
+
if (input.next == question) {
|
|
113
|
+
const length = characterLength(input);
|
|
114
|
+
if (length > 0)
|
|
115
|
+
input.acceptToken(questionChar, length);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
let word = "";
|
|
119
|
+
for (let i = 0; !endsSymbol(input.peek(i)) && word.length < 64; i++)
|
|
120
|
+
word += String.fromCharCode(input.peek(i));
|
|
121
|
+
if (!word || word.length >= 64)
|
|
122
|
+
return;
|
|
123
|
+
if (numberPattern.test(word))
|
|
124
|
+
input.acceptToken(Number, word.length);
|
|
125
|
+
else if (booleanPattern.test(word))
|
|
126
|
+
input.acceptToken(Boolean, word.length);
|
|
127
|
+
});
|
|
128
|
+
// The words the `lfe` dialect reads differently. `defun` and `flet` move here
|
|
129
|
+
// from their Common Lisp kinds, because in LFE they may be written as clauses.
|
|
130
|
+
const lfeTable = /*@__PURE__*/Object.create(null);
|
|
131
|
+
for (const word of ["defun", "defmacro", "match-lambda"])
|
|
132
|
+
lfeTable[word] = lfeClauseBinder;
|
|
133
|
+
for (const word of ["flet", "flet*", "fletrec"])
|
|
134
|
+
lfeTable[word] = lfeClauseFunctionBinder;
|
|
135
|
+
for (const word of ["defmodule", "defrecord"])
|
|
136
|
+
lfeTable[word] = lfeDefiner;
|
|
137
|
+
// Special forms of the other dialects that LFE doesn't have. In LFE they are
|
|
138
|
+
// ordinary names, and `loop` in particular is the usual name for a local
|
|
139
|
+
// function in `fletrec`.
|
|
140
|
+
const otherDialects = "define define-syntax define-values define-record-type define-structure while loop for " +
|
|
141
|
+
"begin prog1 prog2 setq setf set! block return return-from unwind-protect syntax-rules " +
|
|
142
|
+
"syntax-case require provide module struct match parameterize eval-when in-package " +
|
|
143
|
+
"declaim declare handler-case delay force pcase pcase-exhaustive cl-case cl-ecase " +
|
|
144
|
+
"cl-typecase cl-etypecase cl-loop cl-block cl-return cl-return-from condition-case " +
|
|
145
|
+
"save-excursion save-restriction save-match-data with-temp-buffer with-current-buffer interactive";
|
|
146
|
+
for (const word of /*@__PURE__*/otherDialects.split(" "))
|
|
147
|
+
lfeTable[word] = symbolName;
|
|
148
|
+
for (const word of ["receive", "after", "try", "lc", "list-comp", "bc", "binary-comp", "fun"])
|
|
149
|
+
lfeTable[word] = lfeSpecialForm;
|
|
150
|
+
function lfeWords(value, stack) {
|
|
151
|
+
var _a;
|
|
152
|
+
if (!stack.dialectEnabled(Dialect_lfe))
|
|
153
|
+
return -1;
|
|
154
|
+
return (_a = lfeTable[value]) !== null && _a !== void 0 ? _a : -1;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
|
158
|
+
const spec_symbolName = {__proto__:null,lambda:140, "lambda*":140, defun:140, defmacro:140, defgeneric:140, defmethod:140, let:140, "let*":140, letrec:140, "letrec*":140, "let-values":140, "let*-values":140, do:140, "do*":140, "with-slots":140, "multiple-value-bind":140, "destructuring-bind":140, defsubst:140, "named-let":140, "if-let":140, "if-let*":140, "when-let":140, "when-let*":140, "and-let*":140, "pcase-let":140, "pcase-let*":140, "cl-defun":140, "cl-defmacro":140, "cl-defsubst":140, "cl-defgeneric":140, "cl-defmethod":140, "cl-multiple-value-bind":140, "cl-destructuring-bind":140, "seq-let":140, ".":150, "&optional":152, "&rest":152, "&key":152, "&body":152, "&aux":152, "&allow-other-keys":152, "&whole":152, "&environment":152, define:154, "define-syntax":154, "define-values":154, "define-record-type":154, "define-structure":154, if:154, cond:154, case:154, when:154, unless:154, while:154, loop:154, for:154, begin:154, progn:154, prog1:154, prog2:154, setq:154, setf:154, "set!":154, quote:154, quasiquote:154, unquote:154, block:154, return:154, "return-from":154, catch:154, throw:154, "unwind-protect":154, "syntax-rules":154, "syntax-case":154, require:154, provide:154, module:154, struct:154, match:154, parameterize:154, "eval-when":154, "in-package":154, declaim:154, declare:154, "handler-case":154, delay:154, force:154, pcase:154, "pcase-exhaustive":154, "cl-case":154, "cl-ecase":154, "cl-typecase":154, "cl-etypecase":154, "cl-loop":154, "cl-block":154, "cl-return":154, "cl-return-from":154, "condition-case":154, "save-excursion":154, "save-restriction":154, "save-match-data":154, "with-temp-buffer":154, "with-current-buffer":154, interactive:154, dolist:156, dotimes:156, "do-symbols":156, "do-external-symbols":156, "do-all-symbols":156, "with-open-file":156, "with-open-stream":156, "with-input-from-string":156, "with-output-to-string":156, "with-hash-table-iterator":156, "with-package-iterator":156, "cl-dolist":156, "cl-dotimes":156, "seq-doseq":156, flet:158, labels:158, macrolet:158, "cl-flet":158, "cl-flet*":158, "cl-labels":158, "cl-macrolet":158, defvar:160, defparameter:160, defconstant:160, defstruct:160, defclass:160, deftype:160, "define-condition":160, defsetf:160, "define-modify-macro":160, defconst:160, defcustom:160, "defvar-local":160, defgroup:160, defface:160, "cl-defstruct":160, "define-minor-mode":160, "define-derived-mode":160};
|
|
159
|
+
const parser = /*@__PURE__*/LRParser.deserialize({
|
|
160
|
+
version: 14,
|
|
161
|
+
states: "5rQYQVOOOOQR'#Cc'#CcO!jQVO'#CiOOQR'#Co'#CoOOQR'#Cq'#CqOOQR'#Cr'#CrOOQR'#Cs'#CsOOQR'#Dw'#DwO!jQVO'#CtO#wQVO'#CvO$OQVO'#CzO!jQVO'#C{O%dQVO'#CaO&QQVO'#D^OOQR'#Dr'#DrOOQR'#D_'#D_OOQR'#Dq'#DqOOQR'#Dp'#DpOOQR'#D`'#D`QYQVOOOOQR,59T,59TOOQR,59`,59`OOQR,59b,59bO&XQVO,59bOOQR,59f,59fO&`QVO,59fO!jQVO,59gOOQR'#C}'#C}OOQR'#DP'#DPOOQR'#DS'#DSOOQP'#DT'#DTOOQR'#DY'#DYOOQR'#DZ'#DZOOQR'#EQ'#EQO'tQVO,58{O)`QVO,58{O)gQVO,58{O)nQVO,58{O)xQTO,58{O*ZQVO,58{OOQR,58{,58{O*bQVO,58{OOQR,59x,59xO*iQVO,59xOOQR-E7^-E7^OOQR1G.|1G.|OOQR1G/Q1G/QOOQR1G/R1G/ROOQR'#Cd'#CdO*pQVO1G.gOOQR'#Da'#DaO,[QVO'#CfO,cQVO'#CfOOQR1G.g1G.gO,jQVO1G.gO,jQVO1G.gO*pQVO1G.gO,qQTO'#DOO,vQTO'#DQO-RQTO'#DUO-dQTO'#DVOOQP'#De'#DeO-lQTO1G.gO-lQTO1G.gO-wQTO1G.gO.VQTO'#D[OOQR1G/d1G/dOOQR-E7_-E7_OOQR7+$R7+$RO.bQVO7+$RO.bQVO7+$ROOQR'#Ch'#ChO.iQVO'#CgO.sQVO'#CgOOQR'#Du'#DuOOQR'#Db'#DbO.}QVO,59QOOQR,59Q,59QO/UQVO,59QO/]QVO7+$RO/gQVO,59jO,qQTO'#DROOQP'#Dc'#DcO/nQTO,59lOOQR,59l,59lOOQP'#Dd'#DdO/yQTO,59pOOQR,59p,59pO1]QVO'#DWO1dQVO'#DWO1kQVO,59qO1rQVO,59qO-dQTO'#DVOOQP-E7c-E7cO1yQTO7+$RO1yQTO7+$RO,qQTO'#D]OOQP'#Dg'#DgO2UQTO,59vOOQR,59v,59vOOQR<<Gm<<GmO2aQVO<<GmOOQR'#Dv'#DvOOQR,59R,59RO2hQVO,59RO2oQVO,59ROOQR-E7`-E7`OOQR1G.l1G.lO2aQVO<<GmOOQR1G/U1G/UO2vQVO1G/UO4XQVO,59mOOQP-E7a-E7aOOQR1G/W1G/WOOQP-E7b-E7bOOQR1G/[1G/[O4fQTO'#DXO4nQVO'#DXOOQR'#EP'#EPOOQR'#Df'#DfO4uQVO,59rOOQR,59r,59rO4|QVO,59rOOQP1G/]1G/]O5TQVO1G/]O5[QVO1G/]O5cQTO<<GmO5nQTO,59wOOQP-E7e-E7eOOQR1G/b1G/bOOQRAN=XAN=XOOQR1G.m1G.mO5yQVO1G.mO6QQVO1G.mO6XQVOAN=XOOQR7+$p7+$pOOQP1G/X1G/XO6`QVO1G/XO6`QVO1G/XOOQR,59s,59sO6gQVO,59sO6nQVO,59sOOQR-E7d-E7dOOQR1G/^1G/^OOQP7+$w7+$wO6uQTO1G/cO7QQVO1G/cOOQP1G/c1G/cOOQR7+$X7+$XOOQRG22sG22sOOQP7+$s7+$sO7XQVO7+$sOOQR1G/_1G/_O7`QVO1G/_OOQP7+$}7+$}O7gQVO7+$}OOQP<<H_<<H_OOQR7+$y7+$yOOQP<<Hi<<Hi",
|
|
162
|
+
stateData: "7x~O!cOSPOS~OQVORVOU[OXVO^QO`]ObVOdVOiWOkXOmYOpZO!]RO!aUO!g_O!hPO!lRO!mSO!nTO!oUO~OQVORVOU[OXVO`]ObVOdVOiWOkXOmYOpZO!]RO!aUO!g_O!hPO!lRO!mSO!nTO!oUO~O_fO~PYOlhO~PYOQVORVOU[OXVO^QO`]ObVOdVOiWOkXOmYOpZO!]RO!aUO!hPO!lRO!mSO!nTO!oUO~O_xO!^nO!_pO!`mO!goO!pkO!qlO!rmO~P$VOazO~PYO_}O~PYOl!OO~PYOQVORVOU!TOX!SO^QO`!UObVOdVOiWOkXOmYOpZO!]RO!aUO!hPO!lRO!mSO!nTO!oUO~O_!VO!g!QO~P&gOQVORVOXVO^QO_!VO`]ObVOdVOiWOkXOmYOpZO!]RO!aUO!g_O!hPO!lRO!mSO!nTO!oUO~OU!ZO~P(OOU![O~P(OO_!VO!g!QO~P$VOU!]O_!VO`!^Ob!aO!g!QO~OU!cO~P(OO_!VO~PYOa!dO~PYO_!fO!g_O~P&gOQVORVOU!jOXVO^QO`!kObVOdVOiWOkXOmYOpZO!]RO!aUO!g!iO!hPO!lRO!mSO!nTO!oUO~O_!oO~P*zOa!oO~P*zO_!fO~PYO!g!iO~OU!sO^QO_!vO~OU!zO^QO_!yO`!{O!g!iO~OU!zO`!{O~OU#OO_!fO`!^O~OU!]O_!fO`!^Ob#RO~OU#SO^QO_#VO~O_#WO~PYO_#ZO!g!iO~P$VOa#ZO!g!iO~P$VO_#_O~P*zOa#_O~P*zO_#WO!g_O~P&gO_#aO~PYOU!sO^QO_#eO~O^QO_#gO!g!iO~OQVORVOU#hOXVO^QO`#iObVOdVOiWOkXO!]RO!aUO!g!iO!lRO!mSO!nTO!oUO~O_#mO~P0UOa#mO~P0UO_#oO~PYOa#oO~PYOU#OO_#WO`!^O~OU#SO^QO_#uO~O_#vO~PYO_#wO~PYOa#wO~PYO_#{O~PYOQVORVOXVO^QObVOdVOiWOkXOmYOpZO!]RO!aUO!g_O!hPO!lRO!mSO!nTO!oUO~OU!TO_#|O`!UO~P2}O_$PO!goO~Oa$PO~P0UO_$TO~P0UOa$TO~P0UO_$UO~PYOa$UO~PYOU#OO_#vO`!^O~OU!]O_$XO`!^O~O_$YO~PYOa$YO~PYO_$ZO~PYO_$[O~PYO_$^O~P0UOa$^O~P0UOU#OO_$`O`!^O~O_$`O~PYO_$bO~PYO_$cO~P0UO_$dO~PYOd^!lkipX!gi~",
|
|
163
|
+
goto: "5i!uPPPPP!vP#y%WP%a%n%t&gPPPPP(WP(W(W(W)gP)gPPP*z*zP,T,W,Z,^,a,e,h,k,t-P'|-W-^-a-d!v-h.h0U0`0j0p0v1Z1mPPPPPPPP1s2o3wPP5O5U)gPPPPPPP5[5f#R^OQWXYZ[]cgijrstuwy{!R!W!X!Y!g!h!j!k!q!r!|!}#X#[#]#`#b#c#p#q#x#y#z#}$O$W$]$a!z`OQWXYZ]cgijrstuwy{!R!W!X!Y!g!h!q!r!|!}#X#[#]#`#b#c#p#q#x#y#z#}$O$W$]$aQr[W!l!T!U!n!pT#Y!j!kQ!XuQ!YrR!bvQ!XrS!h!R!YQ#`!qR$O#cX!l!T!U!n!pW!l!T!U!n!pQ!r!ZS!w!]!xS#Y!j!kQ#c!s`#j!z!{#i#l#n$Q$R$_R#s#S!raOXY]cgirstuwy{!R!W!X!Y!g!h!q!r!|!}#X#[#]#`#b#c#p#q#x#y#z#}$O$W$]$aQq[W!l!T!U!n!pS!t![!uS!w!]!xS#T!c#US#Y!j!ka#j!z!{#i#l#n$Q$R$_#kVOQWXYZ[]cgijrstuwy{!R!T!U!W!X!Y!g!h!j!k!n!p!q!r!z!{!|!}#X#[#]#`#b#c#i#l#n#p#q#x#y#z#}$O$Q$R$W$]$_$a#Q^OQWXYZ[]cgijrstuwy{!R!W!X!Y!g!h!j!k!q!r!|!}#X#[#]#`#b#c#p#q#x#y#z#}$O$W$]$aW!l!T!U!n!pa#j!z!{#i#l#n$Q$R$_#Q^OQWXYZ[]cgijrstuwy{!R!W!X!Y!g!h!j!k!q!r!|!}#X#[#]#`#b#c#p#q#x#y#z#}$O$W$]$aX!l!T!U!n!pRs[R!XsRt[R!XtT!t![!uRu[Rv[Q!XvQ!h!bR$W#sc!_v!`!a!b#Q#R#r#s$VS!|!]#OR!}!^Qq[R$Q#hRw[R!XwT#T!c#U!{`OQWXYZ]cgijrstuwy{!R!W!X!Y!g!h!q!r!|!}#X#[#]#`#b#c#p#q#x#y#z#}$O$W$]$aQcOQgXQiYQ{]p|cgi{!W!g#X#b#p#q#x#y#z#}$]$a[!WrstuwyU!g!R!X!YS#X!h!qQ#b!rQ#p!|Q#q!}Q#x#[Q#y#]Q#z#`Q#}#cQ$]$OR$a$WQ!RrS!e!R!qR!q!YQ!n!TQ!p!UT#^!n!pQ!u![R#d!uQ!x!]R#f!xQ!`vW#P!`#Q#r$VS#Q!a!bQ#r#RR$V#sQ#l!zQ#n!{Q$R#iW$S#l#n$R$_R$_$QQ#U!cR#t#U!sbOXY]cgirstuwy{!R!W!X!Y!g!h!q!r!|!}#X#[#]#`#b#c#p#q#x#y#z#}$O$W$]$a!raOXY]cgirstuwy{!R!W!X!Y!g!h!q!r!|!}#X#[#]#`#b#c#p#q#x#y#z#}$O$W$]$aQdQQeWQjZR!Pj!z`OQWXYZ]cgijrstuwy{!R!W!X!Y!g!h!q!r!|!}#X#[#]#`#b#c#p#q#x#y#z#}$O$W$]$aQq[T#Y!j!kX!m!T!U!n!pQ#[!jR#]!ka#k!z!{#i#l#n$Q$R$_Ry[",
|
|
164
|
+
nodeNames: "⚠ Comment Number Boolean Program List ( Binder Definition Keyword Bindings BoundList LocalName DatumComment DatumCommentMark ) [ ] String Char LangLine Dot LambdaKeyword SpecialForm Quoted QuoteMark Vector VectorOpen } { Braces ReaderConditional ReaderCondMark IterationBinder IterationBindings FunctionBinder FunctionBindings FunctionBinding Definer Binder Bindings Clause Patterns PatternList Callee FunctionBinder FunctionBindings FunctionBinding Brackets Symbol",
|
|
165
|
+
maxTerm: 82,
|
|
166
|
+
nodeProps: [
|
|
167
|
+
["closedBy", 6,")",16,"]",29,"}"],
|
|
168
|
+
["openedBy", 15,"(",17,"[",28,"{"]
|
|
169
|
+
],
|
|
170
|
+
skippedNodes: [0,1],
|
|
171
|
+
repeatNodeCount: 8,
|
|
172
|
+
tokenData: "=w~RpOX#VXY$aYZ$aZ[#V[]$a]^$a^p#Vpq$aqr#Vrs$ust&ctw#Vwx)Oxy:dyz:iz|#V|}*`}![#V![!]-S!^!}#V!}#O:n#O#P#V#P#Q:s#Q#S#V#S#T)O#T#o#V#o#p:x#p#q:}#q#r=r#r;'S#V;'S;=`$Z<%lO#V~#[_!g~OX#VZ[#V^p#Vqr#Vsw#Vz|#V}!]#V!^!}#V#O#P#V#Q#S#V#T#o#V#p#q#V#r;'S#V;'S;=`$Z<%lO#V~$^P;=`<%l#V~$fT!c~XY$aYZ$a[]$a]^$apq$a~$xVOr$urs%_s#O$u#O#P%d#P;'S$u;'S;=`&]<%lO$u~%dOb~~%gRO;'S$u;'S;=`%p;=`O$u~%sWOr$urs%_s#O$u#O#P%d#P;'S$u;'S;=`&];=`<%l$u<%lO$u~&`P;=`<%l$u~&hv!g~OX#VZ[#V^p#Vqr#Vsw#Vwx)Oxy)Tz{#V{|)Y|}*`}!O)Y!O!Q#V!Q![*h![!]-S!]!^/d!^!c#V!c!d+{!d!e+{!e!o#V!o!p+{!p!u#V!u!v+{!v!}#V#O#P/i#Q#S#V#S#T)O#T#U+{#U#V+{#V#`#V#`#a4^#a#b+{#b#g#V#g#h+{#h#o#V#p#q#V#r;'S#V;'S;=`$Z<%lO#V~)TOi~~)YOk~~)a_p~!g~OX#VZ[#V^p#Vqr#Vsw#Vz|#V}!]#V!^!}#V#O#P#V#Q#S#V#T#o#V#p#q#V#r;'S#V;'S;=`$Z<%lO#V~*ePi~!b!c)O~*md!g~OX#VZ[#V^p#Vqr#Vsw#Vz|#V}!Q#V!Q![*h![!]#V!^!c#V!c!d+{!d!}#V#O#P#V#Q#S#V#T#U+{#U#o#V#p#q#V#r;'S#V;'S;=`$Z<%lO#V~,Q`!g~OX#VZ[#V^p#Vqr#Vsw#Vxy)Tz|#V}!]#V!^!}#V#O#P#V#Q#S#V#T#o#V#p#q#V#r;'S#V;'S;=`$Z<%lO#V~-X_!g~OX.WZ[.W^p.Wqr.Wsw.Wz|.W}!].W!^!}.W#O#P.W#Q#S.W#T#o.W#p#q.W#r;'S.W;'S;=`/^<%lO.W~.__X~!g~OX.WZ[.W^p.Wqr.Wsw.Wz|.W}!].W!^!}.W#O#P.W#Q#S.W#T#o.W#p#q.W#r;'S.W;'S;=`/^<%lO.W~/aP;=`<%l.W~/iO^~~/nn!g~OX1lXY2rZ[1l[^2r^p1lpq2rqr1lrs2rsw1lwz2rz|1l|}2r}!Q1l!Q![2w![!]1l!]!^2r!^!c1l!c!}2w!}#O2r#O#P1l#P#Q2r#Q#S1l#S#T2r#T#o2w#o#p2r#p#q1l#q#r2r#r;'S1l;'S;=`4W<%lO1l~1s_!l~!g~OX#VZ[#V^p#Vqr#Vsw#Vz|#V}!]#V!^!}#V#O#P#V#Q#S#V#T#o#V#p#q#V#r;'S#V;'S;=`$Z<%lO#V~2wO!l~~3Ob!l~!g~OX#VZ[#V^p#Vqr#Vsw#Vz|#V}!Q#V!Q![2w![!]#V!^!c#V!c!}2w#O#P#V#Q#S#V#T#o2w#p#q#V#r;'S#V;'S;=`$Z<%lO#V~4ZP;=`<%l1l~4c`!g~OX#VZ[#V^p#Vqr#Vsw#Vz|#V}!]#V!^!}#V#O#P#V#Q#S#V#T#U5e#U#o#V#p#q#V#r;'S#V;'S;=`$Z<%lO#V~5ja!g~OX#VZ[#V^p#Vqr#Vsw#Vz|#V}!]#V!^!}#V#O#P#V#Q#S#V#T#b#V#b#c6o#c#o#V#p#q#V#r;'S#V;'S;=`$Z<%lO#V~6ta!g~OX#VZ[#V^p#Vqr#Vsw#Vz|#V}!]#V!^!}#V#O#P#V#Q#S#V#T#Z#V#Z#[7y#[#o#V#p#q#V#r;'S#V;'S;=`$Z<%lO#V~8Qkd~!g~OX7yXY9uZ[7y[^9u^p7ypq9uqr7yrs9usw7ywz9uz|7y|}9u}!]7y!]!^9u!^!}7y!}#O9u#O#P7y#P#Q9u#Q#S7y#S#T9u#T#o7y#o#p9u#p#q7y#q#r9u#r;'S7y;'S;=`:^<%lO7y~9zSd~OY9uZ;'S9u;'S;=`:W<%lO9u~:ZP;=`<%l9u~:aP;=`<%l7y~:iOU~~:nO_~~:sO`~~:xOa~~:}Om~~;Si!g~OX:}XY<qZ[:}[^<q^p:}pq<qqr:}rs<qsw:}wx<qz|:}|}<q}!]:}!]!^<q!^!}:}#O#P:}#Q#S:}#S#T<q#T#o:}#o#p<q#p#q#V#q#r<q#r;'S:};'S;=`=l<%lO:}~<tXOY<qZx<qz!}<q#O#P<q#Q#p<q#p#q=a#q;'S<q;'S;=`=f<%lO<q~=fO!g~~=iP;=`<%l<q~=oP;=`<%l:}~=wOl~",
|
|
173
|
+
tokenizers: [comments, atoms, 0],
|
|
174
|
+
topRules: {"Program":[0,4]},
|
|
175
|
+
dialects: {lfe: 0},
|
|
176
|
+
specialized: [{term: 69, get: (value, stack) => (lfeWords(value, stack) << 1), external: lfeWords},{term: 69, get: (value) => spec_symbolName[value] || -1}],
|
|
177
|
+
tokenPrec: 1042
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Names declared in the file, found in the syntax tree. Nothing here is
|
|
181
|
+
// specific to one dialect, so every Lisp built on this grammar can use it.
|
|
182
|
+
/**
|
|
183
|
+
A symbol as it is typed. `#'` and `'` before it are not part of it, so
|
|
184
|
+
`#'ma` completes `ma`.
|
|
185
|
+
*/
|
|
186
|
+
const symbolBefore = /[^\s()\[\]{}"';`,#|]+$/;
|
|
187
|
+
const symbolPattern$1 = /^[^\s()\[\]{}"';`,#|]+$/;
|
|
188
|
+
// Nothing is offered while the cursor is in one of these. `Definition` and
|
|
189
|
+
// `LocalName` are new names being typed.
|
|
190
|
+
const dontComplete = /*@__PURE__*/new Set([
|
|
191
|
+
"String", "Comment", "Char", "Number", "Keyword", "Boolean", "LangLine",
|
|
192
|
+
"Definition", "LocalName", "DatumComment"
|
|
193
|
+
]);
|
|
194
|
+
/**
|
|
195
|
+
True when the cursor sits somewhere a symbol can be completed.
|
|
196
|
+
*/
|
|
197
|
+
function canComplete(context) {
|
|
198
|
+
for (let node = syntaxTree(context.state).resolveInner(context.pos, -1); node; node = node.parent) {
|
|
199
|
+
if (dontComplete.has(node.name))
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
The start of the symbol being typed, or null when nothing should be
|
|
206
|
+
offered. An explicit request (Ctrl-Space) on empty text offers everything.
|
|
207
|
+
*/
|
|
208
|
+
function wordStart(context) {
|
|
209
|
+
if (!canComplete(context))
|
|
210
|
+
return null;
|
|
211
|
+
const word = context.matchBefore(symbolBefore);
|
|
212
|
+
if (word)
|
|
213
|
+
return word.from;
|
|
214
|
+
return context.explicit ? context.pos : null;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
The completion type and detail for a name given by each defining form.
|
|
218
|
+
*/
|
|
219
|
+
const definitionTypes = {
|
|
220
|
+
defun: { type: "function" },
|
|
221
|
+
defgeneric: { type: "function", detail: "generic function" },
|
|
222
|
+
defmethod: { type: "function", detail: "method" },
|
|
223
|
+
defmacro: { type: "function", detail: "macro" },
|
|
224
|
+
defvar: { type: "variable" },
|
|
225
|
+
defparameter: { type: "variable" },
|
|
226
|
+
defconstant: { type: "constant" },
|
|
227
|
+
defstruct: { type: "class", detail: "structure" },
|
|
228
|
+
defclass: { type: "class" },
|
|
229
|
+
deftype: { type: "type" },
|
|
230
|
+
"define-condition": { type: "class", detail: "condition" },
|
|
231
|
+
defsetf: { type: "function" },
|
|
232
|
+
"define-modify-macro": { type: "function", detail: "macro" },
|
|
233
|
+
// Emacs Lisp
|
|
234
|
+
defsubst: { type: "function" },
|
|
235
|
+
"cl-defun": { type: "function" },
|
|
236
|
+
"cl-defsubst": { type: "function" },
|
|
237
|
+
"cl-defmacro": { type: "function", detail: "macro" },
|
|
238
|
+
"cl-defgeneric": { type: "function", detail: "generic function" },
|
|
239
|
+
"cl-defmethod": { type: "function", detail: "method" },
|
|
240
|
+
"named-let": { type: "function", detail: "named let" },
|
|
241
|
+
defconst: { type: "constant" },
|
|
242
|
+
defcustom: { type: "variable", detail: "user option" },
|
|
243
|
+
"defvar-local": { type: "variable" },
|
|
244
|
+
defgroup: { type: "constant", detail: "custom group" },
|
|
245
|
+
defface: { type: "constant", detail: "face" },
|
|
246
|
+
"cl-defstruct": { type: "class", detail: "structure" },
|
|
247
|
+
"define-minor-mode": { type: "function", detail: "minor mode" },
|
|
248
|
+
"define-derived-mode": { type: "function", detail: "major mode" },
|
|
249
|
+
// LFE
|
|
250
|
+
"match-lambda": { type: "function" },
|
|
251
|
+
defmodule: { type: "namespace", detail: "module" },
|
|
252
|
+
defrecord: { type: "class", detail: "record" }
|
|
253
|
+
};
|
|
254
|
+
// `Patterns` holds the patterns of an LFE clause, and the names in them are
|
|
255
|
+
// visible in that clause.
|
|
256
|
+
const bindingLists = /*@__PURE__*/new Set(["Bindings", "IterationBindings", "FunctionBindings", "Patterns"]);
|
|
257
|
+
/**
|
|
258
|
+
The text of a node.
|
|
259
|
+
*/
|
|
260
|
+
function text(state, node) {
|
|
261
|
+
return state.sliceDoc(node.from, node.to);
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
The form a local name is visible in: the whole form that binds it.
|
|
265
|
+
`(let ((x 1)) ...)` makes `x` visible in the `let`, and the parameters of
|
|
266
|
+
a local function in `flet` are visible in that function.
|
|
267
|
+
*/
|
|
268
|
+
function scopeOf(name) {
|
|
269
|
+
var _a, _b, _c;
|
|
270
|
+
if (((_a = name.parent) === null || _a === void 0 ? void 0 : _a.name) == "FunctionBinding")
|
|
271
|
+
return (_c = (_b = name.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) !== null && _c !== void 0 ? _c : null;
|
|
272
|
+
for (let node = name.parent; node; node = node.parent) {
|
|
273
|
+
if (bindingLists.has(node.name))
|
|
274
|
+
return node.parent;
|
|
275
|
+
}
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
function addOption(seen, option) {
|
|
279
|
+
// `_` matches anything in an LFE pattern and binds nothing.
|
|
280
|
+
if (!symbolPattern$1.test(option.label) || option.label.startsWith("&") || option.label == "_")
|
|
281
|
+
return;
|
|
282
|
+
if (!seen.has(option.label))
|
|
283
|
+
seen.set(option.label, option);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
Every name declared in the file that is visible at `pos`: names given by
|
|
287
|
+
`defun`, `defvar` and the like anywhere in the file, and names bound by
|
|
288
|
+
`let`, parameter lists and the other binding forms around `pos`. The name
|
|
289
|
+
under the cursor itself is left out.
|
|
290
|
+
*/
|
|
291
|
+
function declaredNames(state, pos) {
|
|
292
|
+
const seen = new Map();
|
|
293
|
+
syntaxTree(state).iterate({
|
|
294
|
+
enter: ref => {
|
|
295
|
+
var _a, _b;
|
|
296
|
+
if (ref.from <= pos && ref.to >= pos && (ref.name == "Definition" || ref.name == "LocalName"))
|
|
297
|
+
return;
|
|
298
|
+
if (ref.name == "Definition") {
|
|
299
|
+
const head = ref.node.prevSibling;
|
|
300
|
+
const kind = head ? text(state, head).toLowerCase() : "";
|
|
301
|
+
const info = (_a = definitionTypes[kind]) !== null && _a !== void 0 ? _a : { type: "variable" };
|
|
302
|
+
addOption(seen, Object.assign({ label: text(state, ref.node) }, info));
|
|
303
|
+
}
|
|
304
|
+
else if (ref.name == "LocalName") {
|
|
305
|
+
const scope = scopeOf(ref.node);
|
|
306
|
+
if (!scope || pos <= scope.from || pos >= scope.to)
|
|
307
|
+
return;
|
|
308
|
+
const type = ((_b = ref.node.parent) === null || _b === void 0 ? void 0 : _b.name) == "FunctionBinding" ? "function" : "variable";
|
|
309
|
+
addOption(seen, { label: text(state, ref.node), type, boost: 1 });
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
return seen;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
Completes the names declared in the file that are in scope at the cursor.
|
|
317
|
+
*/
|
|
318
|
+
function localCompletionSource(context) {
|
|
319
|
+
const from = wordStart(context);
|
|
320
|
+
if (from == null)
|
|
321
|
+
return null;
|
|
322
|
+
const options = [...declaredNames(context.state, context.pos).values()];
|
|
323
|
+
return { from, options, validFor: symbolPattern$1 };
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// The nodes that hold a sequence of forms, and so both fold and indent as one.
|
|
327
|
+
const lists = "List Brackets Braces Vector Bindings BoundList IterationBindings FunctionBindings FunctionBinding " +
|
|
328
|
+
"Clause Patterns PatternList";
|
|
329
|
+
const listNames = /*@__PURE__*/new Set(/*@__PURE__*/lists.split(" "));
|
|
330
|
+
const closesForm = /^\s*[)\]}]/;
|
|
331
|
+
// The heads after which a form's body indents one unit.
|
|
332
|
+
const bodyHeads = /*@__PURE__*/new Set(["SpecialForm", "Binder", "IterationBinder", "FunctionBinder", "Definer"]);
|
|
333
|
+
// Lisp indents two ways and the difference is what the form means, not how it
|
|
334
|
+
// is punctuated. A special form indents its body one unit past the opening
|
|
335
|
+
// bracket, because the body is subordinate to the head:
|
|
336
|
+
//
|
|
337
|
+
// (defun f (x)
|
|
338
|
+
// (g x))
|
|
339
|
+
//
|
|
340
|
+
// Everything else is an application, and its arguments line up under the first
|
|
341
|
+
// argument, so the reader can see the operands as a column:
|
|
342
|
+
//
|
|
343
|
+
// (mapcar #'car
|
|
344
|
+
// xs)
|
|
345
|
+
//
|
|
346
|
+
// A form whose head is itself a list is data rather than an application, and
|
|
347
|
+
// its elements line up under the first of them. That is what makes a binding
|
|
348
|
+
// list read as a table:
|
|
349
|
+
//
|
|
350
|
+
// (let ([x 1]
|
|
351
|
+
// [y 2])
|
|
352
|
+
//
|
|
353
|
+
// The alignment rules need something on the head's own line to align to. When
|
|
354
|
+
// there is nothing, the form falls back to the body indent.
|
|
355
|
+
function formIndent(context) {
|
|
356
|
+
// Indentation counts from the open bracket, so a form that starts partway
|
|
357
|
+
// along a line indents its body under itself.
|
|
358
|
+
const base = context.column(context.node.from);
|
|
359
|
+
if (closesForm.test(context.textAfter))
|
|
360
|
+
return base;
|
|
361
|
+
// A local function in `flet` or `labels` indents its body like `defun`.
|
|
362
|
+
if (context.node.name === "FunctionBinding")
|
|
363
|
+
return base + context.unit;
|
|
364
|
+
const open = context.node.firstChild;
|
|
365
|
+
const head = open === null || open === void 0 ? void 0 : open.nextSibling;
|
|
366
|
+
if (!head || bodyHeads.has(head.name))
|
|
367
|
+
return base + context.unit;
|
|
368
|
+
if (listNames.has(head.name))
|
|
369
|
+
return context.column(head.from);
|
|
370
|
+
const argument = head.nextSibling;
|
|
371
|
+
if (argument && context.lineAt(argument.from).from === context.lineAt(head.from).from)
|
|
372
|
+
return context.column(argument.from);
|
|
373
|
+
return base + context.unit;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
A language provider based on the Lezer Lisp parser in this package,
|
|
377
|
+
extended with highlighting and indentation information.
|
|
378
|
+
*/
|
|
379
|
+
const lispLanguage = /*@__PURE__*/LRLanguage.define({
|
|
380
|
+
name: "lisp",
|
|
381
|
+
parser: /*@__PURE__*/parser.configure({
|
|
382
|
+
props: [
|
|
383
|
+
/*@__PURE__*/indentNodeProp.add({
|
|
384
|
+
[lists]: formIndent
|
|
385
|
+
}),
|
|
386
|
+
/*@__PURE__*/foldNodeProp.add({
|
|
387
|
+
[lists]: foldInside
|
|
388
|
+
}),
|
|
389
|
+
/*@__PURE__*/styleTags({
|
|
390
|
+
SpecialForm: tags.keyword,
|
|
391
|
+
// A form that binds names. `definitionKeyword` sits under `keyword`, so
|
|
392
|
+
// a theme with nothing to say about the distinction still paints it as
|
|
393
|
+
// one, and a theme that does can tell `let` from `if`.
|
|
394
|
+
"Binder IterationBinder FunctionBinder Definer": tags.definitionKeyword,
|
|
395
|
+
// The name a binder gives: `f` in `(defun f (a b) ...)`.
|
|
396
|
+
Definition: /*@__PURE__*/tags.definition(tags.variableName),
|
|
397
|
+
// A name bound by a binding form, such as a parameter or a `let`
|
|
398
|
+
// variable.
|
|
399
|
+
LocalName: /*@__PURE__*/tags.local(/*@__PURE__*/tags.definition(tags.variableName)),
|
|
400
|
+
// `&optional`, `&key` and the other markers in a parameter list.
|
|
401
|
+
LambdaKeyword: tags.modifier,
|
|
402
|
+
// The head of a list is what the list applies. A theme paints a call
|
|
403
|
+
// differently from the names it is passed in every other language, and
|
|
404
|
+
// Lisp is the one where that matters most: it has no other way of
|
|
405
|
+
// saying which of the words in a form is the verb.
|
|
406
|
+
Callee: /*@__PURE__*/tags.function(tags.variableName),
|
|
407
|
+
Symbol: tags.variableName,
|
|
408
|
+
Keyword: tags.atom,
|
|
409
|
+
Boolean: tags.bool,
|
|
410
|
+
Number: tags.number,
|
|
411
|
+
String: tags.string,
|
|
412
|
+
Char: tags.character,
|
|
413
|
+
Comment: tags.comment,
|
|
414
|
+
"DatumComment/...": tags.comment,
|
|
415
|
+
LangLine: tags.meta,
|
|
416
|
+
QuoteMark: tags.meta,
|
|
417
|
+
ReaderCondMark: tags.meta,
|
|
418
|
+
Dot: tags.punctuation,
|
|
419
|
+
"( )": tags.paren,
|
|
420
|
+
"[ ]": tags.squareBracket,
|
|
421
|
+
"{ }": tags.brace,
|
|
422
|
+
VectorOpen: tags.paren
|
|
423
|
+
})
|
|
424
|
+
]
|
|
425
|
+
}),
|
|
426
|
+
languageData: {
|
|
427
|
+
commentTokens: { line: ";", block: { open: "#|", close: "|#" } },
|
|
428
|
+
closeBrackets: { brackets: ["(", "[", "{", '"'] },
|
|
429
|
+
indentOnInput: /^\s*[)\]}]$/
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
// The special forms the grammar promotes out of Symbol, offered back as
|
|
433
|
+
// completions. Spread across dialects on purpose: one editor serves Common
|
|
434
|
+
// Lisp, Scheme, Racket and Emacs Lisp here, and a name that means nothing in
|
|
435
|
+
// the dialect being typed is a wrong suggestion rather than a broken one.
|
|
436
|
+
const specialForms$1 = /*@__PURE__*/("defun defmacro defvar defparameter defconstant defstruct defclass defmethod defgeneric " +
|
|
437
|
+
"define define-syntax define-values define-record-type define-structure " +
|
|
438
|
+
"lambda let let* letrec letrec* let-values let*-values labels flet macrolet " +
|
|
439
|
+
"if cond case when unless while do dolist dotimes loop for " +
|
|
440
|
+
"begin progn prog1 prog2 setq setf set! " +
|
|
441
|
+
"quote quasiquote unquote lambda-case " +
|
|
442
|
+
"block return return-from catch throw unwind-protect " +
|
|
443
|
+
"multiple-value-bind destructuring-bind " +
|
|
444
|
+
"syntax-rules syntax-case require provide module struct match parameterize " +
|
|
445
|
+
"eval-when in-package declaim declare handler-case delay force")
|
|
446
|
+
.split(" ")
|
|
447
|
+
.map(label => ({ label, type: "keyword" }));
|
|
448
|
+
/**
|
|
449
|
+
Autocompletion for the special forms the grammar recognises.
|
|
450
|
+
*/
|
|
451
|
+
const lispCompletion = /*@__PURE__*/completeFromList(specialForms$1);
|
|
452
|
+
/**
|
|
453
|
+
Lisp language support, with completion for the special forms and for the
|
|
454
|
+
names declared in the file. Serves
|
|
455
|
+
Common Lisp, Scheme, Racket, Emacs Lisp and the smaller dialects that
|
|
456
|
+
share their reader.
|
|
457
|
+
*/
|
|
458
|
+
function lisp() {
|
|
459
|
+
return new LanguageSupport(lispLanguage, [
|
|
460
|
+
lispLanguage.data.of({ autocomplete: lispCompletion }),
|
|
461
|
+
lispLanguage.data.of({ autocomplete: localCompletionSource })
|
|
462
|
+
]);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Building blocks for the dialect entry points, such as `commonLisp()` and
|
|
466
|
+
// `emacsLisp()`. A new dialect gives its built-in names and snippets to
|
|
467
|
+
// `builtinSource`, picks the extra local names it needs from the helpers
|
|
468
|
+
// below, and wraps its sources with `dialectSupport`.
|
|
469
|
+
/**
|
|
470
|
+
The characters a completed symbol may contain.
|
|
471
|
+
*/
|
|
472
|
+
const symbolPattern = /^[^\s()\[\]{}"';`,#|]+$/;
|
|
473
|
+
/**
|
|
474
|
+
A completion source for a dialect's built-in names and its snippets.
|
|
475
|
+
*/
|
|
476
|
+
function builtinSource(options, snippets) {
|
|
477
|
+
const inParens = snippets.map(([label, detail, body]) => snippetCompletion(body, { label, detail, type: "keyword", boost: -1 }));
|
|
478
|
+
const withParens = snippets.map(([label, detail, body]) => snippetCompletion("(" + body + ")", { label, detail, type: "keyword", boost: -1 }));
|
|
479
|
+
const afterParen = options.concat(inParens), bare = options.concat(withParens);
|
|
480
|
+
return (context) => {
|
|
481
|
+
const from = wordStart(context);
|
|
482
|
+
if (from == null)
|
|
483
|
+
return null;
|
|
484
|
+
const open = context.state.sliceDoc(from - 1, from) == "(";
|
|
485
|
+
return { from, options: open ? afterParen : bare, validFor: symbolPattern };
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
A completion source for the names declared in the file that are in scope
|
|
490
|
+
at the cursor. `extra` may add the names a dialect's forms define without
|
|
491
|
+
the grammar marking them, such as the functions written by `defstruct`.
|
|
492
|
+
*/
|
|
493
|
+
function localsSource(extra) {
|
|
494
|
+
return (context) => {
|
|
495
|
+
const from = wordStart(context);
|
|
496
|
+
if (from == null)
|
|
497
|
+
return null;
|
|
498
|
+
const { state, pos } = context;
|
|
499
|
+
const seen = declaredNames(state, pos);
|
|
500
|
+
extra(state, pos, option => {
|
|
501
|
+
if (symbolPattern.test(option.label) && !seen.has(option.label))
|
|
502
|
+
seen.set(option.label, option);
|
|
503
|
+
});
|
|
504
|
+
return { from, options: [...seen.values()], validFor: symbolPattern };
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
Language support for a dialect: the shared grammar with the dialect's
|
|
509
|
+
completion sources. A dialect that reads some forms differently, such as
|
|
510
|
+
LFE, passes the language configured with its grammar dialect.
|
|
511
|
+
*/
|
|
512
|
+
function dialectSupport(sources, language = lispLanguage) {
|
|
513
|
+
return new LanguageSupport(language, sources.map(source => language.data.of({ autocomplete: source })));
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
The lower-case text of a node, or "" for none.
|
|
517
|
+
*/
|
|
518
|
+
function lower(state, node) {
|
|
519
|
+
return node ? text(state, node).toLowerCase() : "";
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
The parts of a list, without its brackets and comments.
|
|
523
|
+
*/
|
|
524
|
+
function partsOf(list) {
|
|
525
|
+
const parts = [];
|
|
526
|
+
for (let child = list.firstChild; child; child = child.nextSibling) {
|
|
527
|
+
if (!/^[()\[\]{}]$/.test(child.name) && child.name != "DatumComment")
|
|
528
|
+
parts.push(child);
|
|
529
|
+
}
|
|
530
|
+
return parts;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
The head of a list, the part after its open bracket.
|
|
534
|
+
*/
|
|
535
|
+
function headOf(list) {
|
|
536
|
+
var _a, _b;
|
|
537
|
+
return (_b = (_a = list.firstChild) === null || _a === void 0 ? void 0 : _a.nextSibling) !== null && _b !== void 0 ? _b : null;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
Every symbol inside a node, at any depth.
|
|
541
|
+
*/
|
|
542
|
+
function symbolsIn(state, node, out) {
|
|
543
|
+
if (node.name == "Symbol" || node.name == "Callee")
|
|
544
|
+
out.push(text(state, node));
|
|
545
|
+
for (let child = node.firstChild; child; child = child.nextSibling)
|
|
546
|
+
symbolsIn(state, child, out);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
The functions a structure definition writes, for Common Lisp's
|
|
550
|
+
`defstruct` and Emacs Lisp's `cl-defstruct`: `make-point`, `copy-point`,
|
|
551
|
+
`point-p` and an accessor for each slot, named with the `:conc-name` when
|
|
552
|
+
one is given.
|
|
553
|
+
*/
|
|
554
|
+
function structureNames(state, form, add) {
|
|
555
|
+
const parts = partsOf(form).slice(1);
|
|
556
|
+
if (!parts.length)
|
|
557
|
+
return;
|
|
558
|
+
let name = "", concName = null;
|
|
559
|
+
const head = parts[0];
|
|
560
|
+
if (head.name == "Definition") {
|
|
561
|
+
name = text(state, head);
|
|
562
|
+
}
|
|
563
|
+
else if (head.name == "List") {
|
|
564
|
+
const options = partsOf(head);
|
|
565
|
+
if (!options.length)
|
|
566
|
+
return;
|
|
567
|
+
name = text(state, options[0]);
|
|
568
|
+
for (const option of options.slice(1)) {
|
|
569
|
+
if (option.name != "List")
|
|
570
|
+
continue;
|
|
571
|
+
const [key, value] = partsOf(option);
|
|
572
|
+
if (lower(state, key) != ":conc-name")
|
|
573
|
+
continue;
|
|
574
|
+
concName = !value || lower(state, value) == "nil" ? "" : text(state, value).replace(/^#?:/, "");
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
const prefix = concName !== null && concName !== void 0 ? concName : name + "-";
|
|
581
|
+
add({ label: "make-" + name, type: "function", detail: "constructor" });
|
|
582
|
+
add({ label: "copy-" + name, type: "function" });
|
|
583
|
+
add({ label: name + "-p", type: "function" });
|
|
584
|
+
for (const slot of parts.slice(1)) {
|
|
585
|
+
const slotName = slot.name == "Symbol" ? slot : slot.name == "List" ? partsOf(slot)[0] : null;
|
|
586
|
+
if (slotName && (slotName.name == "Symbol" || slotName.name == "Callee"))
|
|
587
|
+
add({ label: prefix + text(state, slotName), type: "function", detail: "accessor" });
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
const loopBinders = /*@__PURE__*/new Set(["for", "with", "as"]);
|
|
591
|
+
/**
|
|
592
|
+
The variables a `loop` (or Emacs Lisp's `cl-loop`) binds with `for`, `as`
|
|
593
|
+
and `with`, which are visible in that loop.
|
|
594
|
+
*/
|
|
595
|
+
function loopNames(state, form, pos, add) {
|
|
596
|
+
if (pos <= form.from || pos >= form.to)
|
|
597
|
+
return;
|
|
598
|
+
const parts = partsOf(form);
|
|
599
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
600
|
+
if (!loopBinders.has(lower(state, parts[i])))
|
|
601
|
+
continue;
|
|
602
|
+
const bound = parts[i + 1];
|
|
603
|
+
if (bound.from <= pos && bound.to >= pos)
|
|
604
|
+
continue;
|
|
605
|
+
const names = [];
|
|
606
|
+
symbolsIn(state, bound, names);
|
|
607
|
+
for (const label of names)
|
|
608
|
+
add({ label, type: "variable", boost: 1 });
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
Calls `visit` with every list in the file and its lower-case head.
|
|
613
|
+
*/
|
|
614
|
+
function eachForm(state, visit) {
|
|
615
|
+
syntaxTree(state).iterate({
|
|
616
|
+
enter: ref => {
|
|
617
|
+
if (ref.name != "List")
|
|
618
|
+
return;
|
|
619
|
+
const head = headOf(ref.node);
|
|
620
|
+
if (head)
|
|
621
|
+
visit(ref.node, head, lower(state, head));
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
// The symbols exported by the COMMON-LISP package, grouped by what they name.
|
|
627
|
+
// SBCL wrote these lists with this script, run as
|
|
628
|
+
// `docker run --rm -v "$PWD":/w clfoundation/sbcl sbcl --script /w/dump.lisp`:
|
|
629
|
+
//
|
|
630
|
+
// (let (sp mac fun var con)
|
|
631
|
+
// (do-external-symbols (s :cl)
|
|
632
|
+
// (let ((n (string-downcase (symbol-name s))))
|
|
633
|
+
// (cond ((special-operator-p s) (push n sp))
|
|
634
|
+
// ((macro-function s) (push n mac))
|
|
635
|
+
// ((fboundp s) (push n fun)))
|
|
636
|
+
// (cond ((constantp s) (when (boundp s) (push n con)))
|
|
637
|
+
// ((boundp s) (push n var)))))
|
|
638
|
+
// (flet ((out (name l) (format t "~a ~{~a~^ ~}~%" name (sort l #'string<))))
|
|
639
|
+
// (out "special" sp) (out "macro" mac) (out "function" fun) (out "variable" var) (out "constant" con)))
|
|
640
|
+
const specialOperators = [
|
|
641
|
+
"block", "catch", "eval-when", "flet", "function", "go", "if", "labels",
|
|
642
|
+
"let", "let*", "load-time-value", "locally", "macrolet",
|
|
643
|
+
"multiple-value-call", "multiple-value-prog1", "progn", "progv", "quote",
|
|
644
|
+
"return-from", "setq", "symbol-macrolet", "tagbody", "the", "throw",
|
|
645
|
+
"unwind-protect"
|
|
646
|
+
];
|
|
647
|
+
const macros$2 = [
|
|
648
|
+
"and", "assert", "call-method", "case", "ccase", "check-type", "cond",
|
|
649
|
+
"ctypecase", "decf", "declaim", "defclass", "defconstant", "defgeneric",
|
|
650
|
+
"define-compiler-macro", "define-condition", "define-method-combination",
|
|
651
|
+
"define-modify-macro", "define-setf-expander", "define-symbol-macro",
|
|
652
|
+
"defmacro", "defmethod", "defpackage", "defparameter", "defsetf",
|
|
653
|
+
"defstruct", "deftype", "defun", "defvar", "destructuring-bind", "do", "do*",
|
|
654
|
+
"do-all-symbols", "do-external-symbols", "do-symbols", "dolist", "dotimes",
|
|
655
|
+
"ecase", "etypecase", "formatter", "handler-bind", "handler-case",
|
|
656
|
+
"ignore-errors", "in-package", "incf", "lambda", "loop", "loop-finish",
|
|
657
|
+
"multiple-value-bind", "multiple-value-list", "multiple-value-setq",
|
|
658
|
+
"nth-value", "or", "pop", "pprint-exit-if-list-exhausted",
|
|
659
|
+
"pprint-logical-block", "pprint-pop", "print-unreadable-object", "prog",
|
|
660
|
+
"prog*", "prog1", "prog2", "psetf", "psetq", "push", "pushnew", "remf",
|
|
661
|
+
"restart-bind", "restart-case", "return", "rotatef", "setf", "shiftf",
|
|
662
|
+
"step", "time", "trace", "typecase", "unless", "untrace", "when",
|
|
663
|
+
"with-accessors", "with-compilation-unit", "with-condition-restarts",
|
|
664
|
+
"with-hash-table-iterator", "with-input-from-string", "with-open-file",
|
|
665
|
+
"with-open-stream", "with-output-to-string", "with-package-iterator",
|
|
666
|
+
"with-simple-restart", "with-slots", "with-standard-io-syntax"
|
|
667
|
+
];
|
|
668
|
+
const functions$1 = [
|
|
669
|
+
"*", "+", "-", "/", "/=", "1+", "1-", "<", "<=", "=", ">", ">=", "abort",
|
|
670
|
+
"abs", "acons", "acos", "acosh", "add-method", "adjoin", "adjust-array",
|
|
671
|
+
"adjustable-array-p", "allocate-instance", "alpha-char-p", "alphanumericp",
|
|
672
|
+
"append", "apply", "apropos", "apropos-list", "aref",
|
|
673
|
+
"arithmetic-error-operands", "arithmetic-error-operation", "array-dimension",
|
|
674
|
+
"array-dimensions", "array-displacement", "array-element-type",
|
|
675
|
+
"array-has-fill-pointer-p", "array-in-bounds-p", "array-rank",
|
|
676
|
+
"array-row-major-index", "array-total-size", "arrayp", "ash", "asin",
|
|
677
|
+
"asinh", "assoc", "assoc-if", "assoc-if-not", "atan", "atanh", "atom", "bit",
|
|
678
|
+
"bit-and", "bit-andc1", "bit-andc2", "bit-eqv", "bit-ior", "bit-nand",
|
|
679
|
+
"bit-nor", "bit-not", "bit-orc1", "bit-orc2", "bit-vector-p", "bit-xor",
|
|
680
|
+
"boole", "both-case-p", "boundp", "break", "broadcast-stream-streams",
|
|
681
|
+
"butlast", "byte", "byte-position", "byte-size", "caaaar", "caaadr", "caaar",
|
|
682
|
+
"caadar", "caaddr", "caadr", "caar", "cadaar", "cadadr", "cadar", "caddar",
|
|
683
|
+
"cadddr", "caddr", "cadr", "car", "cdaaar", "cdaadr", "cdaar", "cdadar",
|
|
684
|
+
"cdaddr", "cdadr", "cdar", "cddaar", "cddadr", "cddar", "cdddar", "cddddr",
|
|
685
|
+
"cdddr", "cddr", "cdr", "ceiling", "cell-error-name", "cerror",
|
|
686
|
+
"change-class", "char", "char-code", "char-downcase", "char-equal",
|
|
687
|
+
"char-greaterp", "char-int", "char-lessp", "char-name", "char-not-equal",
|
|
688
|
+
"char-not-greaterp", "char-not-lessp", "char-upcase", "char/=", "char<",
|
|
689
|
+
"char<=", "char=", "char>", "char>=", "character", "characterp", "cis",
|
|
690
|
+
"class-name", "class-of", "clear-input", "clear-output", "close", "clrhash",
|
|
691
|
+
"code-char", "coerce", "compile", "compile-file", "compile-file-pathname",
|
|
692
|
+
"compiled-function-p", "compiler-macro-function", "complement", "complex",
|
|
693
|
+
"complexp", "compute-applicable-methods", "compute-restarts", "concatenate",
|
|
694
|
+
"concatenated-stream-streams", "conjugate", "cons", "consp", "constantly",
|
|
695
|
+
"constantp", "continue", "copy-alist", "copy-list", "copy-pprint-dispatch",
|
|
696
|
+
"copy-readtable", "copy-seq", "copy-structure", "copy-symbol", "copy-tree",
|
|
697
|
+
"cos", "cosh", "count", "count-if", "count-if-not", "decode-float",
|
|
698
|
+
"decode-universal-time", "delete", "delete-duplicates", "delete-file",
|
|
699
|
+
"delete-if", "delete-if-not", "delete-package", "denominator",
|
|
700
|
+
"deposit-field", "describe", "describe-object", "digit-char", "digit-char-p",
|
|
701
|
+
"directory", "directory-namestring", "disassemble", "documentation", "dpb",
|
|
702
|
+
"dribble", "echo-stream-input-stream", "echo-stream-output-stream", "ed",
|
|
703
|
+
"eighth", "elt", "encode-universal-time", "endp", "enough-namestring",
|
|
704
|
+
"ensure-directories-exist", "ensure-generic-function", "eq", "eql", "equal",
|
|
705
|
+
"equalp", "error", "eval", "evenp", "every", "exp", "export", "expt",
|
|
706
|
+
"fboundp", "fceiling", "fdefinition", "ffloor", "fifth", "file-author",
|
|
707
|
+
"file-error-pathname", "file-length", "file-namestring", "file-position",
|
|
708
|
+
"file-string-length", "file-write-date", "fill", "fill-pointer", "find",
|
|
709
|
+
"find-all-symbols", "find-class", "find-if", "find-if-not", "find-method",
|
|
710
|
+
"find-package", "find-restart", "find-symbol", "finish-output", "first",
|
|
711
|
+
"float", "float-digits", "float-precision", "float-radix", "float-sign",
|
|
712
|
+
"floatp", "floor", "fmakunbound", "force-output", "format", "fourth",
|
|
713
|
+
"fresh-line", "fround", "ftruncate", "funcall", "function-keywords",
|
|
714
|
+
"function-lambda-expression", "functionp", "gcd", "gensym", "gentemp", "get",
|
|
715
|
+
"get-decoded-time", "get-dispatch-macro-character", "get-internal-real-time",
|
|
716
|
+
"get-internal-run-time", "get-macro-character", "get-output-stream-string",
|
|
717
|
+
"get-properties", "get-setf-expansion", "get-universal-time", "getf",
|
|
718
|
+
"gethash", "graphic-char-p", "hash-table-count", "hash-table-p",
|
|
719
|
+
"hash-table-rehash-size", "hash-table-rehash-threshold", "hash-table-size",
|
|
720
|
+
"hash-table-test", "host-namestring", "identity", "imagpart", "import",
|
|
721
|
+
"initialize-instance", "input-stream-p", "inspect", "integer-decode-float",
|
|
722
|
+
"integer-length", "integerp", "interactive-stream-p", "intern",
|
|
723
|
+
"intersection", "invalid-method-error", "invoke-debugger", "invoke-restart",
|
|
724
|
+
"invoke-restart-interactively", "isqrt", "keywordp", "last", "lcm", "ldb",
|
|
725
|
+
"ldb-test", "ldiff", "length", "lisp-implementation-type",
|
|
726
|
+
"lisp-implementation-version", "list", "list*", "list-all-packages",
|
|
727
|
+
"list-length", "listen", "listp", "load",
|
|
728
|
+
"load-logical-pathname-translations", "log", "logand", "logandc1",
|
|
729
|
+
"logandc2", "logbitp", "logcount", "logeqv", "logical-pathname",
|
|
730
|
+
"logical-pathname-translations", "logior", "lognand", "lognor", "lognot",
|
|
731
|
+
"logorc1", "logorc2", "logtest", "logxor", "long-site-name", "lower-case-p",
|
|
732
|
+
"machine-instance", "machine-type", "machine-version", "macro-function",
|
|
733
|
+
"macroexpand", "macroexpand-1", "make-array", "make-broadcast-stream",
|
|
734
|
+
"make-concatenated-stream", "make-condition",
|
|
735
|
+
"make-dispatch-macro-character", "make-echo-stream", "make-hash-table",
|
|
736
|
+
"make-instance", "make-instances-obsolete", "make-list", "make-load-form",
|
|
737
|
+
"make-load-form-saving-slots", "make-package", "make-pathname",
|
|
738
|
+
"make-random-state", "make-sequence", "make-string",
|
|
739
|
+
"make-string-input-stream", "make-string-output-stream", "make-symbol",
|
|
740
|
+
"make-synonym-stream", "make-two-way-stream", "makunbound", "map",
|
|
741
|
+
"map-into", "mapc", "mapcan", "mapcar", "mapcon", "maphash", "mapl",
|
|
742
|
+
"maplist", "mask-field", "max", "member", "member-if", "member-if-not",
|
|
743
|
+
"merge", "merge-pathnames", "method-combination-error", "method-qualifiers",
|
|
744
|
+
"min", "minusp", "mismatch", "mod", "muffle-warning", "name-char",
|
|
745
|
+
"namestring", "nbutlast", "nconc", "nintersection", "ninth",
|
|
746
|
+
"no-applicable-method", "no-next-method", "not", "notany", "notevery",
|
|
747
|
+
"nreconc", "nreverse", "nset-difference", "nset-exclusive-or",
|
|
748
|
+
"nstring-capitalize", "nstring-downcase", "nstring-upcase", "nsublis",
|
|
749
|
+
"nsubst", "nsubst-if", "nsubst-if-not", "nsubstitute", "nsubstitute-if",
|
|
750
|
+
"nsubstitute-if-not", "nth", "nthcdr", "null", "numberp", "numerator",
|
|
751
|
+
"nunion", "oddp", "open", "open-stream-p", "output-stream-p",
|
|
752
|
+
"package-error-package", "package-name", "package-nicknames",
|
|
753
|
+
"package-shadowing-symbols", "package-use-list", "package-used-by-list",
|
|
754
|
+
"packagep", "pairlis", "parse-integer", "parse-namestring", "pathname",
|
|
755
|
+
"pathname-device", "pathname-directory", "pathname-host", "pathname-match-p",
|
|
756
|
+
"pathname-name", "pathname-type", "pathname-version", "pathnamep",
|
|
757
|
+
"peek-char", "phase", "plusp", "position", "position-if", "position-if-not",
|
|
758
|
+
"pprint", "pprint-dispatch", "pprint-fill", "pprint-indent", "pprint-linear",
|
|
759
|
+
"pprint-newline", "pprint-tab", "pprint-tabular", "prin1", "prin1-to-string",
|
|
760
|
+
"princ", "princ-to-string", "print", "print-not-readable-object",
|
|
761
|
+
"print-object", "probe-file", "proclaim", "provide", "random",
|
|
762
|
+
"random-state-p", "rassoc", "rassoc-if", "rassoc-if-not", "rational",
|
|
763
|
+
"rationalize", "rationalp", "read", "read-byte", "read-char",
|
|
764
|
+
"read-char-no-hang", "read-delimited-list", "read-from-string", "read-line",
|
|
765
|
+
"read-preserving-whitespace", "read-sequence", "readtable-case",
|
|
766
|
+
"readtablep", "realp", "realpart", "reduce", "reinitialize-instance", "rem",
|
|
767
|
+
"remhash", "remove", "remove-duplicates", "remove-if", "remove-if-not",
|
|
768
|
+
"remove-method", "remprop", "rename-file", "rename-package", "replace",
|
|
769
|
+
"require", "rest", "restart-name", "revappend", "reverse", "room", "round",
|
|
770
|
+
"row-major-aref", "rplaca", "rplacd", "sbit", "scale-float", "schar",
|
|
771
|
+
"search", "second", "set", "set-difference", "set-dispatch-macro-character",
|
|
772
|
+
"set-exclusive-or", "set-macro-character", "set-pprint-dispatch",
|
|
773
|
+
"set-syntax-from-char", "seventh", "shadow", "shadowing-import",
|
|
774
|
+
"shared-initialize", "short-site-name", "signal", "signum",
|
|
775
|
+
"simple-bit-vector-p", "simple-condition-format-arguments",
|
|
776
|
+
"simple-condition-format-control", "simple-string-p", "simple-vector-p",
|
|
777
|
+
"sin", "sinh", "sixth", "sleep", "slot-boundp", "slot-exists-p",
|
|
778
|
+
"slot-makunbound", "slot-missing", "slot-unbound", "slot-value",
|
|
779
|
+
"software-type", "software-version", "some", "sort", "special-operator-p",
|
|
780
|
+
"sqrt", "stable-sort", "standard-char-p", "store-value",
|
|
781
|
+
"stream-element-type", "stream-error-stream", "stream-external-format",
|
|
782
|
+
"streamp", "string", "string-capitalize", "string-downcase", "string-equal",
|
|
783
|
+
"string-greaterp", "string-left-trim", "string-lessp", "string-not-equal",
|
|
784
|
+
"string-not-greaterp", "string-not-lessp", "string-right-trim",
|
|
785
|
+
"string-trim", "string-upcase", "string/=", "string<", "string<=", "string=",
|
|
786
|
+
"string>", "string>=", "stringp", "sublis", "subseq", "subsetp", "subst",
|
|
787
|
+
"subst-if", "subst-if-not", "substitute", "substitute-if",
|
|
788
|
+
"substitute-if-not", "subtypep", "svref", "sxhash", "symbol-function",
|
|
789
|
+
"symbol-name", "symbol-package", "symbol-plist", "symbol-value", "symbolp",
|
|
790
|
+
"synonym-stream-symbol", "tailp", "tan", "tanh", "tenth", "terpri", "third",
|
|
791
|
+
"translate-logical-pathname", "translate-pathname", "tree-equal", "truename",
|
|
792
|
+
"truncate", "two-way-stream-input-stream", "two-way-stream-output-stream",
|
|
793
|
+
"type-error-datum", "type-error-expected-type", "type-of", "typep",
|
|
794
|
+
"unbound-slot-instance", "unexport", "unintern", "union", "unread-char",
|
|
795
|
+
"unuse-package", "update-instance-for-different-class",
|
|
796
|
+
"update-instance-for-redefined-class", "upgraded-array-element-type",
|
|
797
|
+
"upgraded-complex-part-type", "upper-case-p", "use-package", "use-value",
|
|
798
|
+
"user-homedir-pathname", "values", "values-list", "vector", "vector-pop",
|
|
799
|
+
"vector-push", "vector-push-extend", "vectorp", "warn", "wild-pathname-p",
|
|
800
|
+
"write", "write-byte", "write-char", "write-line", "write-sequence",
|
|
801
|
+
"write-string", "write-to-string", "y-or-n-p", "yes-or-no-p", "zerop"
|
|
802
|
+
];
|
|
803
|
+
const variables$1 = [
|
|
804
|
+
"*", "**", "***", "*break-on-signals*", "*compile-file-pathname*",
|
|
805
|
+
"*compile-file-truename*", "*compile-print*", "*compile-verbose*",
|
|
806
|
+
"*debug-io*", "*debugger-hook*", "*default-pathname-defaults*",
|
|
807
|
+
"*error-output*", "*features*", "*gensym-counter*", "*load-pathname*",
|
|
808
|
+
"*load-print*", "*load-truename*", "*load-verbose*", "*macroexpand-hook*",
|
|
809
|
+
"*modules*", "*package*", "*print-array*", "*print-base*", "*print-case*",
|
|
810
|
+
"*print-circle*", "*print-escape*", "*print-gensym*", "*print-length*",
|
|
811
|
+
"*print-level*", "*print-lines*", "*print-miser-width*",
|
|
812
|
+
"*print-pprint-dispatch*", "*print-pretty*", "*print-radix*",
|
|
813
|
+
"*print-readably*", "*print-right-margin*", "*query-io*", "*random-state*",
|
|
814
|
+
"*read-base*", "*read-default-float-format*", "*read-eval*",
|
|
815
|
+
"*read-suppress*", "*readtable*", "*standard-input*", "*standard-output*",
|
|
816
|
+
"*terminal-io*", "*trace-output*", "+", "++", "+++", "-", "/", "//", "///"
|
|
817
|
+
];
|
|
818
|
+
const constants$1 = [
|
|
819
|
+
"array-dimension-limit", "array-rank-limit", "array-total-size-limit",
|
|
820
|
+
"boole-1", "boole-2", "boole-and", "boole-andc1", "boole-andc2", "boole-c1",
|
|
821
|
+
"boole-c2", "boole-clr", "boole-eqv", "boole-ior", "boole-nand", "boole-nor",
|
|
822
|
+
"boole-orc1", "boole-orc2", "boole-set", "boole-xor", "call-arguments-limit",
|
|
823
|
+
"char-code-limit", "double-float-epsilon", "double-float-negative-epsilon",
|
|
824
|
+
"internal-time-units-per-second", "lambda-list-keywords",
|
|
825
|
+
"lambda-parameters-limit", "least-negative-double-float",
|
|
826
|
+
"least-negative-long-float", "least-negative-normalized-double-float",
|
|
827
|
+
"least-negative-normalized-long-float",
|
|
828
|
+
"least-negative-normalized-short-float",
|
|
829
|
+
"least-negative-normalized-single-float", "least-negative-short-float",
|
|
830
|
+
"least-negative-single-float", "least-positive-double-float",
|
|
831
|
+
"least-positive-long-float", "least-positive-normalized-double-float",
|
|
832
|
+
"least-positive-normalized-long-float",
|
|
833
|
+
"least-positive-normalized-short-float",
|
|
834
|
+
"least-positive-normalized-single-float", "least-positive-short-float",
|
|
835
|
+
"least-positive-single-float", "long-float-epsilon",
|
|
836
|
+
"long-float-negative-epsilon", "most-negative-double-float",
|
|
837
|
+
"most-negative-fixnum", "most-negative-long-float",
|
|
838
|
+
"most-negative-short-float", "most-negative-single-float",
|
|
839
|
+
"most-positive-double-float", "most-positive-fixnum",
|
|
840
|
+
"most-positive-long-float", "most-positive-short-float",
|
|
841
|
+
"most-positive-single-float", "multiple-values-limit", "nil", "pi",
|
|
842
|
+
"short-float-epsilon", "short-float-negative-epsilon",
|
|
843
|
+
"single-float-epsilon", "single-float-negative-epsilon", "t"
|
|
844
|
+
];
|
|
845
|
+
|
|
846
|
+
// Common Lisp support on top of the shared Lisp grammar: the standard symbols,
|
|
847
|
+
// snippets, and the names Common Lisp forms define without spelling them out.
|
|
848
|
+
const lambdaListKeywords$1 = [
|
|
849
|
+
"&optional", "&rest", "&key", "&body", "&aux", "&allow-other-keys", "&whole", "&environment"
|
|
850
|
+
];
|
|
851
|
+
const builtinOptions$2 = [
|
|
852
|
+
.../*@__PURE__*/specialOperators.map(label => ({ label, type: "keyword", detail: "special operator" })),
|
|
853
|
+
.../*@__PURE__*/macros$2.map(label => ({ label, type: "keyword", detail: "macro" })),
|
|
854
|
+
.../*@__PURE__*/functions$1.map(label => ({ label, type: "function" })),
|
|
855
|
+
.../*@__PURE__*/variables$1.map(label => ({ label, type: "variable" })),
|
|
856
|
+
.../*@__PURE__*/constants$1.map(label => ({ label, type: "constant" })),
|
|
857
|
+
.../*@__PURE__*/lambdaListKeywords$1.map(label => ({ label, type: "keyword", detail: "lambda list" }))
|
|
858
|
+
];
|
|
859
|
+
// The `defpackage` snippet closes its own form and opens `in-package`, so the
|
|
860
|
+
// closing parenthesis added after it closes `in-package`.
|
|
861
|
+
const snippetSpecs$2 = [
|
|
862
|
+
["defun", "function", "defun ${name} (${params})\n\t${}"],
|
|
863
|
+
["defun", "function with docstring", "defun ${name} (${params})\n\t\"${docstring}\"\n\t${}"],
|
|
864
|
+
["defmacro", "macro", "defmacro ${name} (${params})\n\t`(${})"],
|
|
865
|
+
["defgeneric", "generic function", "defgeneric ${name} (${params})"],
|
|
866
|
+
["defmethod", "method", "defmethod ${name} ((${arg} ${class}))\n\t${}"],
|
|
867
|
+
["defparameter", "global variable", "defparameter *${name}* ${value}"],
|
|
868
|
+
["defvar", "global variable", "defvar *${name}* ${value}"],
|
|
869
|
+
["defconstant", "constant", "defconstant +${name}+ ${value}"],
|
|
870
|
+
["lambda", "anonymous function", "lambda (${params})\n\t${}"],
|
|
871
|
+
["let", "local variables", "let ((${name} ${value}))\n\t${}"],
|
|
872
|
+
["let*", "sequential local variables", "let* ((${name} ${value}))\n\t${}"],
|
|
873
|
+
["flet", "local functions", "flet ((${name} (${params})\n\t\t${}))\n\t${}"],
|
|
874
|
+
["labels", "recursive local functions", "labels ((${name} (${params})\n\t\t${}))\n\t${}"],
|
|
875
|
+
["if", "conditional", "if ${test}\n\t${then}\n\t${else}"],
|
|
876
|
+
["when", "conditional", "when ${test}\n\t${}"],
|
|
877
|
+
["unless", "conditional", "unless ${test}\n\t${}"],
|
|
878
|
+
["cond", "conditional", "cond\n\t((${test}) ${result})\n\t(t ${default})"],
|
|
879
|
+
["case", "conditional", "case ${key}\n\t(${value} ${result})\n\t(otherwise ${default})"],
|
|
880
|
+
["loop", "loop over a list", "loop for ${item} in ${list}\n\t${collect} ${}"],
|
|
881
|
+
["loop", "loop over numbers", "loop for ${i} from ${start} below ${end}\n\t${collect} ${}"],
|
|
882
|
+
["dolist", "loop over a list", "dolist (${item} ${list})\n\t${}"],
|
|
883
|
+
["dotimes", "loop n times", "dotimes (${i} ${n})\n\t${}"],
|
|
884
|
+
["defpackage", "package", "defpackage :${name}\n\t(:use :cl)\n\t(:export #:${symbol}))\n\n(in-package :${name}"],
|
|
885
|
+
["in-package", "set the package", "in-package :${name}"],
|
|
886
|
+
["defstruct", "structure", "defstruct ${name}\n\t${slot}"],
|
|
887
|
+
["defclass", "class", "defclass ${name} (${superclass})\n\t((${slot} :initarg :${slot} :accessor ${accessor}))"],
|
|
888
|
+
["handler-case", "handle a condition", "handler-case ${form}\n\t(${error} (${e})\n\t\t${})"],
|
|
889
|
+
["multiple-value-bind", "bind several values", "multiple-value-bind (${names}) ${form}\n\t${}"]
|
|
890
|
+
];
|
|
891
|
+
/**
|
|
892
|
+
Completes the standard Common Lisp symbols (special operators, macros,
|
|
893
|
+
functions, variables and constants) and snippets for the common forms.
|
|
894
|
+
*/
|
|
895
|
+
const commonLispBuiltins = /*@__PURE__*/builtinSource(builtinOptions$2, snippetSpecs$2);
|
|
896
|
+
const accessorOptions = /*@__PURE__*/new Set([":accessor", ":reader", ":writer"]);
|
|
897
|
+
// The accessors named in `defclass` and `define-condition` slots.
|
|
898
|
+
function classNames(state, form, add) {
|
|
899
|
+
syntaxTree(state).iterate({
|
|
900
|
+
from: form.from,
|
|
901
|
+
to: form.to,
|
|
902
|
+
enter: ref => {
|
|
903
|
+
if (ref.name != "Keyword" || !accessorOptions.has(lower(state, ref.node)))
|
|
904
|
+
return;
|
|
905
|
+
const value = ref.node.nextSibling;
|
|
906
|
+
if ((value === null || value === void 0 ? void 0 : value.name) == "Symbol")
|
|
907
|
+
add({ label: text(state, value), type: "function", detail: "accessor" });
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
/**
|
|
912
|
+
Completes the names declared in the file that are in scope at the cursor.
|
|
913
|
+
On top of the names the grammar marks, it offers the functions written by
|
|
914
|
+
`defstruct`, the accessors named in `defclass`, and `loop` variables.
|
|
915
|
+
*/
|
|
916
|
+
const commonLispLocals = /*@__PURE__*/localsSource((state, pos, add) => {
|
|
917
|
+
eachForm(state, (form, head, kind) => {
|
|
918
|
+
if (head.name == "Definer" && kind == "defstruct")
|
|
919
|
+
structureNames(state, form, add);
|
|
920
|
+
else if (head.name == "Definer" && (kind == "defclass" || kind == "define-condition"))
|
|
921
|
+
classNames(state, form, add);
|
|
922
|
+
else if (head.name == "SpecialForm" && kind == "loop")
|
|
923
|
+
loopNames(state, form, pos, add);
|
|
924
|
+
});
|
|
925
|
+
});
|
|
926
|
+
/**
|
|
927
|
+
Every Common Lisp completion source: the standard symbols, snippets, and
|
|
928
|
+
the names declared in the file.
|
|
929
|
+
*/
|
|
930
|
+
const commonLispCompletion = [commonLispBuiltins, commonLispLocals];
|
|
931
|
+
/**
|
|
932
|
+
Common Lisp language support: the shared Lisp grammar with completion for
|
|
933
|
+
Common Lisp.
|
|
934
|
+
*/
|
|
935
|
+
function commonLisp() {
|
|
936
|
+
return dialectSupport(commonLispCompletion);
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
// The built-in Emacs Lisp special forms, macros and functions offered by
|
|
940
|
+
// completion: the C primitives for lists, sequences, strings, numbers,
|
|
941
|
+
// characters, hash tables, symbols, buffers and evaluation, and the Lisp
|
|
942
|
+
// libraries `subr`, `subr-x`, `seq`, `map`, `pcase`, `cl-lib`, `cl-generic`,
|
|
943
|
+
// `custom` and `ert`. Emacs 30.1 wrote this file with
|
|
944
|
+
// `scripts/emacs-lisp-symbols.el`, which says how to run it.
|
|
945
|
+
const specialForms = [
|
|
946
|
+
"and", "catch", "cond", "condition-case", "defconst", "defvar", "function",
|
|
947
|
+
"if", "inline", "let", "let*", "or", "prog1", "progn", "quote",
|
|
948
|
+
"save-current-buffer", "save-excursion", "save-restriction", "setq",
|
|
949
|
+
"unwind-protect", "while"
|
|
950
|
+
];
|
|
951
|
+
const macros$1 = [
|
|
952
|
+
"and-let*", "cl-assert", "cl-block", "cl-callf", "cl-callf2", "cl-case",
|
|
953
|
+
"cl-check-type", "cl-decf", "cl-declaim", "cl-declare", "cl-defgeneric",
|
|
954
|
+
"cl-define-compiler-macro", "cl-defmacro", "cl-defmethod", "cl-defstruct",
|
|
955
|
+
"cl-defsubst", "cl-deftype", "cl-defun", "cl-destructuring-bind", "cl-do",
|
|
956
|
+
"cl-do*", "cl-do-all-symbols", "cl-do-symbols", "cl-dolist", "cl-dotimes",
|
|
957
|
+
"cl-ecase", "cl-etypecase", "cl-eval-when", "cl-flet", "cl-flet*",
|
|
958
|
+
"cl-function", "cl-incf", "cl-labels", "cl-letf", "cl-letf*",
|
|
959
|
+
"cl-load-time-value", "cl-locally", "cl-loop", "cl-macrolet",
|
|
960
|
+
"cl-multiple-value-bind", "cl-multiple-value-setq", "cl-once-only",
|
|
961
|
+
"cl-prog", "cl-prog*", "cl-progv", "cl-psetf", "cl-psetq", "cl-pushnew",
|
|
962
|
+
"cl-remf", "cl-return", "cl-return-from", "cl-rotatef", "cl-shiftf",
|
|
963
|
+
"cl-symbol-macrolet", "cl-tagbody", "cl-the", "cl-typecase",
|
|
964
|
+
"cl-with-gensyms", "condition-case-unless-debug", "declare", "defcustom",
|
|
965
|
+
"defface", "defgroup", "defmacro", "defsubst", "deftheme", "defun",
|
|
966
|
+
"defvar-local", "dlet", "dolist", "dotimes", "ert-deftest",
|
|
967
|
+
"eval-and-compile", "eval-when-compile", "handler-bind", "if-let",
|
|
968
|
+
"if-let*", "ignore-error", "ignore-errors", "lambda", "letrec", "map-let",
|
|
969
|
+
"named-let", "pcase", "pcase-defmacro", "pcase-dolist", "pcase-exhaustive",
|
|
970
|
+
"pcase-lambda", "pcase-let", "pcase-let*", "pcase-setq", "pop", "prog2",
|
|
971
|
+
"push", "save-match-data", "save-window-excursion", "seq-doseq", "seq-let",
|
|
972
|
+
"seq-setq", "setq-default", "setq-local", "should", "should-error",
|
|
973
|
+
"should-not", "static-if", "thread-first", "thread-last", "unless", "when",
|
|
974
|
+
"when-let", "when-let*", "while-let", "with-current-buffer",
|
|
975
|
+
"with-demoted-errors", "with-memoization", "with-output-to-string",
|
|
976
|
+
"with-restriction", "with-temp-buffer", "with-temp-file",
|
|
977
|
+
"without-restriction"
|
|
978
|
+
];
|
|
979
|
+
const functions = [
|
|
980
|
+
"%", "*", "+", "-", "/", "/=", "1+", "1-", "<", "<=", "=", ">", ">=", "abs",
|
|
981
|
+
"accept-change-group", "acos", "activate-change-group",
|
|
982
|
+
"add-display-text-property", "add-hook", "add-minor-mode", "add-to-list",
|
|
983
|
+
"add-to-ordered-list", "add-variable-watcher", "alist-get", "always",
|
|
984
|
+
"append", "apply", "apply-partially", "aref", "arrayp", "aset", "ash",
|
|
985
|
+
"asin", "assoc", "assoc-default", "assoc-delete-all", "assq",
|
|
986
|
+
"assq-delete-all", "atan", "atom", "backtrace-debug", "backtrace-eval",
|
|
987
|
+
"backtrace-frame", "backtrace-frames", "backward-char",
|
|
988
|
+
"backward-delete-char", "bare-symbol", "bare-symbol-p",
|
|
989
|
+
"barf-if-buffer-read-only", "base64-decode-region", "base64-decode-string",
|
|
990
|
+
"base64-encode-region", "base64-encode-string", "base64url-encode-region",
|
|
991
|
+
"base64url-encode-string", "beginning-of-line", "bignump", "bobp", "bolp",
|
|
992
|
+
"bool-vector", "bool-vector-count-consecutive",
|
|
993
|
+
"bool-vector-count-population", "bool-vector-exclusive-or",
|
|
994
|
+
"bool-vector-intersection", "bool-vector-not", "bool-vector-p",
|
|
995
|
+
"bool-vector-set-difference", "bool-vector-subsetp", "bool-vector-union",
|
|
996
|
+
"booleanp", "boundp", "buffer-base-buffer", "buffer-chars-modified-tick",
|
|
997
|
+
"buffer-enable-undo", "buffer-file-name", "buffer-hash", "buffer-last-name",
|
|
998
|
+
"buffer-line-statistics", "buffer-list", "buffer-live-p",
|
|
999
|
+
"buffer-local-restore-state", "buffer-local-value",
|
|
1000
|
+
"buffer-local-variables", "buffer-match-p", "buffer-modified-p",
|
|
1001
|
+
"buffer-modified-tick", "buffer-name", "buffer-narrowed-p", "buffer-size",
|
|
1002
|
+
"buffer-string", "buffer-substring", "buffer-substring-no-properties",
|
|
1003
|
+
"buffer-swap-text", "bufferp", "butlast", "caaaar", "caaadr", "caaar",
|
|
1004
|
+
"caadar", "caaddr", "caadr", "caar", "cadaar", "cadadr", "cadar", "caddar",
|
|
1005
|
+
"cadddr", "caddr", "cadr", "call-shell-region", "called-interactively-p",
|
|
1006
|
+
"cancel-change-group", "capitalize", "capitalize-region", "capitalize-word",
|
|
1007
|
+
"car", "car-safe", "cdaaar", "cdaadr", "cdaar", "cdadar", "cdaddr", "cdadr",
|
|
1008
|
+
"cdar", "cddaar", "cddadr", "cddar", "cdddar", "cddddr", "cdddr", "cddr",
|
|
1009
|
+
"cdr", "cdr-safe", "ceiling", "char-after", "char-before", "char-equal",
|
|
1010
|
+
"char-or-string-p", "char-resolve-modifiers", "char-to-string",
|
|
1011
|
+
"char-width", "characterp", "chmod", "cl-acons", "cl-adjoin", "cl-assoc",
|
|
1012
|
+
"cl-assoc-if", "cl-assoc-if-not", "cl-caaaar", "cl-caaadr", "cl-caaar",
|
|
1013
|
+
"cl-caadar", "cl-caaddr", "cl-caadr", "cl-cadaar", "cl-cadadr", "cl-cadar",
|
|
1014
|
+
"cl-caddar", "cl-cadddr", "cl-caddr", "cl-call-next-method", "cl-cdaaar",
|
|
1015
|
+
"cl-cdaadr", "cl-cdaar", "cl-cdadar", "cl-cdaddr", "cl-cdadr", "cl-cddaar",
|
|
1016
|
+
"cl-cddadr", "cl-cddar", "cl-cdddar", "cl-cddddr", "cl-cdddr", "cl-ceiling",
|
|
1017
|
+
"cl-coerce", "cl-compiler-macroexpand", "cl-concatenate", "cl-constantly",
|
|
1018
|
+
"cl-copy-list", "cl-copy-seq", "cl-count", "cl-count-if", "cl-count-if-not",
|
|
1019
|
+
"cl-delete", "cl-delete-duplicates", "cl-delete-if", "cl-delete-if-not",
|
|
1020
|
+
"cl-digit-char-p", "cl-eighth", "cl-endp", "cl-equalp", "cl-evenp",
|
|
1021
|
+
"cl-every", "cl-fifth", "cl-fill", "cl-find", "cl-find-class", "cl-find-if",
|
|
1022
|
+
"cl-find-if-not", "cl-find-method", "cl-first", "cl-floor", "cl-fourth",
|
|
1023
|
+
"cl-fresh-line", "cl-functionp", "cl-gcd", "cl-gensym", "cl-gentemp",
|
|
1024
|
+
"cl-get", "cl-getf", "cl-intersection", "cl-isqrt", "cl-lcm", "cl-ldiff",
|
|
1025
|
+
"cl-list*", "cl-list-length", "cl-make-random-state", "cl-map", "cl-mapc",
|
|
1026
|
+
"cl-mapcan", "cl-mapcar", "cl-mapcon", "cl-mapl", "cl-maplist", "cl-member",
|
|
1027
|
+
"cl-member-if", "cl-member-if-not", "cl-merge", "cl-method-qualifiers",
|
|
1028
|
+
"cl-minusp", "cl-mismatch", "cl-mod", "cl-multiple-value-apply",
|
|
1029
|
+
"cl-multiple-value-call", "cl-multiple-value-list", "cl-nintersection",
|
|
1030
|
+
"cl-ninth", "cl-no-applicable-method", "cl-no-next-method",
|
|
1031
|
+
"cl-no-primary-method", "cl-notany", "cl-notevery", "cl-nreconc",
|
|
1032
|
+
"cl-nset-difference", "cl-nset-exclusive-or", "cl-nsublis", "cl-nsubst",
|
|
1033
|
+
"cl-nsubst-if", "cl-nsubst-if-not", "cl-nsubstitute", "cl-nsubstitute-if",
|
|
1034
|
+
"cl-nsubstitute-if-not", "cl-nth-value", "cl-nunion", "cl-oddp",
|
|
1035
|
+
"cl-pairlis", "cl-parse-integer", "cl-plusp", "cl-position",
|
|
1036
|
+
"cl-position-if", "cl-position-if-not", "cl-prettyprint", "cl-proclaim",
|
|
1037
|
+
"cl-random", "cl-random-state-p", "cl-rassoc", "cl-rassoc-if",
|
|
1038
|
+
"cl-rassoc-if-not", "cl-reduce", "cl-rem", "cl-remove",
|
|
1039
|
+
"cl-remove-duplicates", "cl-remove-if", "cl-remove-if-not", "cl-remprop",
|
|
1040
|
+
"cl-replace", "cl-rest", "cl-revappend", "cl-round", "cl-search",
|
|
1041
|
+
"cl-second", "cl-set-difference", "cl-set-exclusive-or", "cl-seventh",
|
|
1042
|
+
"cl-signum", "cl-sixth", "cl-slot-descriptor-p", "cl-some", "cl-sort",
|
|
1043
|
+
"cl-stable-sort", "cl-sublis", "cl-subseq", "cl-subsetp", "cl-subst",
|
|
1044
|
+
"cl-subst-if", "cl-subst-if-not", "cl-substitute", "cl-substitute-if",
|
|
1045
|
+
"cl-substitute-if-not", "cl-svref", "cl-tailp", "cl-tenth", "cl-third",
|
|
1046
|
+
"cl-tree-equal", "cl-truncate", "cl-type-of", "cl-typep", "cl-union",
|
|
1047
|
+
"cl-values", "cl-values-list", "closurep", "clrhash",
|
|
1048
|
+
"collapse-delayed-warnings", "command-modes", "commandp",
|
|
1049
|
+
"compare-buffer-substrings", "compare-strings", "compiled-function-p",
|
|
1050
|
+
"concat", "cons", "consp", "constrain-to-field", "copy-alist",
|
|
1051
|
+
"copy-hash-table", "copy-marker", "copy-overlay", "copy-sequence",
|
|
1052
|
+
"copy-tree", "copysign", "cos", "current-buffer", "current-message",
|
|
1053
|
+
"defalias", "default-boundp", "default-toplevel-value", "default-value",
|
|
1054
|
+
"defconst-1", "define-error", "define-hash-table-test",
|
|
1055
|
+
"define-mail-user-agent", "define-prefix-command", "defvar-1",
|
|
1056
|
+
"defvaralias", "delay-warning", "delete", "delete-all-overlays",
|
|
1057
|
+
"delete-and-extract-region", "delete-char", "delete-consecutive-dups",
|
|
1058
|
+
"delete-dups", "delete-field", "delete-line", "delete-overlay",
|
|
1059
|
+
"delete-region", "delq", "disable-theme", "do-after-load-evaluation",
|
|
1060
|
+
"downcase", "downcase-region", "downcase-word", "drop", "elt", "emacs-pid",
|
|
1061
|
+
"enable-theme", "end-of-line", "ensure-list", "eobp", "eolp", "eq", "eql",
|
|
1062
|
+
"equal", "equal-including-properties", "erase-buffer", "error",
|
|
1063
|
+
"error-message-string", "eval", "eval-buffer", "eval-region", "exp", "expt",
|
|
1064
|
+
"external-debugging-output", "fboundp", "fceiling", "featurep", "ffloor",
|
|
1065
|
+
"fillarray", "find-buffer", "find-tag-default",
|
|
1066
|
+
"find-tag-default-as-regexp", "find-tag-default-as-symbol-regexp",
|
|
1067
|
+
"find-tag-default-bounds", "fixnump", "flatten-list", "flatten-tree",
|
|
1068
|
+
"float", "floatp", "floor", "flush-standard-output", "fmakunbound",
|
|
1069
|
+
"following-char", "force-mode-line-update", "format", "format-message",
|
|
1070
|
+
"forward-char", "forward-line", "forward-symbol", "forward-whitespace",
|
|
1071
|
+
"forward-word-strictly", "frexp", "fround", "fset", "ftruncate",
|
|
1072
|
+
"func-arity", "funcall", "funcall-with-delayed-message", "function-alias-p",
|
|
1073
|
+
"functionp", "gap-position", "gap-size", "generate-new-buffer",
|
|
1074
|
+
"generate-new-buffer-name", "gensym", "get",
|
|
1075
|
+
"get-advertised-calling-convention", "get-buffer", "get-buffer-create",
|
|
1076
|
+
"get-byte", "get-file-buffer", "get-load-suffixes", "get-pos-property",
|
|
1077
|
+
"get-truename-buffer", "get-variable-watchers", "gethash", "goto-char",
|
|
1078
|
+
"group-gid", "group-name", "group-real-gid", "handler-bind-1",
|
|
1079
|
+
"hash-table-count", "hash-table-empty-p", "hash-table-keys", "hash-table-p",
|
|
1080
|
+
"hash-table-rehash-size", "hash-table-rehash-threshold", "hash-table-size",
|
|
1081
|
+
"hash-table-test", "hash-table-values", "hash-table-weakness", "identity",
|
|
1082
|
+
"ignore", "indent-to-column", "indirect-function", "indirect-variable",
|
|
1083
|
+
"insert", "insert-and-inherit", "insert-before-markers",
|
|
1084
|
+
"insert-before-markers-and-inherit", "insert-buffer-substring",
|
|
1085
|
+
"insert-buffer-substring-no-properties", "insert-byte", "insert-char",
|
|
1086
|
+
"insert-into-buffer", "int-to-string", "integer-or-marker-p",
|
|
1087
|
+
"integer-or-null-p", "integerp", "intern", "intern-soft",
|
|
1088
|
+
"interpreted-function-p", "isnan", "json-available-p", "kill-buffer",
|
|
1089
|
+
"kill-local-variable", "last", "ldexp", "length", "length<", "length=",
|
|
1090
|
+
"length>", "line-beginning-position", "line-end-position",
|
|
1091
|
+
"line-number-at-pos", "list", "list-of-strings-p", "listify-key-sequence",
|
|
1092
|
+
"listp", "load", "local-key-binding", "local-variable-if-set-p",
|
|
1093
|
+
"local-variable-p", "log", "logand", "logb", "logcount", "logior", "lognot",
|
|
1094
|
+
"logxor", "looking-at", "looking-at-p", "looking-back", "lsh",
|
|
1095
|
+
"macroexpand", "macrop", "major-mode-restore", "major-mode-suspend",
|
|
1096
|
+
"make-bool-vector", "make-char-table", "make-composed-keymap",
|
|
1097
|
+
"make-finalizer", "make-hash-table", "make-indirect-buffer", "make-list",
|
|
1098
|
+
"make-local-variable", "make-marker", "make-overlay",
|
|
1099
|
+
"make-progress-reporter", "make-record", "make-string", "make-symbol",
|
|
1100
|
+
"make-syntax-table", "make-variable-buffer-local", "make-vector",
|
|
1101
|
+
"makunbound", "malloc-info", "malloc-trim", "map-apply", "map-contains-key",
|
|
1102
|
+
"map-copy", "map-delete", "map-do", "map-elt", "map-empty-p", "map-every-p",
|
|
1103
|
+
"map-filter", "map-insert", "map-into", "map-keymap-sorted", "map-keys",
|
|
1104
|
+
"map-keys-apply", "map-length", "map-merge", "map-merge-with",
|
|
1105
|
+
"map-nested-elt", "map-pairs", "map-put!", "map-remove", "map-some",
|
|
1106
|
+
"map-values", "map-values-apply", "mapatoms", "mapbacktrace", "mapc",
|
|
1107
|
+
"mapcan", "mapcar", "mapconcat", "maphash", "mapp", "mark-marker",
|
|
1108
|
+
"marker-buffer", "marker-insertion-type", "marker-last-position",
|
|
1109
|
+
"marker-position", "markerp", "match-beginning", "match-buffers",
|
|
1110
|
+
"match-data", "match-end", "match-string", "match-string-no-properties",
|
|
1111
|
+
"match-substitute-replacement", "max", "max-char", "md5", "member",
|
|
1112
|
+
"member-ignore-case", "memq", "memql", "merge-ordered-lists", "message",
|
|
1113
|
+
"message-box", "message-or-box", "min", "mkdir", "mod", "module-function-p",
|
|
1114
|
+
"move-marker", "move-overlay", "narrow-to-region", "native-comp-function-p",
|
|
1115
|
+
"natnump", "nbutlast", "nconc", "newline-cache-check",
|
|
1116
|
+
"next-overlay-change", "ngettext", "nlistp", "not", "nreverse", "ntake",
|
|
1117
|
+
"nth", "nthcdr", "null", "number-or-marker-p", "number-sequence",
|
|
1118
|
+
"number-to-string", "numberp", "obarray-clear", "obarray-make", "obarrayp",
|
|
1119
|
+
"object-intervals", "other-buffer", "pcase-compile-patterns", "plist-get",
|
|
1120
|
+
"plist-member", "plist-put", "plistp", "point", "point-marker", "point-max",
|
|
1121
|
+
"point-max-marker", "point-min", "point-min-marker", "pos-bol", "pos-eol",
|
|
1122
|
+
"position-bytes", "position-symbol", "posix-looking-at",
|
|
1123
|
+
"posix-search-backward", "posix-search-forward", "posix-string-match",
|
|
1124
|
+
"preceding-char", "prepare-change-group", "previous-overlay-change",
|
|
1125
|
+
"primitive-function-p", "prin1", "prin1-to-string", "princ", "print",
|
|
1126
|
+
"proper-list-p", "propertize", "provide", "provide-theme",
|
|
1127
|
+
"provided-mode-derived-p", "put", "puthash", "random", "rassoc", "rassq",
|
|
1128
|
+
"rassq-delete-all", "re-search-backward", "re-search-forward", "read",
|
|
1129
|
+
"read-from-string", "readablep", "record", "recordp", "regexp-quote",
|
|
1130
|
+
"region-beginning", "region-end", "register-definition-prefixes", "remhash",
|
|
1131
|
+
"remove", "remove-hook", "remove-overlays", "remove-pos-from-symbol",
|
|
1132
|
+
"remove-variable-watcher", "remove-yank-excluded-properties", "remq",
|
|
1133
|
+
"rename-buffer", "replace-buffer-contents", "replace-match",
|
|
1134
|
+
"replace-regexp-in-region", "replace-regexp-in-string",
|
|
1135
|
+
"replace-region-contents", "replace-string-in-region", "require",
|
|
1136
|
+
"require-theme", "restore-buffer-modified-p", "reverse", "round", "rplaca",
|
|
1137
|
+
"rplacd", "run-hook-query-error-with-timeout", "run-hook-with-args",
|
|
1138
|
+
"run-hook-with-args-until-failure", "run-hook-with-args-until-success",
|
|
1139
|
+
"run-hook-wrapped", "run-hooks", "safe-length", "search-backward",
|
|
1140
|
+
"search-forward", "secure-hash", "secure-hash-algorithms",
|
|
1141
|
+
"self-insert-command", "send-region", "send-string", "seq-concatenate",
|
|
1142
|
+
"seq-contains-p", "seq-copy", "seq-count", "seq-difference", "seq-do",
|
|
1143
|
+
"seq-do-indexed", "seq-drop", "seq-drop-while", "seq-each", "seq-elt",
|
|
1144
|
+
"seq-empty-p", "seq-every-p", "seq-filter", "seq-find", "seq-first",
|
|
1145
|
+
"seq-group-by", "seq-intersection", "seq-into", "seq-into-sequence",
|
|
1146
|
+
"seq-keep", "seq-length", "seq-map", "seq-map-indexed", "seq-mapcat",
|
|
1147
|
+
"seq-mapn", "seq-max", "seq-min", "seq-partition", "seq-position",
|
|
1148
|
+
"seq-positions", "seq-random-elt", "seq-reduce", "seq-remove",
|
|
1149
|
+
"seq-remove-at-position", "seq-rest", "seq-reverse", "seq-set-equal-p",
|
|
1150
|
+
"seq-some", "seq-sort", "seq-sort-by", "seq-split", "seq-subseq",
|
|
1151
|
+
"seq-take", "seq-take-while", "seq-union", "seq-uniq", "seqp", "sequencep",
|
|
1152
|
+
"set", "set-buffer", "set-buffer-modified-p", "set-default",
|
|
1153
|
+
"set-default-toplevel-value", "set-marker", "set-marker-insertion-type",
|
|
1154
|
+
"set-match-data", "setcar", "setcdr", "setplist", "sha1", "signal", "sin",
|
|
1155
|
+
"sort", "special-form-p", "special-variable-p", "split-string",
|
|
1156
|
+
"split-string-and-unquote", "sqrt", "start-file-process-shell-command",
|
|
1157
|
+
"store-match-data", "string", "string-blank-p", "string-bytes",
|
|
1158
|
+
"string-chop-newline", "string-clean-whitespace", "string-collate-equalp",
|
|
1159
|
+
"string-collate-lessp", "string-distance", "string-equal",
|
|
1160
|
+
"string-equal-ignore-case", "string-fill", "string-glyph-split",
|
|
1161
|
+
"string-greaterp", "string-join", "string-lessp", "string-limit",
|
|
1162
|
+
"string-lines", "string-match", "string-match-p", "string-or-null-p",
|
|
1163
|
+
"string-pad", "string-pixel-width", "string-prefix-p",
|
|
1164
|
+
"string-remove-prefix", "string-remove-suffix", "string-replace",
|
|
1165
|
+
"string-search", "string-split", "string-suffix-p", "string-to-char",
|
|
1166
|
+
"string-to-list", "string-to-number", "string-to-unibyte",
|
|
1167
|
+
"string-to-vector", "string-trim", "string-trim-left", "string-trim-right",
|
|
1168
|
+
"string-truncate-left", "string-version-lessp", "string-width", "string<",
|
|
1169
|
+
"string=", "string>", "stringp", "subr-arity", "subr-name",
|
|
1170
|
+
"subr-native-lambda-list", "subr-primitive-p", "subr-type",
|
|
1171
|
+
"subregexp-context-p", "subrp", "subst-char-in-region",
|
|
1172
|
+
"subst-char-in-string", "substring", "substring-no-properties",
|
|
1173
|
+
"suppress-keymap", "sxhash", "sxhash-eq", "sxhash-eql", "sxhash-equal",
|
|
1174
|
+
"sxhash-equal-including-properties", "symbol-file", "symbol-function",
|
|
1175
|
+
"symbol-name", "symbol-plist", "symbol-value", "symbol-with-pos-p",
|
|
1176
|
+
"symbol-with-pos-pos", "symbolp", "syntax-after", "syntax-class",
|
|
1177
|
+
"system-name", "take", "tan", "terpri", "theme-choose-variant",
|
|
1178
|
+
"theme-list-variants", "threadp", "throw", "toggle-theme",
|
|
1179
|
+
"transpose-regions", "truncate", "type-of", "undefined", "unintern",
|
|
1180
|
+
"upcase", "upcase-initials", "upcase-initials-region", "upcase-region",
|
|
1181
|
+
"upcase-word", "use-dialog-box-p", "user-error", "user-full-name",
|
|
1182
|
+
"user-login-name", "user-ptrp", "user-real-login-name", "user-real-uid",
|
|
1183
|
+
"user-uid", "value<", "variable-binding-locus", "vconcat", "vector",
|
|
1184
|
+
"vector-or-char-table-p", "vectorp", "version-list-<", "version-list-<=",
|
|
1185
|
+
"version-list-=", "version-list-not-zero", "version-to-list", "version<",
|
|
1186
|
+
"version<=", "version=", "wholenump", "widen", "widget-apply", "widget-get",
|
|
1187
|
+
"widget-put", "with-no-warnings", "write-char", "xor", "zerop"
|
|
1188
|
+
];
|
|
1189
|
+
|
|
1190
|
+
// Emacs Lisp support on top of the shared Lisp grammar: the built-in special
|
|
1191
|
+
// forms, macros and functions, snippets, and the names Emacs Lisp forms
|
|
1192
|
+
// define without the grammar marking them.
|
|
1193
|
+
const lambdaListKeywords = ["&optional", "&rest", "&key", "&body", "&aux", "&allow-other-keys"];
|
|
1194
|
+
const variables = [
|
|
1195
|
+
"most-positive-fixnum", "most-negative-fixnum", "float-pi", "float-e", "case-fold-search",
|
|
1196
|
+
"standard-output", "standard-input", "lexical-binding", "load-path", "inhibit-read-only",
|
|
1197
|
+
"print-length", "print-level", "fill-column", "tab-width", "indent-tabs-mode"
|
|
1198
|
+
];
|
|
1199
|
+
const builtinOptions$1 = [
|
|
1200
|
+
.../*@__PURE__*/specialForms.map(label => ({ label, type: "keyword", detail: "special form" })),
|
|
1201
|
+
.../*@__PURE__*/macros$1.map(label => ({ label, type: "keyword", detail: "macro" })),
|
|
1202
|
+
.../*@__PURE__*/functions.map(label => ({ label, type: "function" })),
|
|
1203
|
+
.../*@__PURE__*/variables.map(label => ({ label, type: "variable" })),
|
|
1204
|
+
.../*@__PURE__*/["t", "nil"].map(label => ({ label, type: "constant" })),
|
|
1205
|
+
.../*@__PURE__*/lambdaListKeywords.map(label => ({ label, type: "keyword", detail: "argument list" }))
|
|
1206
|
+
];
|
|
1207
|
+
// The `ert-deftest` snippet writes a test as the track's test files do.
|
|
1208
|
+
const snippetSpecs$1 = [
|
|
1209
|
+
["defun", "function", "defun ${name} (${params})\n\t${}"],
|
|
1210
|
+
["defun", "function with docstring", "defun ${name} (${params})\n\t\"${docstring}\"\n\t${}"],
|
|
1211
|
+
["defmacro", "macro", "defmacro ${name} (${params})\n\t`(${})"],
|
|
1212
|
+
["cl-defun", "function with keyword arguments", "cl-defun ${name} (${params} &key ${keys})\n\t${}"],
|
|
1213
|
+
["defvar", "global variable", "defvar ${name} ${value}\n\t\"${docstring}\""],
|
|
1214
|
+
["defconst", "constant", "defconst ${name} ${value}\n\t\"${docstring}\""],
|
|
1215
|
+
["defcustom", "user option", "defcustom ${name} ${value}\n\t\"${docstring}\"\n\t:type '${type}\n\t:group '${group}"],
|
|
1216
|
+
["lambda", "anonymous function", "lambda (${params})\n\t${}"],
|
|
1217
|
+
["let", "local variables", "let ((${name} ${value}))\n\t${}"],
|
|
1218
|
+
["let*", "sequential local variables", "let* ((${name} ${value}))\n\t${}"],
|
|
1219
|
+
["if-let*", "bind and test", "if-let* ((${name} ${value}))\n\t${then}\n\t${else}"],
|
|
1220
|
+
["when-let*", "bind and test", "when-let* ((${name} ${value}))\n\t${}"],
|
|
1221
|
+
["cl-flet", "local functions", "cl-flet ((${name} (${params})\n\t\t${}))\n\t${}"],
|
|
1222
|
+
["cl-labels", "recursive local functions", "cl-labels ((${name} (${params})\n\t\t${}))\n\t${}"],
|
|
1223
|
+
["if", "conditional", "if ${test}\n\t${then}\n\t${else}"],
|
|
1224
|
+
["when", "conditional", "when ${test}\n\t${}"],
|
|
1225
|
+
["unless", "conditional", "unless ${test}\n\t${}"],
|
|
1226
|
+
["cond", "conditional", "cond\n\t((${test}) ${result})\n\t(t ${default})"],
|
|
1227
|
+
["pcase", "pattern match", "pcase ${value}\n\t(${pattern} ${result})\n\t(_ ${default})"],
|
|
1228
|
+
["cl-case", "conditional", "cl-case ${key}\n\t(${value} ${result})\n\t(t ${default})"],
|
|
1229
|
+
["while", "loop while a test holds", "while ${test}\n\t${}"],
|
|
1230
|
+
["dolist", "loop over a list", "dolist (${item} ${list})\n\t${}"],
|
|
1231
|
+
["dotimes", "loop n times", "dotimes (${i} ${n})\n\t${}"],
|
|
1232
|
+
["cl-loop", "loop over a list", "cl-loop for ${item} in ${list}\n\t${collect} ${}"],
|
|
1233
|
+
["cl-loop", "loop over numbers", "cl-loop for ${i} from ${start} below ${end}\n\t${collect} ${}"],
|
|
1234
|
+
["cl-defstruct", "structure", "cl-defstruct ${name}\n\t${slot}"],
|
|
1235
|
+
["condition-case", "handle an error", "condition-case ${err}\n\t\t${form}\n\t(${error} ${})"],
|
|
1236
|
+
["with-temp-buffer", "work in a scratch buffer", "with-temp-buffer\n\t(insert ${text})\n\t${}"],
|
|
1237
|
+
["ert-deftest", "test", "ert-deftest ${name} ()\n\t(should (equal ${expected} ${actual}))"],
|
|
1238
|
+
["provide", "provide a feature", "provide '${feature}"],
|
|
1239
|
+
["require", "load a feature", "require '${feature}"]
|
|
1240
|
+
];
|
|
1241
|
+
/**
|
|
1242
|
+
Completes the built-in Emacs Lisp special forms, macros, functions and
|
|
1243
|
+
variables, and snippets for the common forms.
|
|
1244
|
+
*/
|
|
1245
|
+
const emacsLispBuiltins = /*@__PURE__*/builtinSource(builtinOptions$1, snippetSpecs$1);
|
|
1246
|
+
// `(defalias 'name ...)` and `(defalias #'name ...)` define a function.
|
|
1247
|
+
function aliasName(state, form, add) {
|
|
1248
|
+
const name = partsOf(form)[1];
|
|
1249
|
+
const symbol = (name === null || name === void 0 ? void 0 : name.name) == "Quoted" ? name.lastChild : null;
|
|
1250
|
+
if ((symbol === null || symbol === void 0 ? void 0 : symbol.name) == "Symbol")
|
|
1251
|
+
add({ label: text(state, symbol), type: "function", detail: "alias" });
|
|
1252
|
+
}
|
|
1253
|
+
// `(condition-case err body handlers...)` binds `err` in the handlers.
|
|
1254
|
+
function errorName(state, form, pos, add) {
|
|
1255
|
+
if (pos <= form.from || pos >= form.to)
|
|
1256
|
+
return;
|
|
1257
|
+
const name = partsOf(form)[1];
|
|
1258
|
+
if ((name === null || name === void 0 ? void 0 : name.name) == "Symbol" && !(name.from <= pos && name.to >= pos) && text(state, name) != "nil")
|
|
1259
|
+
add({ label: text(state, name), type: "variable", boost: 1 });
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
Completes the names declared in the file that are in scope at the cursor.
|
|
1263
|
+
On top of the names the grammar marks, it offers the functions written by
|
|
1264
|
+
`cl-defstruct`, functions named by `defalias`, `cl-loop` variables and
|
|
1265
|
+
the error variable of `condition-case`.
|
|
1266
|
+
*/
|
|
1267
|
+
const emacsLispLocals = /*@__PURE__*/localsSource((state, pos, add) => {
|
|
1268
|
+
eachForm(state, (form, head, kind) => {
|
|
1269
|
+
if (head.name == "Definer" && kind == "cl-defstruct")
|
|
1270
|
+
structureNames(state, form, add);
|
|
1271
|
+
else if (head.name == "SpecialForm" && kind == "cl-loop")
|
|
1272
|
+
loopNames(state, form, pos, add);
|
|
1273
|
+
else if (head.name == "SpecialForm" && kind == "condition-case")
|
|
1274
|
+
errorName(state, form, pos, add);
|
|
1275
|
+
else if (head.name == "Callee" && kind == "defalias")
|
|
1276
|
+
aliasName(state, form, add);
|
|
1277
|
+
});
|
|
1278
|
+
});
|
|
1279
|
+
/**
|
|
1280
|
+
Every Emacs Lisp completion source: the built-ins, snippets, and the names
|
|
1281
|
+
declared in the file.
|
|
1282
|
+
*/
|
|
1283
|
+
const emacsLispCompletion = [emacsLispBuiltins, emacsLispLocals];
|
|
1284
|
+
/**
|
|
1285
|
+
Emacs Lisp language support: the shared Lisp grammar with completion for
|
|
1286
|
+
Emacs Lisp.
|
|
1287
|
+
*/
|
|
1288
|
+
function emacsLisp() {
|
|
1289
|
+
return dialectSupport(emacsLispCompletion);
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
// The Erlang functions offered by `lfe()` completion: the BIFs that LFE
|
|
1293
|
+
// calls without a module, and the functions of the common modules, with
|
|
1294
|
+
// their arities. Erlang/OTP 28 wrote this file with
|
|
1295
|
+
// `scripts/lfe-symbols.escript`, which says how to run it.
|
|
1296
|
+
const bifs = [
|
|
1297
|
+
"abs/1", "alias/0/1", "apply/2/3", "atom_to_binary/1/2", "atom_to_list/1",
|
|
1298
|
+
"binary_part/2/3", "binary_to_atom/1/2", "binary_to_existing_atom/1/2",
|
|
1299
|
+
"binary_to_float/1", "binary_to_integer/1/2", "binary_to_list/1/3",
|
|
1300
|
+
"binary_to_term/1/2", "bit_size/1", "bitstring_to_list/1", "byte_size/1",
|
|
1301
|
+
"ceil/1", "check_old_code/1", "check_process_code/2/3", "date/0",
|
|
1302
|
+
"delete_module/1", "demonitor/1/2", "disconnect_node/1", "element/2",
|
|
1303
|
+
"erase/0/1", "error/1/2/3", "exit/1/2/3", "float/1", "float_to_binary/1/2",
|
|
1304
|
+
"float_to_list/1/2", "floor/1", "garbage_collect/0/1/2", "get/0/1",
|
|
1305
|
+
"get_keys/0/1", "group_leader/0/2", "halt/0/1/2", "hd/1",
|
|
1306
|
+
"integer_to_binary/1/2", "integer_to_list/1/2", "iolist_size/1",
|
|
1307
|
+
"iolist_to_binary/1", "is_alive/0", "is_atom/1", "is_binary/1",
|
|
1308
|
+
"is_bitstring/1", "is_boolean/1", "is_float/1", "is_function/1/2",
|
|
1309
|
+
"is_integer/1", "is_list/1", "is_map/1", "is_map_key/2", "is_number/1",
|
|
1310
|
+
"is_pid/1", "is_port/1", "is_process_alive/1", "is_record/2/3",
|
|
1311
|
+
"is_reference/1", "is_tuple/1", "length/1", "link/1/2", "list_to_atom/1",
|
|
1312
|
+
"list_to_binary/1", "list_to_bitstring/1", "list_to_existing_atom/1",
|
|
1313
|
+
"list_to_float/1", "list_to_integer/1/2", "list_to_pid/1", "list_to_port/1",
|
|
1314
|
+
"list_to_ref/1", "list_to_tuple/1", "load_module/2", "make_ref/0",
|
|
1315
|
+
"map_get/2", "map_size/1", "max/2", "min/2", "module_loaded/1",
|
|
1316
|
+
"monitor/2/3", "monitor_node/2", "node/0/1", "nodes/0/1/2", "now/0",
|
|
1317
|
+
"open_port/2", "pid_to_list/1", "port_close/1", "port_command/2/3",
|
|
1318
|
+
"port_connect/2", "port_control/3", "port_to_list/1", "pre_loaded/0",
|
|
1319
|
+
"process_flag/2/3", "process_info/1/2", "processes/0", "purge_module/1",
|
|
1320
|
+
"put/2", "ref_to_list/1", "register/2", "registered/0", "round/1", "self/0",
|
|
1321
|
+
"setelement/3", "size/1", "spawn/1/2/3/4", "spawn_link/1/2/3/4",
|
|
1322
|
+
"spawn_monitor/1/2/3/4", "spawn_opt/2/3/4/5", "spawn_request/1/2/3/4/5",
|
|
1323
|
+
"spawn_request_abandon/1", "split_binary/2", "statistics/1",
|
|
1324
|
+
"term_to_binary/1/2", "term_to_iovec/1/2", "throw/1", "time/0", "tl/1",
|
|
1325
|
+
"trunc/1", "tuple_size/1", "tuple_to_list/1", "unalias/1", "unlink/1",
|
|
1326
|
+
"unregister/1", "whereis/1"
|
|
1327
|
+
];
|
|
1328
|
+
const moduleFunctions = {
|
|
1329
|
+
lists: [
|
|
1330
|
+
"all/2", "any/2", "append/1/2", "concat/1", "delete/2", "droplast/1",
|
|
1331
|
+
"dropwhile/2", "duplicate/2", "enumerate/1/2/3", "filter/2", "filtermap/2",
|
|
1332
|
+
"flatlength/1", "flatmap/2", "flatten/1/2", "foldl/3", "foldr/3",
|
|
1333
|
+
"foreach/2", "join/2", "keydelete/3", "keyfind/3", "keymap/3", "keymember/3",
|
|
1334
|
+
"keymerge/3", "keyreplace/4", "keysearch/3", "keysort/2", "keystore/4",
|
|
1335
|
+
"keytake/3", "last/1", "map/2", "mapfoldl/3", "mapfoldr/3", "max/1",
|
|
1336
|
+
"member/2", "merge/1/2/3", "merge3/3", "min/1", "nth/2", "nthtail/2",
|
|
1337
|
+
"partition/2", "prefix/2", "reverse/1/2", "search/2", "seq/2/3", "sort/1/2",
|
|
1338
|
+
"split/2", "splitwith/2", "sublist/2/3", "subtract/2", "suffix/2", "sum/1",
|
|
1339
|
+
"takewhile/2", "ukeymerge/3", "ukeysort/2", "umerge/1/2/3", "umerge3/3",
|
|
1340
|
+
"uniq/1/2", "unzip/1", "unzip3/1", "usort/1/2", "zip/2/3", "zip3/3/4",
|
|
1341
|
+
"zipwith/3/4", "zipwith3/4/5"
|
|
1342
|
+
],
|
|
1343
|
+
maps: [
|
|
1344
|
+
"filter/2", "filtermap/2", "find/2", "fold/3", "foreach/2", "from_keys/2",
|
|
1345
|
+
"from_list/1", "get/2/3", "groups_from_list/2/3", "intersect/2",
|
|
1346
|
+
"intersect_with/3", "is_key/2", "iterator/1/2", "keys/1", "map/2", "merge/2",
|
|
1347
|
+
"merge_with/3", "new/0", "next/1", "put/3", "remove/2", "size/1", "take/2",
|
|
1348
|
+
"to_list/1", "update/3", "update_with/3/4", "values/1", "with/2", "without/2"
|
|
1349
|
+
],
|
|
1350
|
+
io: [
|
|
1351
|
+
"columns/0/1", "format/1/2/3", "fread/2/3", "fwrite/1/2/3", "get_chars/2/3",
|
|
1352
|
+
"get_line/1/2", "get_password/0", "getopts/0/1", "nl/0/1",
|
|
1353
|
+
"parse_erl_exprs/1/2/3/4", "parse_erl_form/1/2/3/4", "printable_range/0",
|
|
1354
|
+
"put_chars/1/2", "read/1/2/3/4", "rows/0/1", "scan_erl_exprs/1/2/3/4",
|
|
1355
|
+
"scan_erl_form/1/2/3/4", "setopts/1/2", "write/1/2"
|
|
1356
|
+
],
|
|
1357
|
+
io_lib: [
|
|
1358
|
+
"bformat/2/3", "bfwrite/2/3", "build_text/1", "bwrite/2", "bwrite_string/3",
|
|
1359
|
+
"char_list/1", "deep_char_list/1", "deep_latin1_char_list/1", "format/2/3",
|
|
1360
|
+
"fread/2/3", "fwrite/2/3", "indentation/2", "latin1_char_list/1", "nl/0",
|
|
1361
|
+
"print/1/4", "printable_latin1_list/1", "printable_list/1",
|
|
1362
|
+
"printable_unicode_list/1", "scan_format/2", "unscan_format/1", "write/1/2",
|
|
1363
|
+
"write_atom/1", "write_atom_as_latin1/1", "write_char/1",
|
|
1364
|
+
"write_char_as_latin1/1", "write_latin1_char/1", "write_latin1_string/1",
|
|
1365
|
+
"write_string/1", "write_string_as_latin1/1"
|
|
1366
|
+
],
|
|
1367
|
+
string: [
|
|
1368
|
+
"casefold/1", "centre/2/3", "chars/2/3", "chomp/1", "chr/2", "concat/2",
|
|
1369
|
+
"copies/2", "cspan/2", "equal/2/3/4", "find/2/3", "is_empty/1",
|
|
1370
|
+
"jaro_similarity/2", "join/2", "left/2/3", "len/1", "length/1", "lexemes/2",
|
|
1371
|
+
"lowercase/1", "next_codepoint/1", "next_grapheme/1", "nth_lexeme/3",
|
|
1372
|
+
"pad/2/3/4", "prefix/2", "rchr/2", "replace/3/4", "reverse/1", "right/2/3",
|
|
1373
|
+
"rstr/2", "slice/2/3", "span/2", "split/2/3", "str/2", "strip/1/2/3",
|
|
1374
|
+
"sub_string/2/3", "sub_word/2/3", "substr/2/3", "take/2/3/4", "titlecase/1",
|
|
1375
|
+
"to_float/1", "to_graphemes/1", "to_integer/1", "to_lower/1", "to_upper/1",
|
|
1376
|
+
"tokens/2", "trim/1/2/3", "uppercase/1", "words/1/2"
|
|
1377
|
+
],
|
|
1378
|
+
math: [
|
|
1379
|
+
"acos/1", "acosh/1", "asin/1", "asinh/1", "atan/1", "atan2/2", "atanh/1",
|
|
1380
|
+
"ceil/1", "cos/1", "cosh/1", "erf/1", "erfc/1", "exp/1", "floor/1", "fmod/2",
|
|
1381
|
+
"log/1", "log10/1", "log2/1", "pi/0", "pow/2", "sin/1", "sinh/1", "sqrt/1",
|
|
1382
|
+
"tan/1", "tanh/1", "tau/0"
|
|
1383
|
+
],
|
|
1384
|
+
erlang: [
|
|
1385
|
+
"abs/1", "adler32/1/2", "adler32_combine/3", "alias/0/1", "append_element/2",
|
|
1386
|
+
"apply/2/3", "atom_to_binary/1/2", "atom_to_list/1", "binary_part/2/3",
|
|
1387
|
+
"binary_to_atom/1/2", "binary_to_existing_atom/1/2", "binary_to_float/1",
|
|
1388
|
+
"binary_to_integer/1/2", "binary_to_list/1/3", "binary_to_term/1/2",
|
|
1389
|
+
"bit_size/1", "bitstring_to_list/1", "bump_reductions/1", "byte_size/1",
|
|
1390
|
+
"cancel_timer/1/2", "ceil/1", "check_old_code/1", "check_process_code/2/3",
|
|
1391
|
+
"convert_time_unit/3", "crc32/1/2", "crc32_combine/3", "date/0",
|
|
1392
|
+
"decode_packet/3", "delete_element/2", "delete_module/1", "demonitor/1/2",
|
|
1393
|
+
"disconnect_node/1", "display/1", "dist_ctrl_get_data/1",
|
|
1394
|
+
"dist_ctrl_get_data_notification/1", "dist_ctrl_get_opt/2",
|
|
1395
|
+
"dist_ctrl_input_handler/2", "dist_ctrl_put_data/2", "dist_ctrl_set_opt/3",
|
|
1396
|
+
"element/2", "erase/0/1", "error/1/2/3", "exit/1/2/3", "external_size/1/2",
|
|
1397
|
+
"float/1", "float_to_binary/1/2", "float_to_list/1/2", "floor/1",
|
|
1398
|
+
"fun_info/1/2", "fun_to_list/1", "function_exported/3",
|
|
1399
|
+
"garbage_collect/0/1/2", "get/0/1", "get_cookie/0/1", "get_keys/0/1",
|
|
1400
|
+
"group_leader/0/2", "halt/0/1/2", "hd/1", "hibernate/0/3",
|
|
1401
|
+
"insert_element/3", "integer_to_binary/1/2", "integer_to_list/1/2",
|
|
1402
|
+
"iolist_size/1", "iolist_to_binary/1", "iolist_to_iovec/1", "is_alive/0",
|
|
1403
|
+
"is_atom/1", "is_binary/1", "is_bitstring/1", "is_boolean/1", "is_builtin/3",
|
|
1404
|
+
"is_float/1", "is_function/1/2", "is_integer/1", "is_list/1", "is_map/1",
|
|
1405
|
+
"is_map_key/2", "is_number/1", "is_pid/1", "is_port/1", "is_process_alive/1",
|
|
1406
|
+
"is_record/2/3", "is_reference/1", "is_tuple/1", "length/1", "link/1/2",
|
|
1407
|
+
"list_to_atom/1", "list_to_binary/1", "list_to_bitstring/1",
|
|
1408
|
+
"list_to_existing_atom/1", "list_to_float/1", "list_to_integer/1/2",
|
|
1409
|
+
"list_to_pid/1", "list_to_port/1", "list_to_ref/1", "list_to_tuple/1",
|
|
1410
|
+
"load_module/2", "load_nif/2", "loaded/0", "localtime/0",
|
|
1411
|
+
"localtime_to_universaltime/1/2", "make_ref/0", "make_tuple/2/3",
|
|
1412
|
+
"map_get/2", "map_size/1", "match_spec_test/3", "max/2", "md5/1",
|
|
1413
|
+
"md5_final/1", "md5_init/0", "md5_update/2", "memory/0/1", "min/2",
|
|
1414
|
+
"module_loaded/1", "monitor/2/3", "monitor_node/2/3", "monotonic_time/0/1",
|
|
1415
|
+
"nif_error/1/2", "node/0/1", "nodes/0/1/2", "now/0", "open_port/2",
|
|
1416
|
+
"phash/2", "phash2/1/2", "pid_to_list/1", "port_call/3", "port_close/1",
|
|
1417
|
+
"port_command/2/3", "port_connect/2", "port_control/3", "port_info/1/2",
|
|
1418
|
+
"port_to_list/1", "ports/0", "pre_loaded/0", "process_display/2",
|
|
1419
|
+
"process_flag/2/3", "process_info/1/2", "processes/0",
|
|
1420
|
+
"processes_iterator/0", "processes_next/1", "purge_module/1", "put/2",
|
|
1421
|
+
"raise/3", "read_timer/1/2", "ref_to_list/1", "register/2", "registered/0",
|
|
1422
|
+
"resume_process/1", "round/1", "self/0", "send/2/3", "send_after/3/4",
|
|
1423
|
+
"send_nosuspend/2/3", "set_cookie/1/2", "setelement/3", "size/1",
|
|
1424
|
+
"spawn/1/2/3/4", "spawn_link/1/2/3/4", "spawn_monitor/1/2/3/4",
|
|
1425
|
+
"spawn_opt/2/3/4/5", "spawn_request/1/2/3/4/5", "spawn_request_abandon/1",
|
|
1426
|
+
"split_binary/2", "start_timer/3/4", "statistics/1", "suspend_process/1/2",
|
|
1427
|
+
"system_flag/2", "system_info/1", "system_monitor/0/1/2",
|
|
1428
|
+
"system_profile/0/2", "system_time/0/1", "term_to_binary/1/2",
|
|
1429
|
+
"term_to_iovec/1/2", "throw/1", "time/0", "time_offset/0/1", "timestamp/0",
|
|
1430
|
+
"tl/1", "trace/3", "trace_delivered/1", "trace_info/2", "trace_pattern/2/3",
|
|
1431
|
+
"trunc/1", "tuple_size/1", "tuple_to_list/1", "unalias/1",
|
|
1432
|
+
"unique_integer/0/1", "universaltime/0", "universaltime_to_localtime/1",
|
|
1433
|
+
"unlink/1", "unregister/1", "whereis/1", "yield/0"
|
|
1434
|
+
],
|
|
1435
|
+
proplists: [
|
|
1436
|
+
"append_values/2", "compact/1", "delete/2", "expand/2", "from_map/1",
|
|
1437
|
+
"get_all_values/2", "get_bool/2", "get_keys/1", "get_value/2/3",
|
|
1438
|
+
"is_defined/2", "lookup/2", "lookup_all/2", "normalize/2", "property/1/2",
|
|
1439
|
+
"split/2", "substitute_aliases/2", "substitute_negations/2", "to_map/1/2",
|
|
1440
|
+
"unfold/1"
|
|
1441
|
+
],
|
|
1442
|
+
sets: [
|
|
1443
|
+
"add_element/2", "del_element/2", "filter/2", "filtermap/2", "fold/3",
|
|
1444
|
+
"from_list/1/2", "intersection/1/2", "is_disjoint/2", "is_element/2",
|
|
1445
|
+
"is_empty/1", "is_equal/2", "is_set/1", "is_subset/2", "map/2", "new/0/1",
|
|
1446
|
+
"size/1", "subtract/2", "to_list/1", "union/1/2"
|
|
1447
|
+
],
|
|
1448
|
+
ordsets: [
|
|
1449
|
+
"add_element/2", "del_element/2", "filter/2", "filtermap/2", "fold/3",
|
|
1450
|
+
"from_list/1", "intersection/1/2", "is_disjoint/2", "is_element/2",
|
|
1451
|
+
"is_empty/1", "is_equal/2", "is_set/1", "is_subset/2", "map/2", "new/0",
|
|
1452
|
+
"size/1", "subtract/2", "to_list/1", "union/1/2"
|
|
1453
|
+
],
|
|
1454
|
+
orddict: [
|
|
1455
|
+
"append/3", "append_list/3", "erase/2", "fetch/2", "fetch_keys/1",
|
|
1456
|
+
"filter/2", "find/2", "fold/3", "from_list/1", "is_empty/1", "is_key/2",
|
|
1457
|
+
"map/2", "merge/3", "new/0", "size/1", "store/3", "take/2", "to_list/1",
|
|
1458
|
+
"update/3/4", "update_counter/3"
|
|
1459
|
+
],
|
|
1460
|
+
dict: [
|
|
1461
|
+
"append/3", "append_list/3", "erase/2", "fetch/2", "fetch_keys/1",
|
|
1462
|
+
"filter/2", "find/2", "fold/3", "from_list/1", "is_empty/1", "is_key/2",
|
|
1463
|
+
"map/2", "merge/3", "new/0", "size/1", "store/3", "take/2", "to_list/1",
|
|
1464
|
+
"update/3/4", "update_counter/3"
|
|
1465
|
+
],
|
|
1466
|
+
binary: [
|
|
1467
|
+
"at/2", "bin_to_list/1/2/3", "compile_pattern/1", "copy/1/2", "decode_hex/1",
|
|
1468
|
+
"decode_unsigned/1/2", "encode_hex/1/2", "encode_unsigned/1/2", "first/1",
|
|
1469
|
+
"join/2", "last/1", "list_to_bin/1", "longest_common_prefix/1",
|
|
1470
|
+
"longest_common_suffix/1", "match/2/3", "matches/2/3", "part/2/3",
|
|
1471
|
+
"referenced_byte_size/1", "replace/3/4", "split/2/3"
|
|
1472
|
+
],
|
|
1473
|
+
unicode: [
|
|
1474
|
+
"bom_to_encoding/1", "characters_to_binary/1/2/3", "characters_to_list/1/2",
|
|
1475
|
+
"characters_to_nfc_binary/1", "characters_to_nfc_list/1",
|
|
1476
|
+
"characters_to_nfd_binary/1", "characters_to_nfd_list/1",
|
|
1477
|
+
"characters_to_nfkc_binary/1", "characters_to_nfkc_list/1",
|
|
1478
|
+
"characters_to_nfkd_binary/1", "characters_to_nfkd_list/1",
|
|
1479
|
+
"encoding_to_bom/1"
|
|
1480
|
+
],
|
|
1481
|
+
timer: [
|
|
1482
|
+
"apply_after/2/3/4", "apply_interval/2/3/4", "apply_repeatedly/2/3/4",
|
|
1483
|
+
"cancel/1", "exit_after/2/3", "hms/3", "hours/1", "kill_after/1/2",
|
|
1484
|
+
"minutes/1", "now_diff/2", "seconds/1", "send_after/2/3",
|
|
1485
|
+
"send_interval/2/3", "sleep/1", "start/0", "tc/1/2/3/4"
|
|
1486
|
+
],
|
|
1487
|
+
queue: [
|
|
1488
|
+
"all/2", "any/2", "cons/2", "daeh/1", "delete/2", "delete_r/2",
|
|
1489
|
+
"delete_with/2", "delete_with_r/2", "drop/1", "drop_r/1", "filter/2",
|
|
1490
|
+
"filtermap/2", "fold/3", "from_list/1", "get/1", "get_r/1", "head/1", "in/2",
|
|
1491
|
+
"in_r/2", "init/1", "is_empty/1", "is_queue/1", "join/2", "lait/1", "last/1",
|
|
1492
|
+
"len/1", "liat/1", "member/2", "new/0", "out/1", "out_r/1", "peek/1",
|
|
1493
|
+
"peek_r/1", "reverse/1", "snoc/2", "split/2", "tail/1", "to_list/1"
|
|
1494
|
+
],
|
|
1495
|
+
array: [
|
|
1496
|
+
"default/1", "fix/1", "foldl/3", "foldr/3", "from_list/1/2",
|
|
1497
|
+
"from_orddict/1/2", "get/2", "is_array/1", "is_fix/1", "map/2", "new/0/1/2",
|
|
1498
|
+
"relax/1", "reset/2", "resize/1/2", "set/3", "size/1", "sparse_foldl/3",
|
|
1499
|
+
"sparse_foldr/3", "sparse_map/2", "sparse_size/1", "sparse_to_list/1",
|
|
1500
|
+
"sparse_to_orddict/1", "to_list/1", "to_orddict/1"
|
|
1501
|
+
],
|
|
1502
|
+
gb_trees: [
|
|
1503
|
+
"balance/1", "delete/2", "delete_any/2", "empty/0", "enter/3",
|
|
1504
|
+
"from_orddict/1", "get/2", "insert/3", "is_defined/2", "is_empty/1",
|
|
1505
|
+
"iterator/1/2", "iterator_from/2/3", "keys/1", "larger/2", "largest/1",
|
|
1506
|
+
"lookup/2", "map/2", "next/1", "size/1", "smaller/2", "smallest/1", "take/2",
|
|
1507
|
+
"take_any/2", "take_largest/1", "take_smallest/1", "to_list/1", "update/3",
|
|
1508
|
+
"values/1"
|
|
1509
|
+
],
|
|
1510
|
+
gb_sets: [
|
|
1511
|
+
"add/2", "add_element/2", "balance/1", "del_element/2", "delete/2",
|
|
1512
|
+
"delete_any/2", "difference/2", "empty/0", "filter/2", "filtermap/2",
|
|
1513
|
+
"fold/3", "from_list/1", "from_ordset/1", "insert/2", "intersection/1/2",
|
|
1514
|
+
"is_disjoint/2", "is_element/2", "is_empty/1", "is_equal/2", "is_member/2",
|
|
1515
|
+
"is_set/1", "is_subset/2", "iterator/1/2", "iterator_from/2/3", "larger/2",
|
|
1516
|
+
"largest/1", "map/2", "new/0", "next/1", "singleton/1", "size/1",
|
|
1517
|
+
"smaller/2", "smallest/1", "subtract/2", "take_largest/1", "take_smallest/1",
|
|
1518
|
+
"to_list/1", "union/1/2"
|
|
1519
|
+
],
|
|
1520
|
+
calendar: [
|
|
1521
|
+
"date_to_gregorian_days/1/3", "datetime_to_gregorian_seconds/1",
|
|
1522
|
+
"day_of_the_week/1/3", "gregorian_days_to_date/1",
|
|
1523
|
+
"gregorian_seconds_to_datetime/1", "is_leap_year/1", "iso_week_number/0/1",
|
|
1524
|
+
"last_day_of_the_month/2", "local_time/0", "local_time_to_system_time/1/2",
|
|
1525
|
+
"local_time_to_universal_time/1", "local_time_to_universal_time_dst/1",
|
|
1526
|
+
"now_to_datetime/1", "now_to_local_time/1", "now_to_universal_time/1",
|
|
1527
|
+
"rfc3339_to_system_time/1/2", "seconds_to_daystime/1", "seconds_to_time/1",
|
|
1528
|
+
"system_time_to_local_time/2", "system_time_to_rfc3339/1/2",
|
|
1529
|
+
"system_time_to_universal_time/2", "time_difference/2", "time_to_seconds/1",
|
|
1530
|
+
"universal_time/0", "universal_time_to_local_time/1",
|
|
1531
|
+
"universal_time_to_system_time/1/2", "valid_date/1/3"
|
|
1532
|
+
],
|
|
1533
|
+
re: [
|
|
1534
|
+
"compile/1/2", "inspect/2", "replace/3/4", "run/2/3", "split/2/3",
|
|
1535
|
+
"version/0"
|
|
1536
|
+
],
|
|
1537
|
+
rand: [
|
|
1538
|
+
"bytes/1", "bytes_s/2", "export_seed/0", "export_seed_s/1", "exsp_jump/1",
|
|
1539
|
+
"exsp_next/1", "jump/0/1", "mwc59/1", "mwc59_float/1", "mwc59_seed/0/1",
|
|
1540
|
+
"mwc59_value/1", "mwc59_value32/1", "normal/0/2", "normal_s/1/3", "seed/1/2",
|
|
1541
|
+
"seed_s/1/2", "splitmix64_next/1", "uniform/0/1", "uniform_real/0",
|
|
1542
|
+
"uniform_real_s/1", "uniform_s/1/2"
|
|
1543
|
+
],
|
|
1544
|
+
gen_server: [
|
|
1545
|
+
"abcast/2/3", "call/2/3", "cast/2", "check_response/2/3", "enter_loop/3/4/5",
|
|
1546
|
+
"multi_call/2/3/4", "receive_response/2/3", "reply/2", "reqids_add/3",
|
|
1547
|
+
"reqids_new/0", "reqids_size/1", "reqids_to_list/1", "send_request/2/4",
|
|
1548
|
+
"start/3/4", "start_link/3/4", "start_monitor/3/4", "stop/1/3",
|
|
1549
|
+
"wait_response/2/3"
|
|
1550
|
+
],
|
|
1551
|
+
ets: [
|
|
1552
|
+
"all/0", "delete/1/2", "delete_all_objects/1", "delete_object/2",
|
|
1553
|
+
"file2tab/1/2", "first/1", "first_lookup/1", "foldl/3", "foldr/3",
|
|
1554
|
+
"from_dets/2", "fun2ms/1", "give_away/3", "i/0/1", "info/1/2",
|
|
1555
|
+
"init_table/2", "insert/2", "insert_new/2", "is_compiled_ms/1", "last/1",
|
|
1556
|
+
"last_lookup/1", "lookup/2", "lookup_element/3/4", "match/1/2/3",
|
|
1557
|
+
"match_delete/2", "match_object/1/2/3", "match_spec_compile/1",
|
|
1558
|
+
"match_spec_run/2", "member/2", "new/2", "next/2", "next_lookup/2", "prev/2",
|
|
1559
|
+
"prev_lookup/2", "rename/2", "repair_continuation/2", "safe_fixtable/2",
|
|
1560
|
+
"select/1/2/3", "select_count/2", "select_delete/2", "select_replace/2",
|
|
1561
|
+
"select_reverse/1/2/3", "setopts/2", "slot/2", "tab2file/2/3", "tab2list/1",
|
|
1562
|
+
"tabfile_info/1", "table/1/2", "take/2", "test_ms/2", "to_dets/2",
|
|
1563
|
+
"update_counter/3/4", "update_element/3/4", "whereis/1"
|
|
1564
|
+
]
|
|
1565
|
+
};
|
|
1566
|
+
|
|
1567
|
+
// Lisp Flavoured Erlang support on top of the shared Lisp grammar. LFE turns
|
|
1568
|
+
// on the grammar's `lfe` dialect, which reads `defun`, `defmacro`,
|
|
1569
|
+
// `match-lambda`, `flet` and `fletrec` written as pattern-matching clauses.
|
|
1570
|
+
// Completion offers LFE's forms, the Erlang BIFs, the functions of the common
|
|
1571
|
+
// Erlang modules after `lists:` and the like, snippets, and the names bound in
|
|
1572
|
+
// the file, including the variables in patterns.
|
|
1573
|
+
/**
|
|
1574
|
+
The shared Lisp language with the grammar's `lfe` dialect turned on.
|
|
1575
|
+
*/
|
|
1576
|
+
const lfeLanguage = /*@__PURE__*/lispLanguage.configure({ dialect: "lfe" }, "lfe");
|
|
1577
|
+
// LFE's core forms and the macros that ship with it.
|
|
1578
|
+
const coreForms = [
|
|
1579
|
+
"quote", "cons", "car", "cdr", "list", "tuple", "binary", "map", "lambda", "match-lambda",
|
|
1580
|
+
"let", "let-function", "letrec-function", "let-macro", "progn", "if", "case", "receive",
|
|
1581
|
+
"catch", "try", "funcall", "call", "after", "when", "eval-when-compile", "define-module",
|
|
1582
|
+
"define-function", "define-macro", "define-record", "tref", "tset", "mref", "mset", "mupd",
|
|
1583
|
+
"map-get", "map-set", "map-update", "map-remove"
|
|
1584
|
+
];
|
|
1585
|
+
const macros = [
|
|
1586
|
+
"defmodule", "defun", "defmacro", "defsyntax", "defrecord", "defstruct", "deftype",
|
|
1587
|
+
"defopaque", "defspec", "let*", "flet", "flet*", "fletrec", "macrolet", "syntaxlet",
|
|
1588
|
+
"cond", "andalso", "orelse", "fun", "lc", "list-comp", "bc", "binary-comp", "qlc",
|
|
1589
|
+
"match-spec", "do", "list*", "++", "++*", ":", "?", "caar", "cadr", "cdar", "cddr",
|
|
1590
|
+
"backquote", "include-file", "include-lib", "export", "import", "from", "rename"
|
|
1591
|
+
];
|
|
1592
|
+
// Erlang's operators, which LFE writes as functions.
|
|
1593
|
+
const operators = [
|
|
1594
|
+
"+", "-", "*", "/", "==", "/=", "=:=", "=/=", "<", ">", "=<", ">=", "and", "or", "not",
|
|
1595
|
+
"xor", "band", "bor", "bxor", "bnot", "bsl", "bsr", "div", "rem", "!"
|
|
1596
|
+
];
|
|
1597
|
+
const constants = ["true", "false", "undefined", "ok", "error"];
|
|
1598
|
+
// `"foldl/3"` becomes `foldl` with its arities as the detail.
|
|
1599
|
+
function functionOptions(entries, detail = "") {
|
|
1600
|
+
return entries.map(entry => {
|
|
1601
|
+
const [label, ...arities] = entry.split("/");
|
|
1602
|
+
return { label, type: "function", detail: (detail ? detail + " " : "") + "/" + arities.join("/") };
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
const builtinOptions = [
|
|
1606
|
+
.../*@__PURE__*/coreForms.map(label => ({ label, type: "keyword", detail: "core form" })),
|
|
1607
|
+
.../*@__PURE__*/macros.map(label => ({ label, type: "keyword", detail: "macro" })),
|
|
1608
|
+
.../*@__PURE__*/functionOptions(bifs),
|
|
1609
|
+
.../*@__PURE__*/operators.map(label => ({ label, type: "function", detail: "operator" })),
|
|
1610
|
+
.../*@__PURE__*/constants.map(label => ({ label, type: "constant" })),
|
|
1611
|
+
.../*@__PURE__*/Object.keys(moduleFunctions).map(label => ({ label, type: "namespace", detail: "module" }))
|
|
1612
|
+
];
|
|
1613
|
+
const snippetSpecs = [
|
|
1614
|
+
["defmodule", "module", "defmodule ${name}\n\t(export (${function} ${arity})))"],
|
|
1615
|
+
["defun", "function", "defun ${name} (${params})\n\t${}"],
|
|
1616
|
+
["defun", "function with clauses", "defun ${name}\n\t((${pattern}) ${result})\n\t((${pattern}) ${})"],
|
|
1617
|
+
["defun", "function with a guard", "defun ${name}\n\t((${pattern}) (when ${guard})\n\t\t${})\n\t((${pattern}) ${})"],
|
|
1618
|
+
["defmacro", "macro", "defmacro ${name} (${params})\n\t`(${})"],
|
|
1619
|
+
["defrecord", "record", "defrecord ${name}\n\t${field}"],
|
|
1620
|
+
["lambda", "anonymous function", "lambda (${params})\n\t${}"],
|
|
1621
|
+
["match-lambda", "anonymous function with clauses", "match-lambda\n\t((${pattern}) ${result})\n\t((${pattern}) ${})"],
|
|
1622
|
+
["let", "local variables", "let ((${name} ${value}))\n\t${}"],
|
|
1623
|
+
["let*", "sequential local variables", "let* ((${name} ${value}))\n\t${}"],
|
|
1624
|
+
["flet", "local functions", "flet ((${name} (${params})\n\t\t${}))\n\t${}"],
|
|
1625
|
+
["fletrec", "recursive local functions", "fletrec ((${name} (${params})\n\t\t${}))\n\t${}"],
|
|
1626
|
+
["if", "conditional", "if ${test}\n\t${then}\n\t${else}"],
|
|
1627
|
+
["cond", "conditional", "cond\n\t(${test} ${result})\n\t('true ${default})"],
|
|
1628
|
+
["case", "pattern match", "case ${value}\n\t(${pattern} ${result})\n\t(_ ${default})"],
|
|
1629
|
+
["receive", "receive a message", "receive\n\t(${pattern} ${})\n\t(after ${timeout} ${timedOut})"],
|
|
1630
|
+
["try", "handle an exception", "try ${expression}\n\t(catch\n\t\t((tuple ${class} ${reason} ${stack}) ${})))"],
|
|
1631
|
+
["lc", "list comprehension", "lc ((<- ${item} ${list}))\n\t${}"],
|
|
1632
|
+
["fun", "function reference", "fun ${name} ${arity}"]
|
|
1633
|
+
];
|
|
1634
|
+
/**
|
|
1635
|
+
Completes LFE's core forms and macros, the Erlang BIFs and operators, the
|
|
1636
|
+
common module names, and snippets for the common forms.
|
|
1637
|
+
*/
|
|
1638
|
+
const lfeBuiltins = /*@__PURE__*/builtinSource(builtinOptions, snippetSpecs);
|
|
1639
|
+
const moduleOptions = /*@__PURE__*/Object.create(null);
|
|
1640
|
+
for (const module in moduleFunctions)
|
|
1641
|
+
moduleOptions[module] = /*@__PURE__*/functionOptions(moduleFunctions[module], module);
|
|
1642
|
+
const functionName = /^[^\s()\[\]{}"';`,#|:]*$/;
|
|
1643
|
+
/**
|
|
1644
|
+
Completes the functions of an Erlang module, after `lists:` in
|
|
1645
|
+
`(lists:foldl ...)` and after the module name in `(: lists foldl ...)`.
|
|
1646
|
+
*/
|
|
1647
|
+
const lfeModuleFunctions = (context) => {
|
|
1648
|
+
if (!canComplete(context))
|
|
1649
|
+
return null;
|
|
1650
|
+
const qualified = context.matchBefore(/[a-z][\w@]*:[^\s()\[\]{}"';`,#|:]*$/);
|
|
1651
|
+
if (qualified) {
|
|
1652
|
+
const colon = qualified.text.indexOf(":");
|
|
1653
|
+
const options = moduleOptions[qualified.text.slice(0, colon)];
|
|
1654
|
+
return options ? { from: qualified.from + colon + 1, options, validFor: functionName } : null;
|
|
1655
|
+
}
|
|
1656
|
+
const spaced = context.matchBefore(/\(:\s+[a-z][\w@]*\s+[^\s()\[\]{}"';`,#|:]*$/);
|
|
1657
|
+
if (spaced) {
|
|
1658
|
+
const [, module, name] = /^\(:\s+([a-z][\w@]*)\s+(.*)$/.exec(spaced.text);
|
|
1659
|
+
const options = moduleOptions[module];
|
|
1660
|
+
return options ? { from: context.pos - name.length, options, validFor: functionName } : null;
|
|
1661
|
+
}
|
|
1662
|
+
return null;
|
|
1663
|
+
};
|
|
1664
|
+
const contains = (node, pos) => pos > node.from && pos < node.to;
|
|
1665
|
+
const touches = (node, pos) => pos >= node.from && pos <= node.to;
|
|
1666
|
+
// The heads of patterns that build a value rather than name one.
|
|
1667
|
+
const constructors = /*@__PURE__*/new Set(["cons", "list", "tuple", "binary", "map", "=", "list*"]);
|
|
1668
|
+
/**
|
|
1669
|
+
The variables a pattern binds. A bare name binds itself, apart from `_`. In
|
|
1670
|
+
a list the head is a constructor, such as `cons` or `tuple`, or a record
|
|
1671
|
+
matcher such as `match-person`, and the rest are patterns. In a
|
|
1672
|
+
backquoted pattern only the names after `,` bind.
|
|
1673
|
+
*/
|
|
1674
|
+
function patternNames(state, node, out, quasi = false) {
|
|
1675
|
+
switch (node.name) {
|
|
1676
|
+
case "Symbol":
|
|
1677
|
+
case "Callee":
|
|
1678
|
+
case "LocalName":
|
|
1679
|
+
if (!quasi && text(state, node) != "_")
|
|
1680
|
+
out.push(text(state, node));
|
|
1681
|
+
return;
|
|
1682
|
+
case "Quoted": {
|
|
1683
|
+
const mark = node.firstChild, inner = node.lastChild;
|
|
1684
|
+
if (!mark || !inner || mark == inner)
|
|
1685
|
+
return;
|
|
1686
|
+
const quote = text(state, mark);
|
|
1687
|
+
if (quote == "`")
|
|
1688
|
+
patternNames(state, inner, out, true);
|
|
1689
|
+
else if (quote == "," || quote == ",@")
|
|
1690
|
+
patternNames(state, inner, out, false);
|
|
1691
|
+
return;
|
|
1692
|
+
}
|
|
1693
|
+
case "Vector":
|
|
1694
|
+
case "Patterns":
|
|
1695
|
+
for (const part of partsOf(node))
|
|
1696
|
+
patternNames(state, part, out, quasi);
|
|
1697
|
+
return;
|
|
1698
|
+
case "List":
|
|
1699
|
+
case "PatternList":
|
|
1700
|
+
case "Brackets":
|
|
1701
|
+
case "BoundList": {
|
|
1702
|
+
const parts = partsOf(node);
|
|
1703
|
+
if (quasi) {
|
|
1704
|
+
for (const part of parts)
|
|
1705
|
+
patternNames(state, part, out, true);
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
const head = parts[0] ? lower(state, parts[0]) : "";
|
|
1709
|
+
if (head == "binary") {
|
|
1710
|
+
// `(binary (size (size 8)) (rest binary))`: the first part of each
|
|
1711
|
+
// segment is the pattern, and the rest says how to read it.
|
|
1712
|
+
for (const segment of parts.slice(1)) {
|
|
1713
|
+
const pattern = segment.name == "List" || segment.name == "PatternList" ? partsOf(segment)[0] : segment;
|
|
1714
|
+
if (pattern)
|
|
1715
|
+
patternNames(state, pattern, out, false);
|
|
1716
|
+
}
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
if (head == "map") {
|
|
1720
|
+
// `(map key value ...)` binds only the values.
|
|
1721
|
+
for (let i = 2; i < parts.length; i += 2)
|
|
1722
|
+
patternNames(state, parts[i], out, false);
|
|
1723
|
+
return;
|
|
1724
|
+
}
|
|
1725
|
+
const isConstructor = constructors.has(head) || head.startsWith("match-");
|
|
1726
|
+
for (const part of parts.slice(isConstructor ? 1 : 0))
|
|
1727
|
+
patternNames(state, part, out, false);
|
|
1728
|
+
return;
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
function addVariables(names, add) {
|
|
1733
|
+
for (const label of names)
|
|
1734
|
+
add({ label, type: "variable", boost: 1 });
|
|
1735
|
+
}
|
|
1736
|
+
// `(case value (pattern body...) ...)`, and the same clauses in `receive` and
|
|
1737
|
+
// in the `catch` of `try`. A clause's variables are visible in its body.
|
|
1738
|
+
function clauseNames(state, clauses, pos, add) {
|
|
1739
|
+
for (const clause of clauses) {
|
|
1740
|
+
if (!contains(clause, pos) || (clause.name != "List" && clause.name != "Brackets"))
|
|
1741
|
+
continue;
|
|
1742
|
+
const pattern = partsOf(clause)[0];
|
|
1743
|
+
if (!pattern || touches(pattern, pos) || lower(state, pattern) == "after")
|
|
1744
|
+
continue;
|
|
1745
|
+
const names = [];
|
|
1746
|
+
patternNames(state, pattern, names);
|
|
1747
|
+
addVariables(names, add);
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
// `(let ((pattern value) ...) body)`: the names bound by patterns that the
|
|
1751
|
+
// grammar sees as lists, such as `(tuple a b)` or `` `#(,a ,b) ``.
|
|
1752
|
+
function letNames(state, form, pos, add) {
|
|
1753
|
+
const bindings = form.getChild("Bindings");
|
|
1754
|
+
if (!bindings)
|
|
1755
|
+
return;
|
|
1756
|
+
for (const binding of partsOf(bindings)) {
|
|
1757
|
+
if (binding.name != "BoundList")
|
|
1758
|
+
continue;
|
|
1759
|
+
const pattern = partsOf(binding)[0];
|
|
1760
|
+
if (!pattern || pattern.name == "LocalName" || touches(pattern, pos))
|
|
1761
|
+
continue;
|
|
1762
|
+
const names = [];
|
|
1763
|
+
patternNames(state, pattern, names);
|
|
1764
|
+
addVariables(names, add);
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
// `(lc ((<- x xs) (<= (binary (b (size 8))) bin) guard) body)`: the
|
|
1768
|
+
// generators bind their patterns in the rest of the comprehension.
|
|
1769
|
+
function comprehensionNames(state, form, pos, add) {
|
|
1770
|
+
const qualifiers = partsOf(form)[1];
|
|
1771
|
+
if (!qualifiers || qualifiers.name != "List")
|
|
1772
|
+
return;
|
|
1773
|
+
for (const qualifier of partsOf(qualifiers)) {
|
|
1774
|
+
if (qualifier.name != "List")
|
|
1775
|
+
continue;
|
|
1776
|
+
const [arrow, pattern] = partsOf(qualifier);
|
|
1777
|
+
if (!arrow || !pattern || !["<-", "<="].includes(text(state, arrow)) || touches(pattern, pos))
|
|
1778
|
+
continue;
|
|
1779
|
+
const names = [];
|
|
1780
|
+
patternNames(state, pattern, names);
|
|
1781
|
+
addVariables(names, add);
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
// The names in a clause's patterns that the grammar leaves as symbols, such
|
|
1785
|
+
// as `v` in `` (`#(ok ,v) v) ``.
|
|
1786
|
+
function clausePatternNames(state, clause, pos, add) {
|
|
1787
|
+
const patterns = clause.getChild("Patterns");
|
|
1788
|
+
if (!patterns || touches(patterns, pos))
|
|
1789
|
+
return;
|
|
1790
|
+
const names = [];
|
|
1791
|
+
patternNames(state, patterns, names);
|
|
1792
|
+
addVariables(names, add);
|
|
1793
|
+
}
|
|
1794
|
+
// `(defrecord person name (age 0))` writes `make-person`, `is-person`,
|
|
1795
|
+
// `match-person`, `update-person`, and `person-name` and `set-person-name`
|
|
1796
|
+
// for each field.
|
|
1797
|
+
function recordNames(state, form, add) {
|
|
1798
|
+
const parts = partsOf(form).slice(1);
|
|
1799
|
+
if (!parts.length || parts[0].name != "Definition")
|
|
1800
|
+
return;
|
|
1801
|
+
const name = text(state, parts[0]);
|
|
1802
|
+
add({ label: "make-" + name, type: "function", detail: "constructor" });
|
|
1803
|
+
add({ label: "is-" + name, type: "function" });
|
|
1804
|
+
add({ label: "match-" + name, type: "function", detail: "pattern" });
|
|
1805
|
+
add({ label: "update-" + name, type: "function" });
|
|
1806
|
+
for (const field of parts.slice(1)) {
|
|
1807
|
+
const fieldName = field.name == "Symbol" ? field : field.name == "List" ? headOf(field) : null;
|
|
1808
|
+
if (!fieldName || (fieldName.name != "Symbol" && fieldName.name != "Callee"))
|
|
1809
|
+
continue;
|
|
1810
|
+
const label = text(state, fieldName);
|
|
1811
|
+
add({ label: name + "-" + label, type: "function", detail: "field" });
|
|
1812
|
+
add({ label: "set-" + name + "-" + label, type: "function", detail: "field" });
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
const clauseForms = /*@__PURE__*/new Set(["case", "receive"]);
|
|
1816
|
+
const comprehensions = /*@__PURE__*/new Set(["lc", "list-comp", "bc", "binary-comp"]);
|
|
1817
|
+
/**
|
|
1818
|
+
Completes the names declared in the file that are in scope at the cursor.
|
|
1819
|
+
On top of the names the grammar marks, it offers the variables bound by
|
|
1820
|
+
patterns in clauses, `case`, `receive`, `try`, `let` and comprehensions,
|
|
1821
|
+
and the functions written by `defrecord`.
|
|
1822
|
+
*/
|
|
1823
|
+
const lfeLocals = /*@__PURE__*/localsSource((state, pos, add) => {
|
|
1824
|
+
eachForm(state, (form, head, kind) => {
|
|
1825
|
+
if (head.name == "Definer" && kind == "defrecord")
|
|
1826
|
+
recordNames(state, form, add);
|
|
1827
|
+
if (!contains(form, pos))
|
|
1828
|
+
return;
|
|
1829
|
+
if (head.name == "SpecialForm" && clauseForms.has(kind)) {
|
|
1830
|
+
clauseNames(state, partsOf(form).slice(kind == "case" ? 2 : 1), pos, add);
|
|
1831
|
+
}
|
|
1832
|
+
else if (head.name == "SpecialForm" && kind == "catch" && form.parent && lower(state, headOf(form.parent)) == "try") {
|
|
1833
|
+
clauseNames(state, partsOf(form).slice(1), pos, add);
|
|
1834
|
+
}
|
|
1835
|
+
else if (head.name == "Binder" && (kind == "let" || kind == "let*")) {
|
|
1836
|
+
letNames(state, form, pos, add);
|
|
1837
|
+
}
|
|
1838
|
+
else if (head.name == "SpecialForm" && comprehensions.has(kind)) {
|
|
1839
|
+
comprehensionNames(state, form, pos, add);
|
|
1840
|
+
}
|
|
1841
|
+
});
|
|
1842
|
+
// The clauses of `defun`, `match-lambda` and `fletrec` around the cursor.
|
|
1843
|
+
for (let node = syntaxTree(state).resolveInner(pos, -1); node; node = node.parent) {
|
|
1844
|
+
if (node.name == "Clause")
|
|
1845
|
+
clausePatternNames(state, node, pos, add);
|
|
1846
|
+
}
|
|
1847
|
+
});
|
|
1848
|
+
/**
|
|
1849
|
+
Every LFE completion source: the built-ins, the functions of Erlang
|
|
1850
|
+
modules, snippets, and the names declared in the file.
|
|
1851
|
+
*/
|
|
1852
|
+
const lfeCompletion = [lfeBuiltins, lfeModuleFunctions, lfeLocals];
|
|
1853
|
+
/**
|
|
1854
|
+
Lisp Flavoured Erlang language support: the shared Lisp grammar in its
|
|
1855
|
+
`lfe` dialect, with completion for LFE.
|
|
1856
|
+
*/
|
|
1857
|
+
function lfe() {
|
|
1858
|
+
return dialectSupport(lfeCompletion, lfeLanguage);
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
export { commonLisp, commonLispBuiltins, commonLispCompletion, commonLispLocals, declaredNames, emacsLisp, emacsLispBuiltins, emacsLispCompletion, emacsLispLocals, lfe, lfeBuiltins, lfeCompletion, lfeLanguage, lfeLocals, lfeModuleFunctions, lisp, lispCompletion, lispLanguage, localCompletionSource, parser, patternNames };
|