@dallaylaen/ski-interpreter 2.6.2 → 2.7.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 +31 -0
- package/README.md +2 -0
- package/bin/ski.js +5 -1
- package/lib/ski-interpreter.cjs.js +181 -13906
- package/lib/ski-interpreter.cjs.js.map +4 -4
- package/lib/ski-interpreter.min.js +6 -45
- package/lib/ski-interpreter.min.js.map +4 -4
- package/lib/ski-interpreter.mjs +181 -13912
- package/lib/ski-interpreter.mjs.map +4 -4
- package/lib/ski-quest.min.js +6 -45
- package/lib/ski-quest.min.js.map +4 -4
- package/lib/types/expr.d.ts +187 -164
- package/lib/types/extras.d.ts +17 -7
- package/lib/types/index.d.ts +7 -36
- package/lib/types/internal.d.ts +5 -5
- package/lib/types/parser.d.ts +6 -6
- package/lib/types/quest.d.ts +77 -44
- package/lib/types/toposort.d.ts +2 -3
- package/package.json +5 -3
package/lib/types/extras.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Expr, Named, FormatOptions, TermInfo } from './expr';
|
|
2
2
|
import { toposort } from './toposort';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Extra utilities that do not belong in the core.
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* @experimental
|
|
8
|
-
*
|
|
8
|
+
* Look for an expression that matches the predicate,
|
|
9
9
|
* starting with the seed and applying the terms to one another.
|
|
10
10
|
*
|
|
11
11
|
* A predicate returning 0 (or nothing) means "keep looking",
|
|
@@ -28,7 +28,7 @@ import { toposort } from './toposort';
|
|
|
28
28
|
* @param {(e: Expr, props: {}) => number?} predicate
|
|
29
29
|
* @return {{expr?: Expr, total: number, probed: number, gen: number, cache?: Expr[][]}}
|
|
30
30
|
*/
|
|
31
|
-
type SearchOptions = {
|
|
31
|
+
export type SearchOptions = {
|
|
32
32
|
depth?: number;
|
|
33
33
|
tries?: number;
|
|
34
34
|
infer?: boolean;
|
|
@@ -44,8 +44,8 @@ type SearchOptions = {
|
|
|
44
44
|
}) => void;
|
|
45
45
|
progressInterval?: number;
|
|
46
46
|
};
|
|
47
|
-
type SearchCallback = (e: Expr, props: TermInfo) => (number | undefined);
|
|
48
|
-
type SearchResult = {
|
|
47
|
+
export type SearchCallback = (e: Expr, props: TermInfo) => (number | undefined);
|
|
48
|
+
export type SearchResult = {
|
|
49
49
|
expr?: Expr;
|
|
50
50
|
total: number;
|
|
51
51
|
probed: number;
|
|
@@ -54,7 +54,7 @@ type SearchResult = {
|
|
|
54
54
|
};
|
|
55
55
|
declare function search(seed: Expr[], options: SearchOptions, predicate: SearchCallback): SearchResult;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Recursively replace all instances of Expr in a data structure with
|
|
58
58
|
* respective string representation using the format() options.
|
|
59
59
|
* Objects of other types and primitive values are eft as is.
|
|
60
60
|
*
|
|
@@ -64,7 +64,7 @@ declare function search(seed: Expr[], options: SearchOptions, predicate: SearchC
|
|
|
64
64
|
*/
|
|
65
65
|
declare function deepFormat(obj: any, options?: FormatOptions): any;
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
67
|
+
* Given an expression and a hash of named terms,
|
|
68
68
|
* return a semicolon-separated string that declares said expression
|
|
69
69
|
* unambiguously.
|
|
70
70
|
*
|
|
@@ -80,10 +80,20 @@ declare function deepFormat(obj: any, options?: FormatOptions): any;
|
|
|
80
80
|
declare function declare(expr: Expr, env?: {
|
|
81
81
|
[s: string]: Named;
|
|
82
82
|
}): string;
|
|
83
|
+
/**
|
|
84
|
+
* Converts an unknown object into a FormatOptions, or returns an error it it is not valid.
|
|
85
|
+
* A null/undefined counts as an empty options object (and is thus valid).
|
|
86
|
+
*/
|
|
87
|
+
declare function checkFormatOptions(raw: unknown): {
|
|
88
|
+
value: FormatOptions;
|
|
89
|
+
} | {
|
|
90
|
+
error: Record<string, string>;
|
|
91
|
+
};
|
|
83
92
|
export declare const extras: {
|
|
84
93
|
search: typeof search;
|
|
85
94
|
deepFormat: typeof deepFormat;
|
|
86
95
|
declare: typeof declare;
|
|
87
96
|
toposort: typeof toposort;
|
|
97
|
+
checkFormatOptions: typeof checkFormatOptions;
|
|
88
98
|
};
|
|
89
99
|
export {};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -20,19 +20,6 @@ export declare class SKI extends Parser {
|
|
|
20
20
|
Church: typeof Church;
|
|
21
21
|
Alias: typeof import("./expr").Alias;
|
|
22
22
|
};
|
|
23
|
-
static schemas: {
|
|
24
|
-
FormatOptions: import("zod").ZodObject<{
|
|
25
|
-
terse: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
26
|
-
html: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
27
|
-
brackets: import("zod").ZodOptional<import("zod").ZodTuple<[import("zod").ZodString, import("zod").ZodString], null>>;
|
|
28
|
-
space: import("zod").ZodOptional<import("zod").ZodString>;
|
|
29
|
-
var: import("zod").ZodOptional<import("zod").ZodTuple<[import("zod").ZodString, import("zod").ZodString], null>>;
|
|
30
|
-
lambda: import("zod").ZodOptional<import("zod").ZodTuple<[import("zod").ZodString, import("zod").ZodString, import("zod").ZodString], null>>;
|
|
31
|
-
around: import("zod").ZodOptional<import("zod").ZodTuple<[import("zod").ZodString, import("zod").ZodString], null>>;
|
|
32
|
-
redex: import("zod").ZodOptional<import("zod").ZodTuple<[import("zod").ZodString, import("zod").ZodString], null>>;
|
|
33
|
-
inventory: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodCustom<import("./expr").Expr, import("./expr").Expr>>>;
|
|
34
|
-
}, import("zod/v4/core").$strip>;
|
|
35
|
-
};
|
|
36
23
|
static B: import("./expr").Native;
|
|
37
24
|
static C: import("./expr").Native;
|
|
38
25
|
static I: import("./expr").Native;
|
|
@@ -40,7 +27,7 @@ export declare class SKI extends Parser {
|
|
|
40
27
|
static S: import("./expr").Native;
|
|
41
28
|
static W: import("./expr").Native;
|
|
42
29
|
/**
|
|
43
|
-
*
|
|
30
|
+
* Create a proxy object that generates variables on demand,
|
|
44
31
|
* with names corresponding to the property accessed.
|
|
45
32
|
* Different invocations will return distinct variables,
|
|
46
33
|
* even if with the same name.
|
|
@@ -55,33 +42,17 @@ export declare class SKI extends Parser {
|
|
|
55
42
|
};
|
|
56
43
|
static church(n: number): Church;
|
|
57
44
|
static extras: {
|
|
58
|
-
search: (seed: import("./expr").Expr[], options:
|
|
59
|
-
depth?: number;
|
|
60
|
-
tries?: number;
|
|
61
|
-
infer?: boolean;
|
|
62
|
-
maxArgs?: number;
|
|
63
|
-
max?: number;
|
|
64
|
-
noskip?: boolean;
|
|
65
|
-
retain?: boolean;
|
|
66
|
-
progress?: (info: {
|
|
67
|
-
gen: number;
|
|
68
|
-
total: number;
|
|
69
|
-
probed: number;
|
|
70
|
-
step: boolean;
|
|
71
|
-
}) => void;
|
|
72
|
-
progressInterval?: number;
|
|
73
|
-
}, predicate: (e: import("./expr").Expr, props: import("./expr").TermInfo) => (number | undefined)) => {
|
|
74
|
-
expr?: import("./expr").Expr;
|
|
75
|
-
total: number;
|
|
76
|
-
probed: number;
|
|
77
|
-
gen: number;
|
|
78
|
-
cache?: import("./expr").Expr[][];
|
|
79
|
-
};
|
|
45
|
+
search: (seed: import("./expr").Expr[], options: import("./extras").SearchOptions, predicate: import("./extras").SearchCallback) => import("./extras").SearchResult;
|
|
80
46
|
deepFormat: (obj: any, options?: import("./expr").FormatOptions) => any;
|
|
81
47
|
declare: (expr: import("./expr").Expr, env?: {
|
|
82
48
|
[s: string]: import("./expr").Named;
|
|
83
49
|
}) => string;
|
|
84
50
|
toposort: typeof toposort;
|
|
51
|
+
checkFormatOptions: (raw: unknown) => {
|
|
52
|
+
value: import("./expr").FormatOptions;
|
|
53
|
+
} | {
|
|
54
|
+
error: Record<string, string>;
|
|
55
|
+
};
|
|
85
56
|
};
|
|
86
57
|
static Quest: typeof Quest;
|
|
87
58
|
}
|
package/lib/types/internal.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare class Tokenizer {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Create a tokenizer that splits strings into tokens according to the given terms.
|
|
4
4
|
* The terms are interpreted as regular expressions, and are sorted by length
|
|
5
5
|
* to ensure that longer matches are preferred over shorter ones.
|
|
6
6
|
* @param {...string|RegExp} terms
|
|
@@ -8,14 +8,14 @@ export declare class Tokenizer {
|
|
|
8
8
|
rex: RegExp;
|
|
9
9
|
constructor(...terms: (string | RegExp)[]);
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Split the given string into tokens according to the terms specified in the constructor.
|
|
12
12
|
* @param {string} str
|
|
13
13
|
* @return {string[]}
|
|
14
14
|
*/
|
|
15
15
|
split(str: string): string[];
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Add ot remove tokens from a set according to a spec string.
|
|
19
19
|
* The spec string is a sequence of tokens, with each group optionally prefixed
|
|
20
20
|
* by one of the operators '=', '+', or '-'.
|
|
21
21
|
* The '=' operator resets the set to contain only the following token(s).
|
|
@@ -28,7 +28,7 @@ export type TraverseDecorator = <T>(value?: T) => TraverseControl<T>;
|
|
|
28
28
|
export type TraverseValue<T> = TraverseControl<T | null | undefined | void> | T | null | undefined | void;
|
|
29
29
|
export declare class TraverseControl<T> {
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* A wrapper for values returned by fold/traverse callbacks
|
|
32
32
|
* which instructs the traversal to alter its behavior while
|
|
33
33
|
* retaining the value in question.
|
|
34
34
|
*
|
|
@@ -51,7 +51,7 @@ export declare class TraverseControl<T> {
|
|
|
51
51
|
*/
|
|
52
52
|
export declare function unwrap<T>(value: TraverseValue<T>): [T?, TraverseDecorator?];
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* Prepare a self-referencing wrapper function for use as a fold/traverse control decorator.
|
|
55
55
|
*
|
|
56
56
|
* If `fun` is created by `prepareWrapper`, then
|
|
57
57
|
* unwrap(fun(x)) will always return exactly [x, fun], and the second value can be checked with ===.
|
package/lib/types/parser.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare class Parser {
|
|
|
45
45
|
hasLambdas: boolean;
|
|
46
46
|
constructor(options?: ParserOptions);
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Declare a new term
|
|
49
49
|
* If the first argument is an Alias, it is added as is.
|
|
50
50
|
* Otherwise, a new Alias or Native term (depending on impl type) is created.
|
|
51
51
|
* If note is not provided and this.annotate is true, an automatic note is generated.
|
|
@@ -69,7 +69,7 @@ export declare class Parser {
|
|
|
69
69
|
*/
|
|
70
70
|
add(term: Alias | string, impl?: Expr | string | ((arg: Expr) => Invocation), options?: AddOptions | string): this;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Internal helper for add() that creates an Alias or Native term from the given arguments.
|
|
73
73
|
* @param {Alias|string} term
|
|
74
74
|
* @param {string|Expr|function(Expr):Partial} impl
|
|
75
75
|
* @returns {Native|Alias}
|
|
@@ -77,7 +77,7 @@ export declare class Parser {
|
|
|
77
77
|
*/
|
|
78
78
|
_named(term: Alias | string, impl?: Expr | string | ((arg: Expr) => Invocation)): Native | Alias;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* Declare a new term if it is not known, otherwise just allow it.
|
|
81
81
|
* Currently only used by quests.
|
|
82
82
|
* Use with caution, this function may change its signature, behavior, or even be removed in the future.
|
|
83
83
|
*
|
|
@@ -88,7 +88,7 @@ export declare class Parser {
|
|
|
88
88
|
*/
|
|
89
89
|
maybeAdd(name: string, impl: Expr | string | ((arg: Expr) => Invocation)): this;
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
91
|
+
* Declare and remove multiple terms at once
|
|
92
92
|
* term=impl adds term
|
|
93
93
|
* term= removes term
|
|
94
94
|
* @param {string[]} list
|
|
@@ -126,7 +126,7 @@ export declare class Parser {
|
|
|
126
126
|
[key: string]: Expr;
|
|
127
127
|
};
|
|
128
128
|
/**
|
|
129
|
-
*
|
|
129
|
+
* Export term declarations for use in bulkAdd().
|
|
130
130
|
* Currently only Alias terms are serialized.
|
|
131
131
|
* @returns {string[]}
|
|
132
132
|
*/
|
|
@@ -144,7 +144,7 @@ export declare class Parser {
|
|
|
144
144
|
*/
|
|
145
145
|
parse(source: string, options?: ParseOptions): Expr;
|
|
146
146
|
/**
|
|
147
|
-
*
|
|
147
|
+
* Parse a single line of source code, without splitting it into declarations.
|
|
148
148
|
* Internal, always use parse() instead.
|
|
149
149
|
* @template T
|
|
150
150
|
* @param {String} source S(KI)I
|
package/lib/types/quest.d.ts
CHANGED
|
@@ -36,6 +36,10 @@ export type InputSpec = {
|
|
|
36
36
|
numbers?: boolean;
|
|
37
37
|
lambdas?: boolean;
|
|
38
38
|
};
|
|
39
|
+
export type SolEntry = {
|
|
40
|
+
input: string[];
|
|
41
|
+
result: QuestResult;
|
|
42
|
+
};
|
|
39
43
|
export type QuestResult = {
|
|
40
44
|
pass: boolean;
|
|
41
45
|
details: CaseResult[];
|
|
@@ -45,9 +49,6 @@ export type QuestResult = {
|
|
|
45
49
|
steps: number;
|
|
46
50
|
weight?: number;
|
|
47
51
|
};
|
|
48
|
-
type QuestMeta = {
|
|
49
|
-
[key: string]: any;
|
|
50
|
-
};
|
|
51
52
|
export type QuestSpec = {
|
|
52
53
|
input: string | InputSpec | (string | InputSpec)[];
|
|
53
54
|
cases: TestCase[];
|
|
@@ -60,12 +61,12 @@ export type QuestSpec = {
|
|
|
60
61
|
id?: string | number;
|
|
61
62
|
name?: string;
|
|
62
63
|
intro?: string | string[];
|
|
63
|
-
} &
|
|
64
|
+
} & Record<string, unknown>;
|
|
64
65
|
export type SelfCheck = {
|
|
65
66
|
accepted?: string[][];
|
|
66
67
|
rejected?: string[][];
|
|
67
68
|
};
|
|
68
|
-
type AddCaseOptions = {
|
|
69
|
+
export type AddCaseOptions = {
|
|
69
70
|
engine?: Parser;
|
|
70
71
|
env?: {
|
|
71
72
|
[key: string]: Expr;
|
|
@@ -73,25 +74,30 @@ type AddCaseOptions = {
|
|
|
73
74
|
max?: number;
|
|
74
75
|
note?: string;
|
|
75
76
|
caps?: Capability;
|
|
77
|
+
canonize?: {
|
|
78
|
+
max?: number;
|
|
79
|
+
maxSize?: number;
|
|
80
|
+
maxArgs?: number;
|
|
81
|
+
};
|
|
76
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* A combinator problem with a set of test cases for the proposed solution.
|
|
85
|
+
* @param {QuestSpec} options
|
|
86
|
+
* @example const quest = new Quest({
|
|
87
|
+
* input: 'identity',
|
|
88
|
+
* cases: [
|
|
89
|
+
* ['identity x', 'x'],
|
|
90
|
+
* ],
|
|
91
|
+
* allow: 'SK',
|
|
92
|
+
* intro: 'Find a combinator that behaves like the identity function.',
|
|
93
|
+
* });
|
|
94
|
+
* quest.check('S K K'); // { pass: true, details: [...], ... }
|
|
95
|
+
* quest.check('K S'); // { pass: false, details: [...], ... }
|
|
96
|
+
* quest.check('K x'); // fail! internal variable x is not equal to free variable x,
|
|
97
|
+
* // despite having the same name.
|
|
98
|
+
* quest.check('I'); // fail! I not in the allowed list.
|
|
99
|
+
*/
|
|
77
100
|
export declare class Quest {
|
|
78
|
-
/**
|
|
79
|
-
* @description A combinator problem with a set of test cases for the proposed solution.
|
|
80
|
-
* @param {QuestSpec} options
|
|
81
|
-
* @example const quest = new Quest({
|
|
82
|
-
* input: 'identity',
|
|
83
|
-
* cases: [
|
|
84
|
-
* ['identity x', 'x'],
|
|
85
|
-
* ],
|
|
86
|
-
* allow: 'SK',
|
|
87
|
-
* intro: 'Find a combinator that behaves like the identity function.',
|
|
88
|
-
* });
|
|
89
|
-
* quest.check('S K K'); // { pass: true, details: [...], ... }
|
|
90
|
-
* quest.check('K S'); // { pass: false, details: [...], ... }
|
|
91
|
-
* quest.check('K x'); // fail! internal variable x is not equal to free variable x,
|
|
92
|
-
* // despite having the same name.
|
|
93
|
-
* quest.check('I'); // fail! I not in the allowed list.
|
|
94
|
-
*/
|
|
95
101
|
input: (InputSpec & {
|
|
96
102
|
placeholder: FreeVar;
|
|
97
103
|
})[];
|
|
@@ -112,7 +118,7 @@ export declare class Quest {
|
|
|
112
118
|
id?: string | number;
|
|
113
119
|
name?: string;
|
|
114
120
|
intro?: string;
|
|
115
|
-
meta?:
|
|
121
|
+
meta?: Record<string, unknown>;
|
|
116
122
|
constructor(options: QuestSpec);
|
|
117
123
|
/**
|
|
118
124
|
* Display allowed terms based on what engine thinks of this.env + this.restrict.allow
|
|
@@ -128,7 +134,7 @@ export declare class Quest {
|
|
|
128
134
|
*/
|
|
129
135
|
add(opt: AddCaseOptions | string, ...terms: string[]): this;
|
|
130
136
|
/**
|
|
131
|
-
*
|
|
137
|
+
* Statefully parse a list of strings into expressions or fancy aliases thereof.
|
|
132
138
|
* @param {string[]} input
|
|
133
139
|
* @return {{terms: Expr[], weight: number}}
|
|
134
140
|
*/
|
|
@@ -138,7 +144,7 @@ export declare class Quest {
|
|
|
138
144
|
};
|
|
139
145
|
/**
|
|
140
146
|
*
|
|
141
|
-
* @param
|
|
147
|
+
* @param input
|
|
142
148
|
* @return {QuestResult}
|
|
143
149
|
*/
|
|
144
150
|
check(...input: string[]): QuestResult;
|
|
@@ -152,21 +158,15 @@ export declare class Quest {
|
|
|
152
158
|
[key: string]: unknown;
|
|
153
159
|
} | null;
|
|
154
160
|
/**
|
|
155
|
-
*
|
|
161
|
+
* Verify that solutions that are expected to pass/fail do so.
|
|
156
162
|
* @param {SelfCheck|{[key: string]: SelfCheck}} dataset
|
|
157
163
|
* @return {{shouldPass: {input: string[], result: QuestResult}[], shouldFail: {input: string[], result: QuestResult}[]} | null}
|
|
158
164
|
*/
|
|
159
165
|
verifySolutions(dataset: SelfCheck | {
|
|
160
166
|
[key: string | number]: SelfCheck;
|
|
161
167
|
}): {
|
|
162
|
-
shouldPass:
|
|
163
|
-
|
|
164
|
-
result: QuestResult;
|
|
165
|
-
}[];
|
|
166
|
-
shouldFail: {
|
|
167
|
-
input: string[];
|
|
168
|
-
result: QuestResult;
|
|
169
|
-
}[];
|
|
168
|
+
shouldPass: SolEntry[];
|
|
169
|
+
shouldFail: SolEntry[];
|
|
170
170
|
} | null;
|
|
171
171
|
verifyMeta(options?: {
|
|
172
172
|
date?: boolean;
|
|
@@ -191,9 +191,9 @@ export declare class Quest {
|
|
|
191
191
|
[key: string]: unknown;
|
|
192
192
|
};
|
|
193
193
|
};
|
|
194
|
-
static Case: new (input: FreeVar[], options: AddCaseOptions) => Case;
|
|
194
|
+
static Case: abstract new (input: FreeVar[], options: AddCaseOptions) => Case;
|
|
195
195
|
}
|
|
196
|
-
declare class Case {
|
|
196
|
+
export declare abstract class Case {
|
|
197
197
|
/**
|
|
198
198
|
* @param {FreeVar[]} input
|
|
199
199
|
* @param {{
|
|
@@ -213,21 +213,54 @@ declare class Case {
|
|
|
213
213
|
constructor(input: FreeVar[], options: AddCaseOptions);
|
|
214
214
|
parse(src: string): Subst;
|
|
215
215
|
/**
|
|
216
|
-
* @param
|
|
216
|
+
* @param input
|
|
217
217
|
* @return {CaseResult}
|
|
218
218
|
*/
|
|
219
|
-
check(...
|
|
219
|
+
abstract check(...input: Expr[]): CaseResult;
|
|
220
220
|
}
|
|
221
|
-
declare class
|
|
221
|
+
export declare class ExprCase extends Case {
|
|
222
|
+
e1: Subst;
|
|
223
|
+
e2: Subst;
|
|
224
|
+
canonize?: {
|
|
225
|
+
max?: number;
|
|
226
|
+
maxSize?: number;
|
|
227
|
+
maxArgs?: number;
|
|
228
|
+
};
|
|
222
229
|
/**
|
|
223
|
-
* @
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
230
|
+
* @param {FreeVar[]} input
|
|
231
|
+
* @param {{
|
|
232
|
+
* max?: number,
|
|
233
|
+
* note?: string,
|
|
234
|
+
* env?: {string: Expr},
|
|
235
|
+
* canonize?: { max?: number, maxSize?: number, maxArgs?: number },
|
|
236
|
+
* engine?: Parser
|
|
237
|
+
* }} options
|
|
238
|
+
* @param {[e1: string, e2: string]} terms
|
|
227
239
|
*/
|
|
240
|
+
constructor(input: FreeVar[], options: AddCaseOptions, terms: string[]);
|
|
241
|
+
check(...input: Expr[]): CaseResult;
|
|
242
|
+
}
|
|
243
|
+
export declare class PropertyCase extends Case {
|
|
244
|
+
expr: Subst;
|
|
245
|
+
caps: Capability;
|
|
246
|
+
isAffine?: boolean;
|
|
247
|
+
constructor(input: FreeVar[], options: AddCaseOptions, terms: string[]);
|
|
248
|
+
check(...input: Expr[]): CaseResult;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* A placeholder object with exactly n free variables to be substituted later.
|
|
252
|
+
* Basically a poor man's n-fold lambda.
|
|
253
|
+
*
|
|
254
|
+
* @remarks Internal. Do not rely on name, meaning, or structure. It's only in the docs for completeness sake.
|
|
255
|
+
*
|
|
256
|
+
* @experimental
|
|
257
|
+
*
|
|
258
|
+
* @param {Expr} expr
|
|
259
|
+
* @param {FreeVar[]} env
|
|
260
|
+
*/
|
|
261
|
+
export declare class Subst {
|
|
228
262
|
expr: Expr;
|
|
229
263
|
env: FreeVar[];
|
|
230
264
|
constructor(expr: Expr, env: FreeVar[]);
|
|
231
265
|
apply(list: Expr[]): Expr;
|
|
232
266
|
}
|
|
233
|
-
export {};
|
package/lib/types/toposort.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Expr, Named } from './expr';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Sort a list in such a way that dependent terms come after the (named) terms they depend on.
|
|
4
4
|
* If env is given, only terms listed there are taken into account.
|
|
5
5
|
* If env is omitted, it will be implied from the list.
|
|
6
6
|
* If list is omitted, it will default to values of env.
|
|
@@ -18,7 +18,7 @@ import { Expr, Named } from './expr';
|
|
|
18
18
|
* const expr = ski.parse(src);
|
|
19
19
|
* toposort([expr], ski.getTerms()); // returns all terms appearing in Expr in correct order
|
|
20
20
|
*/
|
|
21
|
-
type ToposortResult = {
|
|
21
|
+
export type ToposortResult = {
|
|
22
22
|
list: Expr[];
|
|
23
23
|
env: {
|
|
24
24
|
[s: string]: Named;
|
|
@@ -27,4 +27,3 @@ type ToposortResult = {
|
|
|
27
27
|
export declare function toposort(list: Expr[] | Expr | undefined, env: {
|
|
28
28
|
[s: string]: Named;
|
|
29
29
|
} | undefined): ToposortResult;
|
|
30
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dallaylaen/ski-interpreter",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Simple Kombinator Interpreter - a combinatory logic & lambda calculus parser and interpreter. Supports SKI, BCKW, Church numerals, and setting up assertions ('quests') involving all of the above.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"combinatory logic",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"module": "lib/ski-interpreter.mjs",
|
|
15
15
|
"exports": {
|
|
16
16
|
"types": "./lib/types/index.d.ts",
|
|
17
|
+
"types/*": "./lib/types/*.d.ts",
|
|
17
18
|
"import": "./lib/ski-interpreter.mjs",
|
|
18
19
|
"require": "./lib/ski-interpreter.cjs.js"
|
|
19
20
|
},
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
"lint": "npx eslint --ext .js,.ts src test bin",
|
|
25
26
|
"tsc": "npx tsc",
|
|
26
27
|
"test": "npm run tsc; npx nyc mocha --recursive test",
|
|
28
|
+
"tsdoc": "npx typedoc --treatWarningsAsErrors --out docs/man --gitRevision \"$(git log -1 --format='%H' -- src/)\" src/*.ts",
|
|
27
29
|
"build-web": "npx esbuild --bundle --minify --sourcemap --format=iife ./src/index.ts --outfile=docs/build/js/ski-interpreter.min.js",
|
|
28
30
|
"build-cjs": "npx esbuild --bundle --sourcemap --format=cjs ./src/index.ts --outfile=lib/ski-interpreter.cjs.js",
|
|
29
31
|
"build-esm": "npx esbuild --bundle --sourcemap --format=esm ./src/index.ts --outfile=lib/ski-interpreter.mjs",
|
|
@@ -61,10 +63,10 @@
|
|
|
61
63
|
"eslint-plugin-import": "^2.29.1",
|
|
62
64
|
"mocha": "^10.2.0",
|
|
63
65
|
"nyc": "^15.1.0",
|
|
66
|
+
"typedoc": "^0.28.18",
|
|
64
67
|
"typescript": "^5.8.2"
|
|
65
68
|
},
|
|
66
69
|
"dependencies": {
|
|
67
|
-
"commander": "^14.0.3"
|
|
68
|
-
"zod": "^4.3.6"
|
|
70
|
+
"commander": "^14.0.3"
|
|
69
71
|
}
|
|
70
72
|
}
|