kei-lisp 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -20,48 +20,70 @@ type LispValue = Cons | InterpretedSymbol | Table | number | string | null;
20
20
  * @this {Table}
21
21
  */
22
22
  declare class Table extends Map<unknown, LispValue> {
23
+ /**
24
+ * The enclosing (parent) environment, or null when this is the root.
25
+ */
23
26
  source: Table | null;
27
+ /**
28
+ * Whether this environment is the root of its chain.
29
+ */
24
30
  root: boolean;
25
31
  /**
26
32
  * Constructor.
33
+ * @constructor
27
34
  * @param aTable the environment in which this environment was created
28
35
  */
29
36
  constructor(aTable?: Table | null);
30
37
  /**
31
38
  * Clones this Table and returns the clone.
39
+ * @return the cloned Table
32
40
  */
33
41
  clone(): Table;
34
42
  /**
35
43
  * Returns whether anything is bound to the given property (key).
44
+ * @param aSymbol the symbol to look up
45
+ * @return true if a binding exists in this scope or any enclosing scope
36
46
  */
37
47
  has(aSymbol: unknown): boolean;
38
48
  /**
39
49
  * Returns whether this instance equals the given object.
50
+ * @param anObject the object to compare against
51
+ * @return true when the underlying Map.equals would return true
40
52
  */
41
53
  equals(anObject: unknown): boolean;
42
54
  /**
43
- * Returns the value bound to the given interpreted symbol.
55
+ * Returns the value bound to the given interpreted symbol, walking up the scope chain.
56
+ * @param aSymbol the symbol to look up
57
+ * @return the bound value, or null when no binding exists
44
58
  */
45
59
  get(aSymbol: unknown): LispValue;
46
60
  /**
47
61
  * Returns whether this instance is the root of the environment chain.
62
+ * @return true if this is the root environment
48
63
  */
49
64
  isRoot(): boolean;
50
65
  /**
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.
66
+ * Reassigns the symbol bound in the innermost scope (equivalent to Common Lisp's setq). If a binding exists in the current scope, update it and return; otherwise recurse into the parent scope.
67
+ * @param aSymbol the symbol to update
68
+ * @param anObject the new bound value
69
+ * @return the new bound value, or null when no enclosing scope has a binding
53
70
  */
54
71
  setIfExist(aSymbol: unknown, anObject: LispValue): LispValue;
55
72
  /**
56
73
  * Sets whether this instance is the root of its environment chain.
74
+ * @param aBoolean the new root flag
75
+ * @return null
57
76
  */
58
77
  setRoot(aBoolean: boolean): null;
59
78
  /**
60
79
  * Sets the parent environment.
80
+ * @param aTable the new parent environment (or null)
81
+ * @return null
61
82
  */
62
83
  setSource(aTable: Table | null): null;
63
84
  /**
64
85
  * Returns a formatted string representation of this instance.
86
+ * @return the formatted string
65
87
  */
66
88
  toString(): string;
67
89
  }
