@dallaylaen/ski-interpreter 2.8.0 → 2.8.2
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 +22 -0
- package/bin/ski.js +17 -0
- package/example/collatz.ski +30 -0
- package/example/eval.js +34 -0
- package/example/example-quests.json +83 -0
- package/example/mini-quest.html +42 -0
- package/example/reverse-linked-list.ski +14 -0
- package/example/t-foo-bar.ski +5 -0
- package/lib/ski-interpreter.cjs.js +78 -61
- package/lib/ski-interpreter.cjs.js.map +2 -2
- package/lib/ski-interpreter.min.js +5 -5
- package/lib/ski-interpreter.min.js.map +3 -3
- package/lib/ski-interpreter.mjs +78 -61
- package/lib/ski-interpreter.mjs.map +2 -2
- package/lib/ski-quest.min.js +4 -4
- package/lib/ski-quest.min.js.map +3 -3
- package/lib/types/extras.d.ts +37 -13
- package/lib/types/index.d.ts +1 -0
- package/package.json +2 -1
- package/lib/types/toposort.d.ts +0 -29
package/lib/types/extras.d.ts
CHANGED
|
@@ -51,17 +51,33 @@ export type SearchResult = {
|
|
|
51
51
|
gen: number;
|
|
52
52
|
cache?: Expr[][];
|
|
53
53
|
};
|
|
54
|
-
|
|
54
|
+
export type EquivResult = {
|
|
55
|
+
steps: number;
|
|
56
|
+
equal: boolean;
|
|
57
|
+
normal: boolean;
|
|
58
|
+
canonical: [Expr | null, Expr | null];
|
|
59
|
+
};
|
|
55
60
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
|
|
61
|
+
* Converts an unknown object into a FormatOptions, or returns an error it it is not valid.
|
|
62
|
+
* A null/undefined counts as an empty options object (and is thus valid).
|
|
63
|
+
*/
|
|
64
|
+
declare function checkFormatOptions(raw: unknown): {
|
|
65
|
+
value: FormatOptions;
|
|
66
|
+
} | {
|
|
67
|
+
error: Record<string, string>;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Find out if two expressions are computationally equivalent.
|
|
59
71
|
*
|
|
60
|
-
*
|
|
72
|
+
* Unlike equals(), this function will attempt to normalize both expressions
|
|
73
|
+
* before comparing.
|
|
61
74
|
*
|
|
62
75
|
* @experimental
|
|
76
|
+
* @param e1
|
|
77
|
+
* @param e2
|
|
78
|
+
* @param options
|
|
63
79
|
*/
|
|
64
|
-
declare function
|
|
80
|
+
declare function equiv(e1: Expr, e2: Expr, options?: {}): EquivResult;
|
|
65
81
|
/**
|
|
66
82
|
* Given an expression and a hash of named terms,
|
|
67
83
|
* return a semicolon-separated string that declares said expression
|
|
@@ -75,19 +91,27 @@ declare function deepFormat(obj: any, options?: FormatOptions): any;
|
|
|
75
91
|
*/
|
|
76
92
|
declare function declare(expr: Expr, env?: Record<string, Named>): string;
|
|
77
93
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
94
|
+
* Recursively replace all instances of Expr in a data structure with
|
|
95
|
+
* respective string representation using the format() options.
|
|
96
|
+
* Objects of other types and primitive values are eft as is.
|
|
97
|
+
*
|
|
98
|
+
* May be useful for debugging or diagnostic output.
|
|
99
|
+
*
|
|
100
|
+
* @experimental
|
|
80
101
|
*/
|
|
81
|
-
declare function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
102
|
+
declare function deepFormat(obj: any, options?: FormatOptions): any;
|
|
103
|
+
/**
|
|
104
|
+
* @experimental
|
|
105
|
+
* Look for an expression that matches the predicate,
|
|
106
|
+
* starting with the seed and applying the terms to one another.
|
|
107
|
+
*/
|
|
108
|
+
declare function search(seed: Expr[], options: SearchOptions, predicate: SearchCallback): SearchResult;
|
|
86
109
|
export declare const extras: {
|
|
87
110
|
search: typeof search;
|
|
88
111
|
deepFormat: typeof deepFormat;
|
|
89
112
|
declare: typeof declare;
|
|
90
113
|
toposort: typeof toposort;
|
|
91
114
|
checkFormatOptions: typeof checkFormatOptions;
|
|
115
|
+
equiv: typeof equiv;
|
|
92
116
|
};
|
|
93
117
|
export {};
|
package/lib/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dallaylaen/ski-interpreter",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.2",
|
|
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",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"README.md",
|
|
41
41
|
"LICENSE",
|
|
42
42
|
"CHANGELOG.md",
|
|
43
|
+
"example",
|
|
43
44
|
"lib"
|
|
44
45
|
],
|
|
45
46
|
"repository": {
|
package/lib/types/toposort.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Expr, Named } from './expr';
|
|
2
|
-
/**
|
|
3
|
-
* Sort a list in such a way that dependent terms come after the (named) terms they depend on.
|
|
4
|
-
* If env is given, only terms listed there are taken into account.
|
|
5
|
-
* If env is omitted, it will be implied from the list.
|
|
6
|
-
* If list is omitted, it will default to values of env.
|
|
7
|
-
* If just one term is given instead of a list, it will be coerced into a list.
|
|
8
|
-
*
|
|
9
|
-
* No terms outside env + list may ever appear in the result.
|
|
10
|
-
*
|
|
11
|
-
* The terms in env must be named and their names must match their keys.
|
|
12
|
-
*
|
|
13
|
-
* @param {Expr|Expr[]} list
|
|
14
|
-
* @param {{[s:string]: Named}} env
|
|
15
|
-
* @returns {{list: Expr[], env: {[s:string]: Named}}}
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* const expr = ski.parse(src);
|
|
19
|
-
* toposort([expr], ski.getTerms()); // returns all terms appearing in Expr in correct order
|
|
20
|
-
*/
|
|
21
|
-
export type ToposortResult = {
|
|
22
|
-
list: Expr[];
|
|
23
|
-
env: {
|
|
24
|
-
[s: string]: Named;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export declare function toposort(list: Expr[] | Expr | undefined, env: {
|
|
28
|
-
[s: string]: Named;
|
|
29
|
-
} | undefined): ToposortResult;
|