@dallaylaen/ski-interpreter 2.3.3 → 2.4.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 +16 -0
- package/README.md +9 -2
- package/bin/ski.js +10 -7
- package/lib/ski-interpreter.cjs.js +2082 -2211
- package/lib/ski-interpreter.cjs.js.map +4 -4
- package/lib/ski-interpreter.esm.js +2065 -2222
- package/lib/ski-interpreter.esm.js.map +4 -4
- package/lib/ski-interpreter.min.js +3 -3
- package/lib/ski-interpreter.min.js.map +4 -4
- package/lib/ski-quest.min.js +3 -3
- package/lib/ski-quest.min.js.map +4 -4
- package/{types/src → lib/types}/expr.d.ts +217 -252
- package/{types/src → lib/types}/extras.d.ts +24 -9
- package/lib/types/index.d.ts +68 -0
- package/{types/src → lib/types}/internal.d.ts +27 -23
- package/{types/src → lib/types}/parser.d.ts +40 -83
- package/lib/types/quest.d.ts +232 -0
- package/lib/types/toposort.d.ts +30 -0
- package/package.json +13 -12
- package/types/index.d.ts +0 -3
- package/types/src/quest.d.ts +0 -257
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.4.0] - 2026-03-06
|
|
9
|
+
|
|
10
|
+
### BREAKING CHANGES
|
|
11
|
+
|
|
12
|
+
- Remove Expr.freeOnly method, use `!this.any(e => !(e instanceof FreeVar || e instanceof App))` instead;
|
|
13
|
+
- Remove Expr.weight() function because it's too ambiguous, use `fold (...)` instead.
|
|
14
|
+
- Remove `{ Quest }` from exports, use `SKI.Quest` instead.
|
|
15
|
+
- Rename `ski.js quest-check` to `ski.js quest-lint` for clarity.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- Rewrite the whole thing in TypeScript.
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- Avoid name clashes with existing variables in infer()
|
|
22
|
+
([#15](https://github.com/dallaylaen/ski-interpreter/issues/15))
|
|
23
|
+
|
|
8
24
|
## [2.3.3] - 2026-03-01
|
|
9
25
|
|
|
10
26
|
### Changed
|
package/README.md
CHANGED
|
@@ -99,9 +99,16 @@ npm install @dallaylaen/ski-interpreter
|
|
|
99
99
|
* `--verbose` - Show all evaluation steps
|
|
100
100
|
* Example: `ski file script.ski`
|
|
101
101
|
|
|
102
|
-
* **`
|
|
102
|
+
* **`extract <expression> <known term> ...`** -
|
|
103
|
+
Replace parts of the expression that are equivalent to the known terms with the respective terms. Known terms must be normalizable.
|
|
104
|
+
|
|
105
|
+
* **`search <expression> <known term> ...`** -
|
|
106
|
+
Attempt to brute force an equivalent of the _expression_ using only the _known terms_.
|
|
107
|
+
Only normalizing terms are currently supported.
|
|
108
|
+
|
|
109
|
+
* **`quest-lint <files...>`** - Validate quest definition files
|
|
103
110
|
* `--solution <file>` - Load solutions from a JSON file for verification
|
|
104
|
-
* Example: `ski quest-
|
|
111
|
+
* Example: `ski quest-lint quest1.json quest2.json --solution solutions.json`
|
|
105
112
|
|
|
106
113
|
If no subcommand is provided, help is displayed.
|
|
107
114
|
|
package/bin/ski.js
CHANGED
|
@@ -4,14 +4,15 @@ const fs = require('node:fs/promises');
|
|
|
4
4
|
const { Command } = require('commander');
|
|
5
5
|
|
|
6
6
|
const { SKI } = require('../lib/ski-interpreter.cjs');
|
|
7
|
-
const { Quest } =
|
|
7
|
+
const { Quest } = SKI;
|
|
8
|
+
const { version } = require('../package.json');
|
|
8
9
|
|
|
9
10
|
const program = new Command();
|
|
10
11
|
|
|
11
12
|
program
|
|
12
13
|
.name('ski')
|
|
13
14
|
.description('Simple Kombinator Interpreter - a combinatory logic & lambda calculus parser and interpreter')
|
|
14
|
-
.version(
|
|
15
|
+
.version(version);
|
|
15
16
|
|
|
16
17
|
// REPL subcommand
|
|
17
18
|
program
|
|
@@ -58,7 +59,7 @@ program
|
|
|
58
59
|
|
|
59
60
|
// Quest-check subcommand
|
|
60
61
|
program
|
|
61
|
-
.command('quest-
|
|
62
|
+
.command('quest-lint <files...>')
|
|
62
63
|
.description('Check quest files for validity')
|
|
63
64
|
.option('--solution <file>', 'Load solutions from file')
|
|
64
65
|
.action((files, options) => {
|
|
@@ -214,7 +215,7 @@ async function questCheck (files, solutionFile) {
|
|
|
214
215
|
// Exit with appropriate code
|
|
215
216
|
process.exit(hasErrors ? 1 : 0);
|
|
216
217
|
} catch (err) {
|
|
217
|
-
console.error('Error in quest-
|
|
218
|
+
console.error('Error in quest-lint:', err.message);
|
|
218
219
|
process.exit(2);
|
|
219
220
|
}
|
|
220
221
|
}
|
|
@@ -264,9 +265,11 @@ function extractExpression (targetStr, termStrs) {
|
|
|
264
265
|
|
|
265
266
|
const replaced = expr.traverse(e => {
|
|
266
267
|
const canon = e.infer().expr;
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
if (canon) {
|
|
269
|
+
for (const [lambda, term] of pairs) {
|
|
270
|
+
if (canon.equals(lambda))
|
|
271
|
+
return term;
|
|
272
|
+
}
|
|
270
273
|
}
|
|
271
274
|
return null;
|
|
272
275
|
});
|