@@ -73,12 +95,20 @@ declare class Table extends Map<unknown, LispValue> {
73
95
  * @author Keisuke Ikeda
74
96
  * @this {InterpretedSymbol}
75
97
  */
76
- declare class InterpretedSymbol {
98
+ declare class InterpretedSymbol extends Object {
77
99
  #private;
100
+ /**
101
+ * Lazy accessor for the intern table that holds every InterpretedSymbol instance.
102
+ * @return the intern Table (created on first access)
103
+ */
78
104
  static get table(): Table;
105
+ /**
106
+ * The printed name of this symbol.
107
+ */
79
108
  name: string;
80
109
  /**
81
110
  * Constructor.
111
+ * @constructor
82
112
  * @param name printed name
83
113
  */
84
114
  constructor(name?: string);
@@ -90,15 +120,19 @@ declare class InterpretedSymbol {
90
120
  compareTo(aSymbol: InterpretedSymbol): number;
91
121
  /**
92
122
  * Returns whether this symbol equals the given object.
123
+ * @param anObject the object to compare against
124
+ * @return true when identity-equal (since intern guarantees uniqueness)
93
125
  */
94
126
  equals(anObject: unknown): boolean;
95
127
  /**
96
128
  * Returns the same interpreted symbol for a given printed name.
97
129
  * @param aString printed name
130
+ * @return the canonical InterpretedSymbol for that name
98
131
  */
99
132
  static of(aString: string): InterpretedSymbol;
100
133
  /**
101
134
  * Returns the string representation of this symbol.
135
+ * @return the printed name
102
136
  */
103
137
  toString(): string;
104
138
  }
@@ -110,39 +144,53 @@ declare class InterpretedSymbol {
110
144
  * @author Keisuke Ikeda
111
145
  * @this {Loop}
112
146
  */
113
- declare class Loop {
147
+ declare class Loop extends Object {
148
+ /**
149
+ * The Cons being iterated over.
150
+ */
114
151
  aCons: Cons;
152
+ /**
153
+ * The number of elements in the underlying Cons (computed once at construction time).
154
+ */
115
155
  length: number;
156
+ /**
157
+ * The 1-based index of the next element to return.
158
+ */
116
159
  index: number;
117
160
  /**
118
161
  * Constructor.
162
+ * @constructor
119
163
  * @param aCons the Cons to iterate over
120
164
  */
121
165
  constructor(aCons: Cons);
122
166
  /**
123
- * Returns this instance.
167
+ * Returns this instance so it can be used as its own iterator.
168
+ * @return this Loop instance
124
169
  */
125
170
  iterator(): this;
126
171
  /**
127
172
  * Returns whether a next element exists.
173
+ * @return true if there is at least one more element
128
174
  */
129
175
  hasNext(): boolean;
130
176
  /**
131
- * Returns the next element.
177
+ * Returns the next element and advances the cursor.
178
+ * @return the element at the current index
132
179
  */
133
180
  next(): LispValue;
134
181
  /**
135
- * Implementation of the iterable protocol.
136
- * Enables iteration with for...of and similar constructs.
182
+ * Implementation of the iterable protocol. Enables iteration with for...of and similar constructs.
183
+ * @return an iterator over the Cons elements
137
184
  */
138
185
  [Symbol.iterator](): Iterator<LispValue>;
139
186
  /**
140
- * Implementation of the async iterable protocol.
141
- * Enables iteration with for await...of and similar constructs.
187
+ * Implementation of the async iterable protocol. Enables iteration with for await...of and similar constructs.
188
+ * @return an async iterator over the Cons elements
142
189
  */
143
190
  [Symbol.asyncIterator](): AsyncIterator<LispValue>;
144
191
  /**
145
- * Advances to the next element.
192
+ * Advances the cursor to the next element.
193
+ * @return null
146
194
  */
147
195
  remove(): null;
148
196
  }
@@ -154,9 +202,18 @@ declare class Loop {
154
202
  * @author Keisuke Ikeda
155
203
  * @this {Cons}
156
204
  */
157
- declare class Cons {
205
+ declare class Cons extends Object {
206
+ /**
207
+ * The shared empty-list sentinel. A Cons whose car and cdr are both itself, representing Lisp `nil`.
208
+ */
158
209
  static readonly nil: Cons;
210
+ /**
211
+ * The head element of this Cons cell.
212
+ */
159
213
  car: LispValue;
214
+ /**
215
+ * The tail of this Cons cell (typically another Cons or nil).
216
+ */
160
217
  cdr: LispValue;
161
218
  /**
162
219
  * Constructor.
@@ -302,32 +359,153 @@ declare class Cons {
302
359
  type Stream = NodeJS.WritableStream | null;
303
360
  /**
304
361
  * @class
305
- * @classdesc
362
+ * @classdesc Manages output streams (stdout / stderr / spy / trace) used by the interpreter.
306
363
  * @author Keisuke Ikeda
307
364
  * @this {StreamManager}
308
365
  */
309
- declare class StreamManager {
366
+ declare class StreamManager extends Object {
367
+ /**
368
+ * Whether tracing is currently enabled.
369
+ */
310
370
  isTrace: boolean;
371
+ /**
372
+ * Map from a named stream key (e.g. "default", "stdout", "stderr") to a WritableStream.
373
+ */
311
374
  streamTable: Map<string, Stream>;
375
+ /**
376
+ * Map from a spied symbol to the stream key used for that symbol's output.
377
+ */
312
378
  spyTable: Map<InterpretedSymbol, string>;
379
+ /**
380
+ * The stream that receives trace output while tracing is on.
381
+ */
313
382
  traceStream: Stream;
383
+ /**
384
+ * Constructor.
385
+ * @constructor
386
+ */
314
387
  constructor();
388
+ /**
389
+ * Returns the currently selected output stream (trace stream when tracing, otherwise the default).
390
+ * @return the active stream, or null when none is available
391
+ */
315
392
  getStream(): Stream;
316
393
  /**
317
394
  * Initializes the instance variables.
395
+ * @return null
318
396
  */
319
397
  initialize(): null;
398
+ /**
399
+ * Returns whether the given symbol is being spied (or whether tracing is on, in which case every symbol is "spied").
400
+ * @param aSymbol the symbol to check, or null
401
+ * @return true if the symbol is spied or tracing is on
402
+ */
320
403
  isSpy(aSymbol: InterpretedSymbol | null): boolean;
404
+ /**
405
+ * Removes the given symbol from the spy table.
406
+ * @param aSymbol the symbol to stop spying
407
+ * @return null
408
+ */
321
409
  noSpy(aSymbol: InterpretedSymbol): null;
410
+ /**
411
+ * Turns tracing off and clears the spy table.
412
+ * @return null
413
+ */
322
414
  noTrace(): null;
415
+ /**
416
+ * Sets the tracing flag.
417
+ * @param aBoolean the new value for the tracing flag
418
+ * @return null
419
+ */
323
420
  setIsTrace(aBoolean: boolean): null;
421
+ /**
422
+ * Sets the trace output stream.
423
+ * @param aStream the stream to send trace output to
424
+ * @return null
425
+ */
324
426
  setTraceStream(aStream: Stream): null;
427
+ /**
428
+ * Registers the given symbol as spied with the given stream key.
429
+ * @param aSymbol the symbol to spy on
430
+ * @param aString the stream key (e.g. "default")
431
+ * @return null
432
+ */
325
433
  spy(aSymbol: InterpretedSymbol, aString: string): null;
434
+ /**
435
+ * Returns the stream (or stream-key string) used for the given symbol's spy output.
436
+ * @param aSymbol the symbol whose spy stream is requested, or null
437
+ * @return the trace stream, the registered key string, or throws if none is found
438
+ */
326
439
  spyStream(aSymbol: InterpretedSymbol | null): Stream | string;
440
+ /**
441
+ * Returns a copy of the spy table (defensive copy so callers do not mutate the internal map).
442
+ * @return a new map containing the same entries as the internal spy table
443
+ */
327
444
  spyTable_(): Map<InterpretedSymbol, string>;
445
+ /**
446
+ * Turns tracing on, routing trace output to the currently active stream.
447
+ * @return null
448
+ */
328
449
  trace(): null;
329
450
  }
330
451
  //#endregion
452
+ //#region src/plugin/types.d.ts
453
+ /**
454
+ * Context passed to a plugin's `apply` call. Holds the live interpreter state
455
+ * needed to perform recursive evaluation or to read / write the environment.
456
+ */
457
+ interface PluginContext {
458
+ /**
459
+ * The current variable binding environment.
460
+ */
461
+ environment: Table;
462
+ /**
463
+ * The stream manager that owns the interpreter's I/O / spy / trace streams.
464
+ */
465
+ streamManager: StreamManager;
466
+ /**
467
+ * The current call depth (used for spy indentation).
468
+ */
469
+ depth: number;
470
+ /**
471
+ * Re-evaluates the given form using the current environment / stream manager / depth.
472
+ * Use this to evaluate a sub-form (e.g. when the plugin received a lambda value).
473
+ * @param form the form to evaluate
474
+ * @return the evaluation result
475
+ */
476
+ eval(form: LispValue): LispValue;
477
+ }
478
+ /**
479
+ * A kei-lisp plugin contributes additional Lisp-callable functions to the
480
+ * interpreter. Register one with `LispInterpreter.use(plugin)`. When the
481
+ * evaluator encounters `(symbol ...)` and `symbol` is not a special form,
482
+ * registered plugins are consulted in registration order; the first plugin
483
+ * whose `has(symbol)` returns true handles the call.
484
+ *
485
+ * Arguments are pre-evaluated by the interpreter before being passed to
486
+ * `apply`, matching the calling convention of built-in functions.
487
+ */
488
+ interface KeiLispPlugin {
489
+ /**
490
+ * Plugin identifier, used for diagnostics and collision messages.
491
+ */
492
+ readonly name: string;
493
+ /**
494
+ * Returns true if this plugin handles the given symbol.
495
+ * @param symbol the call symbol to check
496
+ * @return true if `apply` should be called for this symbol
497
+ */
498
+ has(symbol: InterpretedSymbol): boolean;
499
+ /**
500
+ * Applies the plugin function to the (already-evaluated) arguments.
501
+ * @param symbol the call symbol
502
+ * @param args the evaluated argument list (a Cons, possibly Cons.nil)
503
+ * @param ctx the interpreter context for recursive evaluation
504
+ * @return the result value
505
+ */
506
+ apply(symbol: InterpretedSymbol, args: Cons, ctx: PluginContext): LispValue;
507
+ }
508
+ //#endregion
331
509
  //#region src/interpreter/LispInterpreter/index.d.ts
332
510
  /**
333
511
  * @class
@@ -335,22 +513,50 @@ declare class StreamManager {
335
513
  * @author Keisuke Ikeda
336
514
  * @this {LispInterpreter}
337
515
  */
338
- declare class LispInterpreter {
516
+ declare class LispInterpreter extends Object {
517
+ /**
518
+ * The root (top-level) environment table, pre-populated with built-in symbols.
519
+ */
339
520
  root: Table;
521
+ /**
522
+ * The stream manager that owns the interpreter's output / spy streams.
523
+ */
340
524
  streamManager: StreamManager;
525
+ /**
526
+ * Registered plugins consulted by the evaluator on every call. See `use`.
527
+ */
528
+ plugins: KeiLispPlugin[];
529
+ /**
530
+ * Constructor.
531
+ * @constructor
532
+ */
341
533
  constructor();
534
+ /**
535
+ * Registers a plugin. Subsequent `eval` calls will consult the plugin chain
536
+ * (in registration order, first match wins) when no special form matches a
537
+ * symbol, before falling through to the Applier built-ins.
538
+ * @param plugin the plugin to register
539
+ * @return this interpreter, for chaining
540
+ */
541
+ use(plugin: KeiLispPlugin): this;
342
542
  /**
343
543
  * Evaluates the given expression and returns the result. Throws `ParseError`,
344
544
  * `EvalError`, or `ExitError` on failure; library users are expected to catch
345
545
  * these (see the `KeiLispError` base class for the parse/eval family).
546
+ * @param aCons the expression to evaluate
547
+ * @return the evaluation result
346
548
  */
347
549
  eval(aCons: LispValue): LispValue;
348
550
  /**
349
551
  * Parses the source string, evaluates every expression it contains, and returns the results as an array.
552
+ * @param source the Lisp source string
553
+ * @return the array of evaluation results, one per top-level expression
350
554
  */
351
555
  evalAll(source: string): LispValue[];
352
556
  /**
353
557
  * Parses and evaluates the source string and returns the value of the last expression.
558
+ * @param source the Lisp source string
559
+ * @return the value of the last expression, or `Cons.nil` for empty input
354
560
  */
355
561
  evalString(source: string): LispValue;
356
562
  /**
@@ -358,14 +564,19 @@ declare class LispInterpreter {
358
564
  * it. The result is always a `Cons` (possibly `Cons.nil` for empty input)
359
565
  * because the source is wrapped in an outer list before parsing. Throws
360
566
  * `ParseError` if the source cannot be parsed.
567
+ * @param aString the Lisp source string
568
+ * @return a Cons containing the parsed top-level expressions
361
569
  */
362
570
  parse(aString: string): Cons;
363
571
  /**
364
572
  * Sets the given environment as the root of the environment chain.
573
+ * @param environment the environment table to install as root
574
+ * @return null
365
575
  */
366
576
  setRoot(environment: Table): null;
367
577
  /**
368
- * Initializes the environment table.
578
+ * Builds the root environment table by pre-registering every built-in symbol and the small set of bootstrap lambdas (append / butlast / nthcdr / reverse).
579
+ * @return the freshly initialized root environment
369
580
  */
370
581
  initializeTable(): Table;
371
582
  }
@@ -377,16 +588,346 @@ declare class LispInterpreter {
377
588
  * @author Keisuke Ikeda
378
589
  * @this {Repl}
379
590
  */
380
- declare class Repl {
591
+ declare class Repl extends Object {
592
+ /**
593
+ * The underlying interpreter used to parse and evaluate user input.
594
+ */
381
595
  interpreter: LispInterpreter;
596
+ /**
597
+ * The Node.js readline interface that supplies prompt I/O.
598
+ */
382
599
  rl: Interface;
600
+ /**
601
+ * Constructor.
602
+ * @constructor
603
+ * @param interpreter the interpreter to evaluate input against (defaults to a fresh one)
604
+ */
383
605
  constructor(interpreter?: LispInterpreter);
384
606
  /**
385
607
  * Starts the REPL loop.
608
+ * @return void
386
609
  */
387
610
  run(): void;
388
611
  }
389
612
  //#endregion
613
+ //#region src/runtime/Evaluator/index.d.ts
614
+ /**
615
+ * @class
616
+ * @classdesc Class that mimics Lisp's universal function Evaluate.
617
+ * @author Keisuke Ikeda
618
+ * @this {Evaluator}
619
+ */
620
+ declare class Evaluator extends Object {
621
+ /**
622
+ * Lisp-name to method-name dispatch map for special forms.
623
+ */
624
+ static readonly buildInFunctions: Map<InterpretedSymbol, string>;
625
+ /**
626
+ * The variable binding environment used during evaluation.
627
+ */
628
+ environment: Table;
629
+ /**
630
+ * The stream manager used for trace and spy output.
631
+ */
632
+ streamManager: StreamManager;
633
+ /**
634
+ * The current call depth, used for indenting trace/spy output.
635
+ */
636
+ depth: number;
637
+ /**
638
+ * Registered plugins consulted by `eval` when no special form matches.
639
+ */
640
+ plugins: KeiLispPlugin[];
641
+ /**
642
+ * Constructor.
643
+ * @param aTable the variable binding environment
644
+ * @param aStreamManager the stream manager for trace and spy output
645
+ * @param aNumber the initial call depth
646
+ * @param plugins the plugin chain consulted before falling through to Applier
647
+ */
648
+ constructor(aTable: Table, aStreamManager: StreamManager, aNumber: number, plugins?: KeiLispPlugin[]);
649
+ /**
650
+ * Implementation of the Lisp `and` special form.
651
+ * @param aCons the argument Cons containing the expressions to evaluate
652
+ * @return nil if any expression evaluates to nil, otherwise t
653
+ */
654
+ and(aCons: Cons): LispValue;
655
+ /**
656
+ * Implementation of the Lisp `apply` special form.
657
+ * @param aCons the argument Cons containing the procedure and its argument list
658
+ * @return the result of applying the procedure to the arguments
659
+ */
660
+ apply_lisp(aCons: Cons): LispValue;
661
+ /**
662
+ * Implementation of the Lisp `bind` special form.
663
+ * @param aCons the argument Cons whose car is the symbol to look up
664
+ * @return the binding count for the symbol, or nil if unbound
665
+ */
666
+ bind(aCons: Cons): LispValue;
667
+ /**
668
+ * Counts the number of distinct bindings for the given symbol along the environment chain.
669
+ * @param aSymbol the symbol whose bindings are inspected
670
+ * @return the number of distinct bindings found
671
+ */
672
+ bindAUX(aSymbol: InterpretedSymbol): number;
673
+ /**
674
+ * Sequentially evaluates and binds each (symbol value) pair into the given table; used by let*.
675
+ * @param parameters the Cons of (symbol value) pairs to bind
676
+ * @param aTable the table into which the bindings are written
677
+ */
678
+ binding(parameters: Cons, aTable: Table): null;
679
+ /**
680
+ * Evaluates all (symbol value) pairs first and then writes them into the given table in parallel; used by let.
681
+ * @param parameters the Cons of (symbol value) pairs to bind
682
+ * @param aTable the table into which the bindings are written
683
+ */
684
+ bindingParallel(parameters: Cons, aTable: Table): null;
685
+ /**
686
+ * Implementation of the Lisp `cond` special form.
687
+ * @param aCons the argument Cons of (test consequent...) clauses
688
+ * @return the result of the first clause whose test is non-nil, or nil
689
+ */
690
+ cond(aCons: LispValue): LispValue;
691
+ /**
692
+ * Implementation of the Lisp `defun` special form.
693
+ * @param aCons the argument Cons containing the function name, parameter list, and body
694
+ * @return the function name symbol
695
+ */
696
+ defun(aCons: Cons): LispValue;
697
+ /**
698
+ * Implementation of the Lisp `do` special form (parallel binding update).
699
+ * @param aCons the argument Cons containing bindings, termination clause, and body
700
+ * @return the value of the termination clause's result form
701
+ */
702
+ do_(aCons: Cons): LispValue;
703
+ /**
704
+ * Implementation of the Lisp `dolist` special form.
705
+ * @param aCons the argument Cons containing the binding clause and body
706
+ * @return the value of the result form
707
+ */
708
+ doList(aCons: Cons): LispValue;
709
+ /**
710
+ * Implementation of the Lisp `do*` special form (sequential binding update).
711
+ * @param aCons the argument Cons containing bindings, termination clause, and body
712
+ * @return the value of the termination clause's result form
713
+ */
714
+ doStar(aCons: Cons): LispValue;
715
+ /**
716
+ * Evaluates a procedure call by delegating to the Applier after evaluating each argument.
717
+ * @param form the call form whose car is the procedure and whose cdr is the argument list
718
+ * @return the result of applying the procedure
719
+ */
720
+ entrustApplier(form: Cons): LispValue;
721
+ /**
722
+ * Evaluates the given form in the given environment.
723
+ * @param form the form to evaluate
724
+ * @param environment the variable binding environment
725
+ * @param aStreamManager the stream manager for trace and spy output
726
+ * @param depth the current call depth
727
+ * @param plugins the plugin chain consulted before falling through to Applier
728
+ * @return the evaluation result
729
+ */
730
+ static eval(form: LispValue, environment: Table, aStreamManager?: StreamManager, depth?: number, plugins?: KeiLispPlugin[]): LispValue;
731
+ /**
732
+ * Evaluates the given form using this Evaluator's environment.
733
+ * @param form the form to evaluate
734
+ * @return the evaluation result
735
+ */
736
+ eval(form: LispValue): LispValue;
737
+ /**
738
+ * Evaluates the argument list (the same way `entrustApplier` does), then
739
+ * delegates the call to the matched plugin with a context that allows
740
+ * recursive evaluation.
741
+ * @param plugin the plugin that claimed the call symbol
742
+ * @param form the call form whose car is the symbol and whose cdr is the argument list
743
+ * @return the result returned by the plugin
744
+ */
745
+ entrustPlugin(plugin: KeiLispPlugin, form: Cons): LispValue;
746
+ /**
747
+ * Implementation of the Lisp `eval` special form.
748
+ * @param aCons the argument Cons whose car is the form to evaluate twice
749
+ * @return the result of evaluating the form
750
+ */
751
+ eval_lisp(aCons: Cons): LispValue;
752
+ /**
753
+ * Resolves the value bound to the given symbol in the current environment.
754
+ * @param aSymbol the symbol to resolve
755
+ * @return the value bound to the symbol
756
+ */
757
+ evaluateSymbol(aSymbol: InterpretedSymbol): LispValue;
758
+ /**
759
+ * Implementation of the Lisp `exit` special form; terminates the REPL by throwing an ExitError.
760
+ */
761
+ exit(): never;
762
+ /**
763
+ * Implementation of the Lisp `gc` special form; triggers garbage collection and returns memory usage.
764
+ * @return an association list of memory usage statistics
765
+ */
766
+ gc(): Cons;
767
+ /**
768
+ * Implementation of the Lisp `if` special form.
769
+ * @param aCons the argument Cons containing the test, then-form, and else-form
770
+ * @return the result of evaluating the selected branch
771
+ */
772
+ if_(aCons: Cons): LispValue;
773
+ /**
774
+ * Returns the indentation string used for trace and spy output at the current depth.
775
+ * @return the indentation string
776
+ */
777
+ indent(): string;
778
+ /**
779
+ * Returns whether the given symbol is currently being spied on.
780
+ * @param aSymbol the symbol to check
781
+ * @return a boolean
782
+ */
783
+ isSpy(aSymbol: InterpretedSymbol | null): boolean;
784
+ /**
785
+ * Implementation of the Lisp `lambda` special form; captures the current environment as a closure.
786
+ * @param args the argument Cons containing the parameter list and body
787
+ * @return a lambda form with the captured environment appended
788
+ */
789
+ lambda(args: Cons): LispValue;
790
+ /**
791
+ * Implementation of the Lisp `let` special form (parallel binding).
792
+ * @param aCons the argument Cons containing bindings and body
793
+ * @return the value of the last body form
794
+ */
795
+ let(aCons: Cons): LispValue;
796
+ /**
797
+ * Implementation of the Lisp `let*` special form (sequential binding).
798
+ * @param aCons the argument Cons containing bindings and body
799
+ * @return the value of the last body form
800
+ */
801
+ letStar(aCons: Cons): LispValue;
802
+ /**
803
+ * Implementation of the Lisp `not` special form.
804
+ * @param aCons the argument Cons whose car is the expression to negate
805
+ * @return t if the expression evaluates to nil, otherwise nil
806
+ */
807
+ not(aCons: Cons): LispValue;
808
+ /**
809
+ * Implementation of the Lisp `notrace` special form; disables tracing.
810
+ * @return the symbol t
811
+ */
812
+ notrace(): InterpretedSymbol;
813
+ /**
814
+ * Implementation of the Lisp `or` special form.
815
+ * @param aCons the argument Cons containing the expressions to evaluate
816
+ * @return t if any expression evaluates to non-nil, otherwise nil
817
+ */
818
+ or(aCons: Cons): LispValue;
819
+ /**
820
+ * Implementation of the Lisp `pop` special form.
821
+ * @param aCons the argument Cons whose car is the symbol bound to a list
822
+ * @return the popped element, or nil if the binding is not a Cons
823
+ */
824
+ pop_(aCons: Cons): LispValue;
825
+ /**
826
+ * Implementation of the Lisp `progn` special form.
827
+ * @param aCons the argument Cons containing the body expressions
828
+ * @return the value of the last body form, or nil if there are none
829
+ */
830
+ progn(aCons: Cons): LispValue;
831
+ /**
832
+ * Implementation of the Lisp `princ` special form; writes the evaluated argument without a trailing newline.
833
+ * @param aCons the argument Cons whose car is the expression to print
834
+ * @return the printed value
835
+ */
836
+ princ(aCons: Cons): LispValue;
837
+ /**
838
+ * Implementation of the Lisp `print` special form; writes the evaluated argument followed by a newline.
839
+ * @param aCons the argument Cons whose car is the expression to print
840
+ * @return the printed value
841
+ */
842
+ print(aCons: Cons): LispValue;
843
+ /**
844
+ * Implementation of the Lisp `push` special form.
845
+ * @param aCons the argument Cons containing the value to push and the target symbol
846
+ * @return the new Cons stored in the symbol
847
+ */
848
+ push_(aCons: Cons): LispValue;
849
+ /**
850
+ * Implementation of the Lisp `quote` special form.
851
+ * @param aCons the argument Cons whose car is the form to return unevaluated
852
+ * @return the quoted form
853
+ */
854
+ quote(aCons: Cons): LispValue;
855
+ /**
856
+ * Implementation of the Lisp `rplaca` special form; destructively replaces the car of a Cons.
857
+ * @param args the argument Cons containing the target Cons expression and the new car value
858
+ * @return the modified Cons
859
+ */
860
+ rplaca(args: Cons): LispValue;
861
+ /**
862
+ * Implementation of the Lisp `rplacd` special form; destructively replaces the cdr of a Cons.
863
+ * @param args the argument Cons containing the target Cons expression and the new cdr value
864
+ * @return the modified Cons
865
+ */
866
+ rplacd(args: Cons): LispValue;
867
+ /**
868
+ * Implementation of the Lisp `setq` special form; assigns values in the local environment.
869
+ * @param args the argument Cons containing alternating (symbol value) pairs
870
+ * @return the last assigned value
871
+ */
872
+ setq(args: Cons): LispValue;
873
+ /**
874
+ * Implementation of the Lisp `set-allq` special form; assigns values in the binding's owning scope.
875
+ * @param args the argument Cons containing alternating (symbol value) pairs
876
+ * @return the last assigned value
877
+ */
878
+ set_allq(args: Cons): LispValue;
879
+ /**
880
+ * Sets the current call depth used for trace and spy indentation.
881
+ * @param aNumber the new depth
882
+ */
883
+ setDepth(aNumber: number): null;
884
+ /**
885
+ * Builds and returns the Lisp-name to method-name dispatch map for special forms.
886
+ * @return the dispatch map
887
+ */
888
+ static setup(): Map<InterpretedSymbol, string>;
889
+ /**
890
+ * Dispatches a special-form call to the corresponding method via the build-in dispatch map.
891
+ * @param form the form whose car is the special-form symbol
892
+ * @return the result of the special-form method
893
+ */
894
+ specialForm(form: Cons): LispValue;
895
+ /**
896
+ * Writes a trace/spy line to the given stream (or stdout) with the current indentation.
897
+ * @param aStream the destination stream, or null/string to fall back to stdout
898
+ * @param line the line to write
899
+ */
900
+ spyPrint(aStream: NodeJS.WritableStream | string | null, line: string): null;
901
+ /**
902
+ * Implementation of the Lisp `terpri` special form; writes a newline to stdout.
903
+ * @return the symbol t
904
+ */
905
+ terpri(): InterpretedSymbol;
906
+ /**
907
+ * Implementation of the Lisp `time` special form; measures evaluation time in milliseconds.
908
+ * @param aCons the argument Cons whose car is the form to time
909
+ * @return the elapsed time in milliseconds
910
+ */
911
+ time(aCons: Cons): number;
912
+ /**
913
+ * Implementation of the Lisp `trace` special form; enables tracing.
914
+ * @return the symbol t
915
+ */
916
+ trace(): InterpretedSymbol;
917
+ /**
918
+ * Implementation of the Lisp `unless` special form.
919
+ * @param aCons the argument Cons containing the test and body
920
+ * @return the value of the last body form if the test is nil, otherwise nil
921
+ */
922
+ unless(aCons: Cons): LispValue;
923
+ /**
924
+ * Implementation of the Lisp `when` special form.
925
+ * @param aCons the argument Cons containing the test and body
926
+ * @return the value of the last body form if the test is non-nil, otherwise nil
927
+ */
928
+ when(aCons: Cons): LispValue;
929
+ }
930
+ //#endregion
390
931
  //#region src/errors/KeiLispError/index.d.ts
391
932
  /**
392
933
  * @class
@@ -450,5 +991,5 @@ declare class ParseError extends KeiLispError {
450
991
  constructor(message: string);
451
992
  }
452
993
  //#endregion
453
- export { Cons, EvalError, ExitError, InterpretedSymbol, KeiLispError, LispInterpreter, type LispValue, ParseError, Repl };
994
+ export { Cons, EvalError, Evaluator, ExitError, InterpretedSymbol, KeiLispError, type KeiLispPlugin, LispInterpreter, type LispValue, ParseError, type PluginContext, Repl, StreamManager, Table };
454
995
  //# sourceMappingURL=index.d.ts.map