kei-lisp 2.0.0 → 2.1.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/README.md +30 -14
- package/dist/cli.cjs +2442 -3020
- package/dist/cli.d.cts +1 -0
- package/dist/index.cjs +2441 -2899
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +402 -328
- package/dist/index.d.ts +402 -328
- package/dist/index.js +2412 -2890
- package/dist/index.js.map +1 -1
- package/package.json +27 -30
package/dist/index.d.ts
CHANGED
|
@@ -1,198 +1,6 @@
|
|
|
1
|
-
import { Interface } from
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @class
|
|
5
|
-
* @classdesc Iterator class for Cons.
|
|
6
|
-
* @author Keisuke Ikeda
|
|
7
|
-
* @this {Loop}
|
|
8
|
-
*/
|
|
9
|
-
declare class Loop {
|
|
10
|
-
aCons: Cons;
|
|
11
|
-
length: number;
|
|
12
|
-
index: number;
|
|
13
|
-
/**
|
|
14
|
-
* Constructor.
|
|
15
|
-
* @param aCons the Cons to iterate over
|
|
16
|
-
*/
|
|
17
|
-
constructor(aCons: Cons);
|
|
18
|
-
/**
|
|
19
|
-
* Returns this instance.
|
|
20
|
-
*/
|
|
21
|
-
iterator(): this;
|
|
22
|
-
/**
|
|
23
|
-
* Returns whether a next element exists.
|
|
24
|
-
*/
|
|
25
|
-
hasNext(): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Returns the next element.
|
|
28
|
-
*/
|
|
29
|
-
next(): LispValue;
|
|
30
|
-
/**
|
|
31
|
-
* Implementation of the iterable protocol.
|
|
32
|
-
* Enables iteration with for...of and similar constructs.
|
|
33
|
-
*/
|
|
34
|
-
[Symbol.iterator](): Iterator<LispValue>;
|
|
35
|
-
/**
|
|
36
|
-
* Implementation of the async iterable protocol.
|
|
37
|
-
* Enables iteration with for await...of and similar constructs.
|
|
38
|
-
*/
|
|
39
|
-
[Symbol.asyncIterator](): AsyncIterator<LispValue>;
|
|
40
|
-
/**
|
|
41
|
-
* Advances to the next element.
|
|
42
|
-
*/
|
|
43
|
-
remove(): null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @class
|
|
48
|
-
* @classdesc Class that mimics a Cons cell.
|
|
49
|
-
* @author Keisuke Ikeda
|
|
50
|
-
* @this {Cons}
|
|
51
|
-
*/
|
|
52
|
-
declare class Cons {
|
|
53
|
-
static readonly nil: Cons;
|
|
54
|
-
car: LispValue;
|
|
55
|
-
cdr: LispValue;
|
|
56
|
-
/**
|
|
57
|
-
* Constructor.
|
|
58
|
-
* @constructor
|
|
59
|
-
* @param car the car; defaults to nil when no argument is given.
|
|
60
|
-
* @param cdr the cdr; defaults to nil when no argument is given.
|
|
61
|
-
*/
|
|
62
|
-
constructor(car?: LispValue, cdr?: LispValue);
|
|
63
|
-
/**
|
|
64
|
-
* Appends the given element to the end of this Cons.
|
|
65
|
-
* @param anObject the object to append
|
|
66
|
-
* @return the Cons with the element appended
|
|
67
|
-
*/
|
|
68
|
-
add(anObject: LispValue): this;
|
|
69
|
-
/**
|
|
70
|
-
* Clones this Cons and returns the clone.
|
|
71
|
-
* @return the cloned Cons
|
|
72
|
-
*/
|
|
73
|
-
clone(): Cons;
|
|
74
|
-
/**
|
|
75
|
-
* Clones the given value (a Cons element) and returns the clone.
|
|
76
|
-
* @param value a Cons element
|
|
77
|
-
* @return the cloned element
|
|
78
|
-
*/
|
|
79
|
-
static cloneValue(value: LispValue): LispValue;
|
|
80
|
-
/**
|
|
81
|
-
* Returns whether this Cons equals the given object.
|
|
82
|
-
* @param anObject the object to compare against
|
|
83
|
-
* @return a boolean
|
|
84
|
-
*/
|
|
85
|
-
equals(anObject: LispValue): boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Returns whether both arguments are Cons cells and are equal.
|
|
88
|
-
* @param left the object to compare
|
|
89
|
-
* @param right the object to compare
|
|
90
|
-
* @return a boolean
|
|
91
|
-
*/
|
|
92
|
-
equalsAUX(left: LispValue, right: LispValue): boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Returns whether the given argument is an Atom.
|
|
95
|
-
*/
|
|
96
|
-
static isAtom(anObject: LispValue): boolean;
|
|
97
|
-
/**
|
|
98
|
-
* Returns whether the given argument is a Cons.
|
|
99
|
-
*/
|
|
100
|
-
static isCons(anObject: LispValue): anObject is Cons;
|
|
101
|
-
/**
|
|
102
|
-
* Returns whether the given argument is a List.
|
|
103
|
-
*/
|
|
104
|
-
static isList(anObject: LispValue): boolean;
|
|
105
|
-
/**
|
|
106
|
-
* Returns whether the given argument is Nil.
|
|
107
|
-
*/
|
|
108
|
-
static isNil(anObject: LispValue): boolean;
|
|
109
|
-
/**
|
|
110
|
-
* Returns whether the given argument is not a Cons.
|
|
111
|
-
*/
|
|
112
|
-
static isNotCons(anObject: LispValue): boolean;
|
|
113
|
-
/**
|
|
114
|
-
* Returns whether the given argument is not a List.
|
|
115
|
-
*/
|
|
116
|
-
static isNotList(anObject: LispValue): boolean;
|
|
117
|
-
/**
|
|
118
|
-
* Returns whether the given argument is not Nil.
|
|
119
|
-
*/
|
|
120
|
-
static isNotNil(anObject: LispValue): boolean;
|
|
121
|
-
/**
|
|
122
|
-
* Returns whether the given argument is not an interpreted symbol.
|
|
123
|
-
*/
|
|
124
|
-
static isNotSymbol(anObject: LispValue): boolean;
|
|
125
|
-
/**
|
|
126
|
-
* Returns whether the given argument is a number.
|
|
127
|
-
*/
|
|
128
|
-
static isNumber(anObject: LispValue): anObject is number;
|
|
129
|
-
/**
|
|
130
|
-
* Returns whether the given argument is a string.
|
|
131
|
-
*/
|
|
132
|
-
static isString(anObject: LispValue): anObject is string;
|
|
133
|
-
/**
|
|
134
|
-
* Returns whether the given argument is an interpreted symbol.
|
|
135
|
-
*/
|
|
136
|
-
static isSymbol(anObject: LispValue): anObject is InterpretedSymbol;
|
|
137
|
-
/**
|
|
138
|
-
* Returns whether the given argument is an environment.
|
|
139
|
-
*/
|
|
140
|
-
static isTable(anObject: LispValue): anObject is Table;
|
|
141
|
-
/**
|
|
142
|
-
* Returns the last cell of this Cons.
|
|
143
|
-
* @return this Cons's last cell
|
|
144
|
-
*/
|
|
145
|
-
last(): Cons;
|
|
146
|
-
/**
|
|
147
|
-
* Returns an iterator over this Cons.
|
|
148
|
-
* @return an iterator over this Cons
|
|
149
|
-
*/
|
|
150
|
-
loop(): Loop;
|
|
151
|
-
/**
|
|
152
|
-
* Returns the length (depth) of this Cons.
|
|
153
|
-
* @return the length (depth) of this Cons
|
|
154
|
-
*/
|
|
155
|
-
length(): number;
|
|
156
|
-
/**
|
|
157
|
-
* Concatenates the given Cons and returns this Cons.
|
|
158
|
-
* @param aCons the Cons to concatenate
|
|
159
|
-
* @return this Cons
|
|
160
|
-
*/
|
|
161
|
-
nconc(aCons: Cons): this;
|
|
162
|
-
/**
|
|
163
|
-
* Returns the nth element of this Cons.
|
|
164
|
-
* @param aNumber the index to retrieve
|
|
165
|
-
* @return the element at the given index
|
|
166
|
-
*/
|
|
167
|
-
nth(aNumber: number): LispValue;
|
|
168
|
-
/**
|
|
169
|
-
* Lexes the given string into a Cons and returns it.
|
|
170
|
-
* @param aString the string to lex
|
|
171
|
-
*/
|
|
172
|
-
static parse(aString: string): LispValue;
|
|
173
|
-
/**
|
|
174
|
-
* Sets the car.
|
|
175
|
-
*/
|
|
176
|
-
setCar(anObject: LispValue): null;
|
|
177
|
-
/**
|
|
178
|
-
* Sets the cdr.
|
|
179
|
-
*/
|
|
180
|
-
setCdr(anObject: LispValue): null;
|
|
181
|
-
/**
|
|
182
|
-
* Sets both the car and the cdr.
|
|
183
|
-
*/
|
|
184
|
-
setCons(car: LispValue, cdr: LispValue): this;
|
|
185
|
-
/**
|
|
186
|
-
* Returns a formatted string representation of this Cons.
|
|
187
|
-
*/
|
|
188
|
-
toString(): string;
|
|
189
|
-
/**
|
|
190
|
-
* Returns a formatted string representation of the given object.
|
|
191
|
-
* @param anObject the object to format
|
|
192
|
-
*/
|
|
193
|
-
static toString(anObject: LispValue): string;
|
|
194
|
-
}
|
|
1
|
+
import { Interface } from "node:readline";
|
|
195
2
|
|
|
3
|
+
//#region src/types/index.d.ts
|
|
196
4
|
/**
|
|
197
5
|
* Union of every value the interpreter can store or evaluate.
|
|
198
6
|
*
|
|
@@ -203,7 +11,8 @@ declare class Cons {
|
|
|
203
11
|
* - `null` — internal sentinel, distinct from Lisp `nil` (which is `Cons.nil`)
|
|
204
12
|
*/
|
|
205
13
|
type LispValue = Cons | InterpretedSymbol | Table | number | string | null;
|
|
206
|
-
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/runtime/Table/index.d.ts
|
|
207
16
|
/**
|
|
208
17
|
* @class
|
|
209
18
|
* @classdesc Class that manages bindings of interpreted symbols.
|
|
@@ -211,52 +20,53 @@ type LispValue = Cons | InterpretedSymbol | Table | number | string | null;
|
|
|
211
20
|
* @this {Table}
|
|
212
21
|
*/
|
|
213
22
|
declare class Table extends Map<unknown, LispValue> {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
23
|
+
source: Table | null;
|
|
24
|
+
root: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Constructor.
|
|
27
|
+
* @param aTable the environment in which this environment was created
|
|
28
|
+
*/
|
|
29
|
+
constructor(aTable?: Table | null);
|
|
30
|
+
/**
|
|
31
|
+
* Clones this Table and returns the clone.
|
|
32
|
+
*/
|
|
33
|
+
clone(): Table;
|
|
34
|
+
/**
|
|
35
|
+
* Returns whether anything is bound to the given property (key).
|
|
36
|
+
*/
|
|
37
|
+
has(aSymbol: unknown): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Returns whether this instance equals the given object.
|
|
40
|
+
*/
|
|
41
|
+
equals(anObject: unknown): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the value bound to the given interpreted symbol.
|
|
44
|
+
*/
|
|
45
|
+
get(aSymbol: unknown): LispValue;
|
|
46
|
+
/**
|
|
47
|
+
* Returns whether this instance is the root of the environment chain.
|
|
48
|
+
*/
|
|
49
|
+
isRoot(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Reassigns the symbol bound in the innermost scope (equivalent to Common Lisp's setq).
|
|
52
|
+
* If a binding exists in the current scope, update it and return; otherwise recurse into the parent scope.
|
|
53
|
+
*/
|
|
54
|
+
setIfExist(aSymbol: unknown, anObject: LispValue): LispValue;
|
|
55
|
+
/**
|
|
56
|
+
* Sets whether this instance is the root of its environment chain.
|
|
57
|
+
*/
|
|
58
|
+
setRoot(aBoolean: boolean): null;
|
|
59
|
+
/**
|
|
60
|
+
* Sets the parent environment.
|
|
61
|
+
*/
|
|
62
|
+
setSource(aTable: Table | null): null;
|
|
63
|
+
/**
|
|
64
|
+
* Returns a formatted string representation of this instance.
|
|
65
|
+
*/
|
|
66
|
+
toString(): string;
|
|
258
67
|
}
|
|
259
|
-
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/value/InterpretedSymbol/index.d.ts
|
|
260
70
|
/**
|
|
261
71
|
* @class
|
|
262
72
|
* @classdesc Interpreted symbol with uniqueness, where each printed name maps to a single canonical instance (identity equals equality). A class that mimics canonical strings, distinct from JS's standard Symbol.
|
|
@@ -264,35 +74,231 @@ declare class Table extends Map<unknown, LispValue> {
|
|
|
264
74
|
* @this {InterpretedSymbol}
|
|
265
75
|
*/
|
|
266
76
|
declare class InterpretedSymbol {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
77
|
+
#private;
|
|
78
|
+
static get table(): Table;
|
|
79
|
+
name: string;
|
|
80
|
+
/**
|
|
81
|
+
* Constructor.
|
|
82
|
+
* @param name printed name
|
|
83
|
+
*/
|
|
84
|
+
constructor(name?: string);
|
|
85
|
+
/**
|
|
86
|
+
* Compares this interpreted symbol with the given one by printed name.
|
|
87
|
+
* @param aSymbol the symbol to compare against
|
|
88
|
+
* @return the difference in string length
|
|
89
|
+
*/
|
|
90
|
+
compareTo(aSymbol: InterpretedSymbol): number;
|
|
91
|
+
/**
|
|
92
|
+
* Returns whether this symbol equals the given object.
|
|
93
|
+
*/
|
|
94
|
+
equals(anObject: unknown): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Returns the same interpreted symbol for a given printed name.
|
|
97
|
+
* @param aString printed name
|
|
98
|
+
*/
|
|
99
|
+
static of(aString: string): InterpretedSymbol;
|
|
100
|
+
/**
|
|
101
|
+
* Returns the string representation of this symbol.
|
|
102
|
+
*/
|
|
103
|
+
toString(): string;
|
|
294
104
|
}
|
|
295
|
-
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region src/value/Loop/index.d.ts
|
|
107
|
+
/**
|
|
108
|
+
* @class
|
|
109
|
+
* @classdesc Iterator class for Cons.
|
|
110
|
+
* @author Keisuke Ikeda
|
|
111
|
+
* @this {Loop}
|
|
112
|
+
*/
|
|
113
|
+
declare class Loop {
|
|
114
|
+
aCons: Cons;
|
|
115
|
+
length: number;
|
|
116
|
+
index: number;
|
|
117
|
+
/**
|
|
118
|
+
* Constructor.
|
|
119
|
+
* @param aCons the Cons to iterate over
|
|
120
|
+
*/
|
|
121
|
+
constructor(aCons: Cons);
|
|
122
|
+
/**
|
|
123
|
+
* Returns this instance.
|
|
124
|
+
*/
|
|
125
|
+
iterator(): this;
|
|
126
|
+
/**
|
|
127
|
+
* Returns whether a next element exists.
|
|
128
|
+
*/
|
|
129
|
+
hasNext(): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Returns the next element.
|
|
132
|
+
*/
|
|
133
|
+
next(): LispValue;
|
|
134
|
+
/**
|
|
135
|
+
* Implementation of the iterable protocol.
|
|
136
|
+
* Enables iteration with for...of and similar constructs.
|
|
137
|
+
*/
|
|
138
|
+
[Symbol.iterator](): Iterator<LispValue>;
|
|
139
|
+
/**
|
|
140
|
+
* Implementation of the async iterable protocol.
|
|
141
|
+
* Enables iteration with for await...of and similar constructs.
|
|
142
|
+
*/
|
|
143
|
+
[Symbol.asyncIterator](): AsyncIterator<LispValue>;
|
|
144
|
+
/**
|
|
145
|
+
* Advances to the next element.
|
|
146
|
+
*/
|
|
147
|
+
remove(): null;
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/value/Cons/index.d.ts
|
|
151
|
+
/**
|
|
152
|
+
* @class
|
|
153
|
+
* @classdesc Class that mimics a Cons cell.
|
|
154
|
+
* @author Keisuke Ikeda
|
|
155
|
+
* @this {Cons}
|
|
156
|
+
*/
|
|
157
|
+
declare class Cons {
|
|
158
|
+
static readonly nil: Cons;
|
|
159
|
+
car: LispValue;
|
|
160
|
+
cdr: LispValue;
|
|
161
|
+
/**
|
|
162
|
+
* Constructor.
|
|
163
|
+
* @constructor
|
|
164
|
+
* @param car the car; defaults to nil when no argument is given.
|
|
165
|
+
* @param cdr the cdr; defaults to nil when no argument is given.
|
|
166
|
+
*/
|
|
167
|
+
constructor(car?: LispValue, cdr?: LispValue);
|
|
168
|
+
/**
|
|
169
|
+
* Appends the given element to the end of this Cons.
|
|
170
|
+
* @param anObject the object to append
|
|
171
|
+
* @return the Cons with the element appended
|
|
172
|
+
*/
|
|
173
|
+
add(anObject: LispValue): this;
|
|
174
|
+
/**
|
|
175
|
+
* Clones this Cons and returns the clone.
|
|
176
|
+
* @return the cloned Cons
|
|
177
|
+
*/
|
|
178
|
+
clone(): Cons;
|
|
179
|
+
/**
|
|
180
|
+
* Clones the given value (a Cons element) and returns the clone.
|
|
181
|
+
* @param value a Cons element
|
|
182
|
+
* @return the cloned element
|
|
183
|
+
*/
|
|
184
|
+
static cloneValue(value: LispValue): LispValue;
|
|
185
|
+
/**
|
|
186
|
+
* Returns whether this Cons equals the given object.
|
|
187
|
+
* @param anObject the object to compare against
|
|
188
|
+
* @return a boolean
|
|
189
|
+
*/
|
|
190
|
+
equals(anObject: LispValue): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Returns whether both arguments are Cons cells and are equal.
|
|
193
|
+
* @param left the object to compare
|
|
194
|
+
* @param right the object to compare
|
|
195
|
+
* @return a boolean
|
|
196
|
+
*/
|
|
197
|
+
equalsAUX(left: LispValue, right: LispValue): boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Returns whether the given argument is an Atom.
|
|
200
|
+
*/
|
|
201
|
+
static isAtom(anObject: LispValue): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Returns whether the given argument is a Cons.
|
|
204
|
+
*/
|
|
205
|
+
static isCons(anObject: LispValue): anObject is Cons;
|
|
206
|
+
/**
|
|
207
|
+
* Returns whether the given argument is a List.
|
|
208
|
+
*/
|
|
209
|
+
static isList(anObject: LispValue): boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Returns whether the given argument is Nil.
|
|
212
|
+
*/
|
|
213
|
+
static isNil(anObject: LispValue): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Returns whether the given argument is not a Cons.
|
|
216
|
+
*/
|
|
217
|
+
static isNotCons(anObject: LispValue): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Returns whether the given argument is not a List.
|
|
220
|
+
*/
|
|
221
|
+
static isNotList(anObject: LispValue): boolean;
|
|
222
|
+
/**
|
|
223
|
+
* Returns whether the given argument is not Nil.
|
|
224
|
+
*/
|
|
225
|
+
static isNotNil(anObject: LispValue): boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Returns whether the given argument is not an interpreted symbol.
|
|
228
|
+
*/
|
|
229
|
+
static isNotSymbol(anObject: LispValue): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Returns whether the given argument is a number.
|
|
232
|
+
*/
|
|
233
|
+
static isNumber(anObject: LispValue): anObject is number;
|
|
234
|
+
/**
|
|
235
|
+
* Returns whether the given argument is a string.
|
|
236
|
+
*/
|
|
237
|
+
static isString(anObject: LispValue): anObject is string;
|
|
238
|
+
/**
|
|
239
|
+
* Returns whether the given argument is an interpreted symbol.
|
|
240
|
+
*/
|
|
241
|
+
static isSymbol(anObject: LispValue): anObject is InterpretedSymbol;
|
|
242
|
+
/**
|
|
243
|
+
* Returns whether the given argument is an environment.
|
|
244
|
+
*/
|
|
245
|
+
static isTable(anObject: LispValue): anObject is Table;
|
|
246
|
+
/**
|
|
247
|
+
* Returns the last cell of this Cons.
|
|
248
|
+
* @return this Cons's last cell
|
|
249
|
+
*/
|
|
250
|
+
last(): Cons;
|
|
251
|
+
/**
|
|
252
|
+
* Returns an iterator over this Cons.
|
|
253
|
+
* @return an iterator over this Cons
|
|
254
|
+
*/
|
|
255
|
+
loop(): Loop;
|
|
256
|
+
/**
|
|
257
|
+
* Returns the length (depth) of this Cons.
|
|
258
|
+
* @return the length (depth) of this Cons
|
|
259
|
+
*/
|
|
260
|
+
length(): number;
|
|
261
|
+
/**
|
|
262
|
+
* Concatenates the given Cons and returns this Cons.
|
|
263
|
+
* @param aCons the Cons to concatenate
|
|
264
|
+
* @return this Cons
|
|
265
|
+
*/
|
|
266
|
+
nconc(aCons: Cons): this;
|
|
267
|
+
/**
|
|
268
|
+
* Returns the nth element of this Cons.
|
|
269
|
+
* @param aNumber the index to retrieve
|
|
270
|
+
* @return the element at the given index
|
|
271
|
+
*/
|
|
272
|
+
nth(aNumber: number): LispValue;
|
|
273
|
+
/**
|
|
274
|
+
* Lexes the given string into a Cons and returns it.
|
|
275
|
+
* @param aString the string to lex
|
|
276
|
+
*/
|
|
277
|
+
static parse(aString: string): LispValue;
|
|
278
|
+
/**
|
|
279
|
+
* Sets the car.
|
|
280
|
+
*/
|
|
281
|
+
setCar(anObject: LispValue): null;
|
|
282
|
+
/**
|
|
283
|
+
* Sets the cdr.
|
|
284
|
+
*/
|
|
285
|
+
setCdr(anObject: LispValue): null;
|
|
286
|
+
/**
|
|
287
|
+
* Sets both the car and the cdr.
|
|
288
|
+
*/
|
|
289
|
+
setCons(car: LispValue, cdr: LispValue): this;
|
|
290
|
+
/**
|
|
291
|
+
* Returns a formatted string representation of this Cons.
|
|
292
|
+
*/
|
|
293
|
+
toString(): string;
|
|
294
|
+
/**
|
|
295
|
+
* Returns a formatted string representation of the given object.
|
|
296
|
+
* @param anObject the object to format
|
|
297
|
+
*/
|
|
298
|
+
static toString(anObject: LispValue): string;
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/runtime/StreamManager/index.d.ts
|
|
296
302
|
type Stream = NodeJS.WritableStream | null;
|
|
297
303
|
/**
|
|
298
304
|
* @class
|
|
@@ -301,27 +307,28 @@ type Stream = NodeJS.WritableStream | null;
|
|
|
301
307
|
* @this {StreamManager}
|
|
302
308
|
*/
|
|
303
309
|
declare class StreamManager {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
310
|
+
isTrace: boolean;
|
|
311
|
+
streamTable: Map<string, Stream>;
|
|
312
|
+
spyTable: Map<InterpretedSymbol, string>;
|
|
313
|
+
traceStream: Stream;
|
|
314
|
+
constructor();
|
|
315
|
+
getStream(): Stream;
|
|
316
|
+
/**
|
|
317
|
+
* Initializes the instance variables.
|
|
318
|
+
*/
|
|
319
|
+
initialize(): null;
|
|
320
|
+
isSpy(aSymbol: InterpretedSymbol | null): boolean;
|
|
321
|
+
noSpy(aSymbol: InterpretedSymbol): null;
|
|
322
|
+
noTrace(): null;
|
|
323
|
+
setIsTrace(aBoolean: boolean): null;
|
|
324
|
+
setTraceStream(aStream: Stream): null;
|
|
325
|
+
spy(aSymbol: InterpretedSymbol, aString: string): null;
|
|
326
|
+
spyStream(aSymbol: InterpretedSymbol | null): Stream | string;
|
|
327
|
+
spyTable_(): Map<InterpretedSymbol, string>;
|
|
328
|
+
trace(): null;
|
|
323
329
|
}
|
|
324
|
-
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/interpreter/LispInterpreter/index.d.ts
|
|
325
332
|
/**
|
|
326
333
|
* @class
|
|
327
334
|
* @classdesc Class for the interpreter.
|
|
@@ -329,40 +336,90 @@ declare class StreamManager {
|
|
|
329
336
|
* @this {LispInterpreter}
|
|
330
337
|
*/
|
|
331
338
|
declare class LispInterpreter {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
339
|
+
root: Table;
|
|
340
|
+
streamManager: StreamManager;
|
|
341
|
+
constructor();
|
|
342
|
+
/**
|
|
343
|
+
* Evaluates the given expression and returns the result. Throws `ParseError`,
|
|
344
|
+
* `EvalError`, or `ExitError` on failure; library users are expected to catch
|
|
345
|
+
* these (see the `KeiLispError` base class for the parse/eval family).
|
|
346
|
+
*/
|
|
347
|
+
eval(aCons: LispValue): LispValue;
|
|
348
|
+
/**
|
|
349
|
+
* Parses the source string, evaluates every expression it contains, and returns the results as an array.
|
|
350
|
+
*/
|
|
351
|
+
evalAll(source: string): LispValue[];
|
|
352
|
+
/**
|
|
353
|
+
* Parses and evaluates the source string and returns the value of the last expression.
|
|
354
|
+
*/
|
|
355
|
+
evalString(source: string): LispValue;
|
|
356
|
+
/**
|
|
357
|
+
* Parses the given string into a list of top-level expressions and returns
|
|
358
|
+
* it. The result is always a `Cons` (possibly `Cons.nil` for empty input)
|
|
359
|
+
* because the source is wrapped in an outer list before parsing. Throws
|
|
360
|
+
* `ParseError` if the source cannot be parsed.
|
|
361
|
+
*/
|
|
362
|
+
parse(aString: string): Cons;
|
|
363
|
+
/**
|
|
364
|
+
* Sets the given environment as the root of the environment chain.
|
|
365
|
+
*/
|
|
366
|
+
setRoot(environment: Table): null;
|
|
367
|
+
/**
|
|
368
|
+
* Initializes the environment table.
|
|
369
|
+
*/
|
|
370
|
+
initializeTable(): Table;
|
|
364
371
|
}
|
|
365
|
-
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region src/interpreter/Repl/index.d.ts
|
|
374
|
+
/**
|
|
375
|
+
* @class
|
|
376
|
+
* @classdesc Interactive REPL wrapper around LispInterpreter. Handles line accumulation, parenthesis balancing, and prompt I/O.
|
|
377
|
+
* @author Keisuke Ikeda
|
|
378
|
+
* @this {Repl}
|
|
379
|
+
*/
|
|
380
|
+
declare class Repl {
|
|
381
|
+
interpreter: LispInterpreter;
|
|
382
|
+
rl: Interface;
|
|
383
|
+
constructor(interpreter?: LispInterpreter);
|
|
384
|
+
/**
|
|
385
|
+
* Starts the REPL loop.
|
|
386
|
+
*/
|
|
387
|
+
run(): void;
|
|
388
|
+
}
|
|
389
|
+
//#endregion
|
|
390
|
+
//#region src/errors/KeiLispError/index.d.ts
|
|
391
|
+
/**
|
|
392
|
+
* @class
|
|
393
|
+
* @classdesc Base class for all errors raised by kei-lisp during parsing or evaluation. Catch this to handle any Lisp-level failure without intercepting an unrelated runtime error or an `ExitError` (which signals a graceful `(exit)` and is intentionally not a subclass).
|
|
394
|
+
* @author Keisuke Ikeda
|
|
395
|
+
* @this {KeiLispError}
|
|
396
|
+
*/
|
|
397
|
+
declare class KeiLispError extends Error {
|
|
398
|
+
/**
|
|
399
|
+
* Constructor.
|
|
400
|
+
* @constructor
|
|
401
|
+
* @param message human-readable diagnostic message
|
|
402
|
+
*/
|
|
403
|
+
constructor(message: string);
|
|
404
|
+
}
|
|
405
|
+
//#endregion
|
|
406
|
+
//#region src/errors/EvalError/index.d.ts
|
|
407
|
+
/**
|
|
408
|
+
* @class
|
|
409
|
+
* @classdesc Error raised when evaluation or application of a Lisp expression fails (type mismatch, unbound symbol, arity error, etc.). Subclass of `KeiLispError`.
|
|
410
|
+
* @author Keisuke Ikeda
|
|
411
|
+
* @this {EvalError}
|
|
412
|
+
*/
|
|
413
|
+
declare class EvalError extends KeiLispError {
|
|
414
|
+
/**
|
|
415
|
+
* Constructor.
|
|
416
|
+
* @constructor
|
|
417
|
+
* @param message human-readable diagnostic message
|
|
418
|
+
*/
|
|
419
|
+
constructor(message: string);
|
|
420
|
+
}
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/errors/ExitError/index.d.ts
|
|
366
423
|
/**
|
|
367
424
|
* @class
|
|
368
425
|
* @classdesc Error class representing a graceful exit triggered by a Lisp (exit) call. Catch it at the REPL or library boundary to run cleanup before terminating.
|
|
@@ -370,11 +427,28 @@ declare class LispInterpreter {
|
|
|
370
427
|
* @this {ExitError}
|
|
371
428
|
*/
|
|
372
429
|
declare class ExitError extends Error {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
430
|
+
/**
|
|
431
|
+
* Constructor.
|
|
432
|
+
* @constructor
|
|
433
|
+
*/
|
|
434
|
+
constructor();
|
|
378
435
|
}
|
|
379
|
-
|
|
380
|
-
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region src/errors/ParseError/index.d.ts
|
|
438
|
+
/**
|
|
439
|
+
* @class
|
|
440
|
+
* @classdesc Error raised when the parser cannot turn a source string into an AST. Subclass of `KeiLispError`.
|
|
441
|
+
* @author Keisuke Ikeda
|
|
442
|
+
* @this {ParseError}
|
|
443
|
+
*/
|
|
444
|
+
declare class ParseError extends KeiLispError {
|
|
445
|
+
/**
|
|
446
|
+
* Constructor.
|
|
447
|
+
* @constructor
|
|
448
|
+
* @param message human-readable diagnostic message
|
|
449
|
+
*/
|
|
450
|
+
constructor(message: string);
|
|
451
|
+
}
|
|
452
|
+
//#endregion
|
|
453
|
+
export { Cons, EvalError, ExitError, InterpretedSymbol, KeiLispError, LispInterpreter, type LispValue, ParseError, Repl };
|
|
454
|
+
//# sourceMappingURL=index.d.ts.map
|