@mark1russell7/coeval 0.4.3 → 0.5.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 +2 -1
- package/build/index.d.ts +9 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +277 -34
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/errors.ts +4 -2
- package/src/generate.ts +11 -3
- package/src/index.ts +1 -1
- package/src/reference.ts +147 -3
- package/src/stdlib.ts +180 -27
package/README.md
CHANGED
|
@@ -33,8 +33,9 @@ A plan evaluates many times without a trace. `evaluate(machine, doc)` gives the
|
|
|
33
33
|
| The run side | `run`, `Runner`, `permits`, `narrow`, `partCaps` | Effects in order, parts at the same time, capabilities that only narrow, and an abort. The kernel narrows the capabilities of each part by the contract of its kind |
|
|
34
34
|
| Errors | `Result`, `EvalError`, `Failure`, `failures` | An error value has a code, a reason, a place and a cause. An evaluation does not throw |
|
|
35
35
|
| The static kit | `walk`, `refsOf`, `mapRefs`, `check` | The documents of a document in linear time, its free references, and its problems before a run, each with its place and its JSON path. A check narrows the capabilities as a run does. The hook `known` of a machine names the unknown operations |
|
|
36
|
+
| Trees | `STD_WORLD` (`panel`, `box`), `nearestWalker` | The decorated tree: each field of a node is an attribute that evaluates on demand, one time in an evaluation. A sibling is a path through the parent, and a cycle gives `#CYCLE!` with its chain |
|
|
36
37
|
| The formula kit | `formulaMachine`, `FormulaProfile`, `formulaKnown` | The shared constructs `lit`, `ref`, `record`, `list`, `let`, `fn`, `call`, `if`, `and`, `or`, and the namespaces `ops` and `ext`. A profile gives the rules of a language, for example how the errors of two parts combine. An address gives a thing, not its value |
|
|
37
|
-
| One meaning | `agree`, `reference`, `formulaDefinitions`, `generate` | A reference interpreter that compiles nothing, and `agree`, which compares a plan with it and with the second tier of a language. `generate` builds random documents from the kind contracts |
|
|
38
|
+
| One meaning | `agree`, `reference`, `formulaDefinitions`, `STD_DEFINITIONS`, `generate` | A reference interpreter that compiles nothing, and `agree`, which compares a plan with it and with the second tier of a language. `generate` builds random documents from the kind contracts |
|
|
38
39
|
|
|
39
40
|
Each rule has an ID in [`docs/SPEC.md`](https://github.com/mark1russell7/coeval/blob/main/docs/SPEC.md), and each ID has a test. [The site](https://mark1russell7.github.io/coeval/) explains each idea with a live diagram.
|
|
40
41
|
|
package/build/index.d.ts
CHANGED
|
@@ -1841,6 +1841,11 @@ interface ReferenceOptions {
|
|
|
1841
1841
|
* @returns The result.
|
|
1842
1842
|
*/
|
|
1843
1843
|
export declare function reference(machine: Machine, doc: unknown, context?: Context, options?: ReferenceOptions): Result;
|
|
1844
|
+
/**
|
|
1845
|
+
* The definitions of the reference for the evaluators of the standard machine that need their own reading. The
|
|
1846
|
+
* reference uses them for the standard evaluators, also without the option `definitions`. It holds `tree.node`.
|
|
1847
|
+
*/
|
|
1848
|
+
export declare const STD_DEFINITIONS: Definitions;
|
|
1844
1849
|
/**
|
|
1845
1850
|
* This function gives the definitions of the formula kit for one profile. Each construct is a function evaluator in
|
|
1846
1851
|
* the most direct style. It shares no code with the compilers of `formulaEvaluators`, thus the two readings of the
|
|
@@ -2003,6 +2008,10 @@ interface GenerateOptions {
|
|
|
2003
2008
|
readonly own?: readonly string[];
|
|
2004
2009
|
/** The keys for the steps of a path after its root and its name. */
|
|
2005
2010
|
readonly keys?: readonly Key[];
|
|
2011
|
+
/** The roots that a path can start at. The default is each root. */
|
|
2012
|
+
readonly roots?: readonly Root[];
|
|
2013
|
+
/** The most steps of a path after its root and its name. The default is 2. */
|
|
2014
|
+
readonly steps?: number;
|
|
2006
2015
|
}
|
|
2007
2016
|
/**
|
|
2008
2017
|
* This function lists the types of a world: each kind and each alias, also in a namespace. A namespace with a
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["Shape","Part"],"sources":["../src/doc.ts","../src/errors.ts","../src/deref.ts","../src/world.ts","../src/ladder.ts","../src/classify.ts","../src/parts.ts","../src/evaluate.ts","../src/stdlib.ts","../src/order.ts","../src/context.ts","../src/static.ts","../src/formula.ts","../src/reference.ts","../src/agree.ts","../src/generate.ts"],"mappings":";;KACY,mDAAmD;YAAmC,cAAA;;;KAGtF;YAAuC,cAAA;;;KAGvC;;;;;;;;;;;KAYA,4BAA4B;WAAmB;WAAsB,gBAAgB;;;;;;KAMrF;;WAED,MAAM;;WAEN,OAAO;;WAEP;;WAEA,MAAM,SAAS;;;qBAIb;;;;;;;;wBASG,SAAS,iBAAiB,SAAS;;;;;;;;wBAanC,MAAM,QAAQ,YAAY,cAAc;;;;;;;wBAUxC,MAAM,iBAAiB,SAAS;;;;;;;;wBAWhC,UAAU,iBAAiB,SAAS;;;;;;;wBAcpC,SAAS,MAAM,mBAAmB;;;;;;;wBAalC,SAAS,MAAM;;;;;;;;;wBAqBf,WAAW,iBAAiB,SAAS,aAAa;;UAUjD;WACN,UAAU;;WAEV,QAAQ,SAAS,eAAe;;;;;;;;;;wBAW3B,OAAO,gBAAgB,4BAA4B;;;;;;;;;wBAqBnD,MAAM,MAAM,SAAS,OAAO,MAAM;WAAmB;WAAwB,MAAM;IAAgC;;;;;;;wBAUnH,OAAO,eAAe,SAAS;;;;;;;wBAU/B,OAAO,KAAK,WAAW;;;;;;;wBAevB,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;wBA+B1B,UAAU,YAAY;;;;KC5O1B;;KAkBA,YAAY;;;;;;;UAQP;WACN,MAAM;WACN;WACA,iBAAiB;WACjB;;;KAIC,OAAO;WAA0B;WAAmB,OAAO;;WAAiB;WAAoB,OAAO;;;KAGvG;WAAoB;WAAoB,OAAO;;;;;;;;wBAQ3C,GAAG,GAAG,OAAO,IAAI,OAAO;;;;;;;;;wBAYxB,KAAK,MAAM,WAAW,gBAAgB;WAAiB,iBAAiB;WAAgB;IAAyB;;;;;;;;;wBAejH,OAAO,GAAG,QAAQ,OAAO,IAAI,gBAAgB,QAAQ,OAAO;;;;;qBAS/D,gBAAgB;WAClB,OAAO;;;;;;EAOhB,YAAY,OAAO;;;;;;;;wBAaL,gBAAgB;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["Shape","Part"],"sources":["../src/doc.ts","../src/errors.ts","../src/deref.ts","../src/world.ts","../src/ladder.ts","../src/classify.ts","../src/parts.ts","../src/evaluate.ts","../src/stdlib.ts","../src/order.ts","../src/context.ts","../src/static.ts","../src/formula.ts","../src/reference.ts","../src/agree.ts","../src/generate.ts"],"mappings":";;KACY,mDAAmD;YAAmC,cAAA;;;KAGtF;YAAuC,cAAA;;;KAGvC;;;;;;;;;;;KAYA,4BAA4B;WAAmB;WAAsB,gBAAgB;;;;;;KAMrF;;WAED,MAAM;;WAEN,OAAO;;WAEP;;WAEA,MAAM,SAAS;;;qBAIb;;;;;;;;wBASG,SAAS,iBAAiB,SAAS;;;;;;;;wBAanC,MAAM,QAAQ,YAAY,cAAc;;;;;;;wBAUxC,MAAM,iBAAiB,SAAS;;;;;;;;wBAWhC,UAAU,iBAAiB,SAAS;;;;;;;wBAcpC,SAAS,MAAM,mBAAmB;;;;;;;wBAalC,SAAS,MAAM;;;;;;;;;wBAqBf,WAAW,iBAAiB,SAAS,aAAa;;UAUjD;WACN,UAAU;;WAEV,QAAQ,SAAS,eAAe;;;;;;;;;;wBAW3B,OAAO,gBAAgB,4BAA4B;;;;;;;;;wBAqBnD,MAAM,MAAM,SAAS,OAAO,MAAM;WAAmB;WAAwB,MAAM;IAAgC;;;;;;;wBAUnH,OAAO,eAAe,SAAS;;;;;;;wBAU/B,OAAO,KAAK,WAAW;;;;;;;wBAevB,SAAS,iBAAiB;;;;;;;;;;;;;;;;;;wBA+B1B,UAAU,YAAY;;;;KC5O1B;;KAkBA,YAAY;;;;;;;UAQP;WACN,MAAM;WACN;WACA,iBAAiB;WACjB;;;KAIC,OAAO;WAA0B;WAAmB,OAAO;;WAAiB;WAAoB,OAAO;;;KAGvG;WAAoB;WAAoB,OAAO;;;;;;;;wBAQ3C,GAAG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-
return error instanceof RangeError &&
|
|
302
|
+
return (error instanceof RangeError || error instanceof SyntaxError) && error.message.includes("call stack");
|
|
303
303
|
} catch {
|
|
304
304
|
return true;
|
|
305
305
|
}
|
|
@@ -2257,7 +2257,8 @@ const STD_WORLD = {
|
|
|
2257
2257
|
],
|
|
2258
2258
|
of: "number"
|
|
2259
2259
|
},
|
|
2260
|
-
|
|
2260
|
+
caps: [{ rule: "mask" }],
|
|
2261
|
+
summary: "A node of a tree. Each part is an attribute that evaluates on demand, one time, with the node as self."
|
|
2261
2262
|
},
|
|
2262
2263
|
box: {
|
|
2263
2264
|
verbs: {
|
|
@@ -2273,7 +2274,8 @@ const STD_WORLD = {
|
|
|
2273
2274
|
],
|
|
2274
2275
|
of: "number"
|
|
2275
2276
|
},
|
|
2276
|
-
|
|
2277
|
+
caps: [{ rule: "mask" }],
|
|
2278
|
+
summary: "A node of a tree, as panel. A formula in a box can read its parent and its siblings."
|
|
2277
2279
|
},
|
|
2278
2280
|
math: { kinds: {
|
|
2279
2281
|
sum: {
|
|
@@ -2390,53 +2392,167 @@ const STD_EVALUATORS = {
|
|
|
2390
2392
|
const found = resolve(data);
|
|
2391
2393
|
return found.ok ? ok(valueOfThing(found.thing)) : fail(found.code, found.reason);
|
|
2392
2394
|
},
|
|
2393
|
-
"tree.node": (input) => treeNode(input
|
|
2395
|
+
"tree.node": (input) => treeNode(input)
|
|
2394
2396
|
};
|
|
2397
|
+
/** The brand of a node of the decorated tree. Its value is the state that the kit reads. */
|
|
2398
|
+
const TREE_NODE = Symbol.for("coeval.tree.node");
|
|
2399
|
+
const BUSY = Object.freeze({ busy: true });
|
|
2400
|
+
/** The attributes in evaluation, in the order of their demands. An evaluation does not wait, thus one list serves. */
|
|
2401
|
+
const demands = [];
|
|
2402
|
+
function attributeText(key, type, place) {
|
|
2403
|
+
return `${key} of ${type} at [${place.join(", ")}]`;
|
|
2404
|
+
}
|
|
2405
|
+
/** This function gives the `#CYCLE!` of a demand that reached an attribute in evaluation, with the chain of demands. */
|
|
2406
|
+
function cycleAt(cells, key, text) {
|
|
2407
|
+
const first = demands.findIndex((demand) => demand.cells === cells && demand.key === key);
|
|
2408
|
+
const chain = first === -1 ? [text] : demands.slice(first).map((demand) => demand.text);
|
|
2409
|
+
chain.push(text);
|
|
2410
|
+
return fail("#CYCLE!", `The attributes form a cycle: ${chain.join(" -> ")}.`);
|
|
2411
|
+
}
|
|
2412
|
+
function stateOf(thing) {
|
|
2413
|
+
return typeof thing === "object" && thing !== null ? thing[TREE_NODE] : void 0;
|
|
2414
|
+
}
|
|
2415
|
+
/** This function sets an own field, also the field `__proto__` (SHAPE.PROTO). */
|
|
2416
|
+
function putField(target, key, value) {
|
|
2417
|
+
Object.defineProperty(target, key, {
|
|
2418
|
+
value,
|
|
2419
|
+
enumerable: true,
|
|
2420
|
+
writable: true,
|
|
2421
|
+
configurable: true
|
|
2422
|
+
});
|
|
2423
|
+
}
|
|
2395
2424
|
/**
|
|
2396
|
-
* This function
|
|
2397
|
-
* it
|
|
2425
|
+
* This function gives a value with the JSON of each node of a tree in it. A list or a plain record is new only when
|
|
2426
|
+
* it holds a node. A container that holds itself stays as it is.
|
|
2398
2427
|
*/
|
|
2399
|
-
function
|
|
2400
|
-
const
|
|
2428
|
+
function plainOf(value, path) {
|
|
2429
|
+
const state = stateOf(value);
|
|
2430
|
+
if (state !== void 0) {
|
|
2431
|
+
if (path.has(value)) return fail("#CYCLE!", `The JSON of the node ${state.type} at [${state.place.join(", ")}] holds the node itself.`);
|
|
2432
|
+
return state.json(path);
|
|
2433
|
+
}
|
|
2434
|
+
if (typeof value !== "object" || value === null || path.has(value) || isHostThing(value)) return ok(value);
|
|
2435
|
+
if (!Array.isArray(value) && !isRecord(value)) return ok(value);
|
|
2436
|
+
path.add(value);
|
|
2437
|
+
try {
|
|
2438
|
+
if (Array.isArray(value)) {
|
|
2439
|
+
let list;
|
|
2440
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
2441
|
+
const item = plainOf(value[index], path);
|
|
2442
|
+
if (!item.ok) return item;
|
|
2443
|
+
if (item.value !== value[index]) (list ??= [...value])[index] = item.value;
|
|
2444
|
+
}
|
|
2445
|
+
return ok(list ?? value);
|
|
2446
|
+
}
|
|
2447
|
+
const record = value;
|
|
2448
|
+
let out;
|
|
2449
|
+
for (const key of Object.keys(record)) {
|
|
2450
|
+
const item = plainOf(record[key], path);
|
|
2451
|
+
if (!item.ok) return item;
|
|
2452
|
+
if (item.value === record[key]) continue;
|
|
2453
|
+
if (out === void 0) {
|
|
2454
|
+
out = {};
|
|
2455
|
+
for (const other of Object.keys(record)) putField(out, other, record[other]);
|
|
2456
|
+
}
|
|
2457
|
+
putField(out, key, item.value);
|
|
2458
|
+
}
|
|
2459
|
+
return ok(out ?? value);
|
|
2460
|
+
} finally {
|
|
2461
|
+
path.delete(value);
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
/**
|
|
2465
|
+
* This function makes a node of the decorated tree. A step `parent` gives the self of the context of the node, and a
|
|
2466
|
+
* step `type` gives its type. A step with the key of a part reads that attribute. A failed attribute throws `Failure`
|
|
2467
|
+
* with its own error, thus a reference to it gives that error.
|
|
2468
|
+
*/
|
|
2469
|
+
function treeThing(parts, context, type, place, build) {
|
|
2470
|
+
const cells = /* @__PURE__ */ new Map();
|
|
2401
2471
|
const read = (key) => {
|
|
2402
|
-
const
|
|
2403
|
-
if (
|
|
2472
|
+
const cell = cells.get(key);
|
|
2473
|
+
if (cell !== void 0) return cell.busy ? cycleAt(cells, key, attributeText(key, type, place)) : cell.result;
|
|
2404
2474
|
const part = parts.find((item) => item.key === key);
|
|
2405
2475
|
if (part === void 0) return void 0;
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2476
|
+
cells.set(key, BUSY);
|
|
2477
|
+
demands.push({
|
|
2478
|
+
cells,
|
|
2479
|
+
key,
|
|
2480
|
+
text: attributeText(key, type, place)
|
|
2481
|
+
});
|
|
2482
|
+
let result;
|
|
2483
|
+
try {
|
|
2484
|
+
result = part.evaluate({
|
|
2485
|
+
...context,
|
|
2486
|
+
self: node
|
|
2487
|
+
});
|
|
2488
|
+
} catch (error) {
|
|
2489
|
+
cells.delete(key);
|
|
2490
|
+
throw error;
|
|
2491
|
+
} finally {
|
|
2492
|
+
demands.pop();
|
|
2493
|
+
}
|
|
2494
|
+
cells.set(key, {
|
|
2495
|
+
busy: false,
|
|
2496
|
+
result
|
|
2409
2497
|
});
|
|
2410
|
-
memo.set(key, result);
|
|
2411
2498
|
return result;
|
|
2412
2499
|
};
|
|
2413
|
-
const
|
|
2500
|
+
const state = {
|
|
2501
|
+
build,
|
|
2502
|
+
type,
|
|
2503
|
+
place,
|
|
2504
|
+
json(path) {
|
|
2505
|
+
path.add(node);
|
|
2506
|
+
try {
|
|
2507
|
+
const out = {};
|
|
2508
|
+
for (const part of parts) {
|
|
2509
|
+
const result = read(part.key);
|
|
2510
|
+
if (!result.ok) return result;
|
|
2511
|
+
const value = plainOf(result.value, path);
|
|
2512
|
+
if (!value.ok) return value;
|
|
2513
|
+
putField(out, part.key, value.value);
|
|
2514
|
+
}
|
|
2515
|
+
return ok(out);
|
|
2516
|
+
} finally {
|
|
2517
|
+
path.delete(node);
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
};
|
|
2521
|
+
const node = {
|
|
2414
2522
|
[THING]: true,
|
|
2523
|
+
[TREE_NODE]: state,
|
|
2415
2524
|
type,
|
|
2416
2525
|
label: `node ${type}`,
|
|
2417
2526
|
deref(key) {
|
|
2418
2527
|
if (key === "parent") return context.self;
|
|
2419
2528
|
if (key === "type") return type;
|
|
2420
2529
|
const result = read(String(key));
|
|
2421
|
-
|
|
2530
|
+
if (result === void 0) return void 0;
|
|
2531
|
+
if (!result.ok) throw new Failure(result.error);
|
|
2532
|
+
return result.value;
|
|
2422
2533
|
},
|
|
2423
2534
|
toJson() {
|
|
2424
|
-
const
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
out[part.key] = result?.ok === true ? result.value : null;
|
|
2428
|
-
}
|
|
2429
|
-
return out;
|
|
2535
|
+
const result = state.json(/* @__PURE__ */ new Set());
|
|
2536
|
+
if (!result.ok) throw new Failure(result.error);
|
|
2537
|
+
return result.value;
|
|
2430
2538
|
}
|
|
2431
2539
|
};
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2540
|
+
return node;
|
|
2541
|
+
}
|
|
2542
|
+
/**
|
|
2543
|
+
* This function evaluates a node of the decorated tree. Inside an attribute of an open tree, the node gives its host
|
|
2544
|
+
* thing, and no attribute evaluates. Else the node is the root of a new tree, and it gives the JSON of the tree.
|
|
2545
|
+
*/
|
|
2546
|
+
function treeNode({ parts, context, kind, place }) {
|
|
2547
|
+
const above = stateOf(context.self);
|
|
2548
|
+
if (above !== void 0 && above.build.open) return ok(treeThing(parts, context, kind, place, above.build));
|
|
2549
|
+
const build = { open: true };
|
|
2550
|
+
const root = treeThing(parts, context, kind, place, build);
|
|
2551
|
+
try {
|
|
2552
|
+
return stateOf(root).json(/* @__PURE__ */ new Set());
|
|
2553
|
+
} finally {
|
|
2554
|
+
build.open = false;
|
|
2438
2555
|
}
|
|
2439
|
-
return ok(out);
|
|
2440
2556
|
}
|
|
2441
2557
|
function hostType(node, wanted) {
|
|
2442
2558
|
return isHostThing(node) && node.type === wanted;
|
|
@@ -3943,7 +4059,10 @@ function formulaMachine(profile = {}, more = {}) {
|
|
|
3943
4059
|
function own(table, name) {
|
|
3944
4060
|
return table !== void 0 && Object.hasOwn(table, name) ? table[name] : void 0;
|
|
3945
4061
|
}
|
|
3946
|
-
/**
|
|
4062
|
+
/**
|
|
4063
|
+
* This function finds the code of an evaluator name. A runner wins over an evaluator of the same name. A standard
|
|
4064
|
+
* evaluator gets the definition of the reference, unless the options give another definition (REF.TREE).
|
|
4065
|
+
*/
|
|
3947
4066
|
function choose(env, name) {
|
|
3948
4067
|
const runner = own(env.machine.runners, name);
|
|
3949
4068
|
if (runner !== void 0) {
|
|
@@ -3953,7 +4072,8 @@ function choose(env, name) {
|
|
|
3953
4072
|
}
|
|
3954
4073
|
const evaluator = own(env.machine.evaluators, name);
|
|
3955
4074
|
if (evaluator === void 0) return void 0;
|
|
3956
|
-
const
|
|
4075
|
+
const standard = evaluator === own(STD_EVALUATORS, name) ? own(STD_DEFINITIONS.evaluators, name) : void 0;
|
|
4076
|
+
const defined = own(env.definitions.evaluators, name) ?? standard;
|
|
3957
4077
|
if (defined !== void 0) return { evaluator: defined };
|
|
3958
4078
|
return typeof evaluator === "function" ? { evaluator } : { gap: `The reference has no definition of the compiled evaluator ${name}.` };
|
|
3959
4079
|
}
|
|
@@ -4218,6 +4338,126 @@ function reference(machine, doc, context = makeContext(), options = {}) {
|
|
|
4218
4338
|
return placed(thrown(error, "the reference"), []);
|
|
4219
4339
|
}
|
|
4220
4340
|
}
|
|
4341
|
+
const refNodes = /* @__PURE__ */ new WeakMap();
|
|
4342
|
+
/** The attributes in evaluation in the reference, in the order of their demands (TREE.CYCLE). */
|
|
4343
|
+
const inEvaluation = [];
|
|
4344
|
+
function nameOfAttribute(node, name) {
|
|
4345
|
+
return `${name} of ${node.kind} at [${node.place.join(", ")}]`;
|
|
4346
|
+
}
|
|
4347
|
+
function refNodeOf(thing) {
|
|
4348
|
+
return typeof thing === "object" && thing !== null ? refNodes.get(thing) : void 0;
|
|
4349
|
+
}
|
|
4350
|
+
/** TREE.ONCE, TREE.MEMO and TREE.CYCLE: the result of one attribute, or `undefined` when the node has no such part. */
|
|
4351
|
+
function attributeOf(node, self, name) {
|
|
4352
|
+
const done = node.values.get(name);
|
|
4353
|
+
if (done !== void 0) return done;
|
|
4354
|
+
if (node.pending.has(name)) {
|
|
4355
|
+
const from = inEvaluation.findIndex((entry) => entry.node === node && entry.name === name);
|
|
4356
|
+
return fail("#CYCLE!", `The attributes form a cycle: ${[...from < 0 ? [nameOfAttribute(node, name)] : inEvaluation.slice(from).map((entry) => nameOfAttribute(entry.node, entry.name)), nameOfAttribute(node, name)].join(" -> ")}.`);
|
|
4357
|
+
}
|
|
4358
|
+
const part = node.parts.find((item) => item.key === name);
|
|
4359
|
+
if (part === void 0) return void 0;
|
|
4360
|
+
node.pending.add(name);
|
|
4361
|
+
inEvaluation.push({
|
|
4362
|
+
node,
|
|
4363
|
+
name
|
|
4364
|
+
});
|
|
4365
|
+
try {
|
|
4366
|
+
const result = part.evaluate({
|
|
4367
|
+
...node.ctx,
|
|
4368
|
+
self
|
|
4369
|
+
});
|
|
4370
|
+
node.values.set(name, result);
|
|
4371
|
+
return result;
|
|
4372
|
+
} finally {
|
|
4373
|
+
node.pending.delete(name);
|
|
4374
|
+
inEvaluation.pop();
|
|
4375
|
+
}
|
|
4376
|
+
}
|
|
4377
|
+
/** TREE.RESULT: the JSON of a node. `open` holds the nodes and the containers whose JSON is in progress. */
|
|
4378
|
+
function jsonOfNode(node, self, open) {
|
|
4379
|
+
const record = {};
|
|
4380
|
+
for (const part of node.parts) {
|
|
4381
|
+
const result = attributeOf(node, self, part.key);
|
|
4382
|
+
if (!result.ok) return result;
|
|
4383
|
+
const value = plainValue(result.value, [...open, self]);
|
|
4384
|
+
if (!value.ok) return value;
|
|
4385
|
+
setField(record, part.key, value.value);
|
|
4386
|
+
}
|
|
4387
|
+
return ok(record);
|
|
4388
|
+
}
|
|
4389
|
+
/** This function gives a copy of a value with the JSON of each node in it. */
|
|
4390
|
+
function plainValue(value, open) {
|
|
4391
|
+
const node = refNodeOf(value);
|
|
4392
|
+
if (node !== void 0) {
|
|
4393
|
+
if (open.includes(value)) return fail("#CYCLE!", `The JSON of the node ${node.kind} at [${node.place.join(", ")}] holds the node itself.`);
|
|
4394
|
+
return jsonOfNode(node, value, open);
|
|
4395
|
+
}
|
|
4396
|
+
if (typeof value !== "object" || value === null || isHostThing(value) || open.includes(value)) return ok(value);
|
|
4397
|
+
if (Array.isArray(value)) {
|
|
4398
|
+
const items = [];
|
|
4399
|
+
for (const item of value) {
|
|
4400
|
+
const plain = plainValue(item, [...open, value]);
|
|
4401
|
+
if (!plain.ok) return plain;
|
|
4402
|
+
items.push(plain.value);
|
|
4403
|
+
}
|
|
4404
|
+
return ok(items);
|
|
4405
|
+
}
|
|
4406
|
+
if (!isRecord(value)) return ok(value);
|
|
4407
|
+
const copy = {};
|
|
4408
|
+
for (const key of Object.keys(value)) {
|
|
4409
|
+
const plain = plainValue(value[key], [...open, value]);
|
|
4410
|
+
if (!plain.ok) return plain;
|
|
4411
|
+
setField(copy, key, plain.value);
|
|
4412
|
+
}
|
|
4413
|
+
return ok(copy);
|
|
4414
|
+
}
|
|
4415
|
+
/**
|
|
4416
|
+
* TREE.LAZY, TREE.PARENT, TREE.SIBLING and TREE.ERROR: a node of an open tree gives its thing, and the root of a new
|
|
4417
|
+
* tree gives its JSON. A step on the thing reads an attribute, and a failed attribute throws its own error.
|
|
4418
|
+
*/
|
|
4419
|
+
const treeDefinition = ({ parts, context, kind, place }) => {
|
|
4420
|
+
const outer = refNodeOf(context.self);
|
|
4421
|
+
const nested = outer !== void 0 && outer.tree.open;
|
|
4422
|
+
const node = {
|
|
4423
|
+
tree: nested ? outer.tree : { open: true },
|
|
4424
|
+
kind,
|
|
4425
|
+
place,
|
|
4426
|
+
parts,
|
|
4427
|
+
ctx: context,
|
|
4428
|
+
values: /* @__PURE__ */ new Map(),
|
|
4429
|
+
pending: /* @__PURE__ */ new Set()
|
|
4430
|
+
};
|
|
4431
|
+
const self = {
|
|
4432
|
+
[THING]: true,
|
|
4433
|
+
type: kind,
|
|
4434
|
+
label: `node ${kind}`,
|
|
4435
|
+
deref: (key) => {
|
|
4436
|
+
if (key === "parent") return context.self;
|
|
4437
|
+
if (key === "type") return kind;
|
|
4438
|
+
const result = attributeOf(node, self, String(key));
|
|
4439
|
+
if (result === void 0 || result.ok) return result?.ok === true ? result.value : void 0;
|
|
4440
|
+
throw new Failure(result.error);
|
|
4441
|
+
},
|
|
4442
|
+
toJson: () => {
|
|
4443
|
+
const result = jsonOfNode(node, self, []);
|
|
4444
|
+
if (result.ok) return result.value;
|
|
4445
|
+
throw new Failure(result.error);
|
|
4446
|
+
}
|
|
4447
|
+
};
|
|
4448
|
+
refNodes.set(self, node);
|
|
4449
|
+
if (nested) return ok(self);
|
|
4450
|
+
try {
|
|
4451
|
+
return jsonOfNode(node, self, []);
|
|
4452
|
+
} finally {
|
|
4453
|
+
node.tree.open = false;
|
|
4454
|
+
}
|
|
4455
|
+
};
|
|
4456
|
+
/**
|
|
4457
|
+
* The definitions of the reference for the evaluators of the standard machine that need their own reading. The
|
|
4458
|
+
* reference uses them for the standard evaluators, also without the option `definitions`. It holds `tree.node`.
|
|
4459
|
+
*/
|
|
4460
|
+
const STD_DEFINITIONS = { evaluators: { "tree.node": treeDefinition } };
|
|
4221
4461
|
const CLOSURE$1 = Symbol.for("coeval.closure");
|
|
4222
4462
|
/** This function sets an own field, also the field `__proto__` (SHAPE.PROTO). */
|
|
4223
4463
|
function setField(target, key, value) {
|
|
@@ -4697,6 +4937,8 @@ function generate(world, options) {
|
|
|
4697
4937
|
const maxSize = options.maxSize ?? 24;
|
|
4698
4938
|
const malformed = options.malformed ?? .05;
|
|
4699
4939
|
const keys = options.keys ?? KEYS;
|
|
4940
|
+
const steps = options.steps ?? 2;
|
|
4941
|
+
const roots = options.roots ?? ROOTS;
|
|
4700
4942
|
const stepTypes = types.filter((type) => {
|
|
4701
4943
|
const found = lookupKind(world, type);
|
|
4702
4944
|
return found.ok && Object.hasOwn(found.kind.verbs, "step");
|
|
@@ -4774,11 +5016,12 @@ function generate(world, options) {
|
|
|
4774
5016
|
{ names: "a" },
|
|
4775
5017
|
["nowhere", "a"]
|
|
4776
5018
|
]);
|
|
4777
|
-
const
|
|
5019
|
+
const others = roots.filter((name) => name !== "names");
|
|
5020
|
+
const root = roots.includes("names") && pos.names.length > 0 && (others.length === 0 || rng.chance(.75)) || others.length === 0 ? "names" : rng.pick(others);
|
|
4778
5021
|
const path = [root];
|
|
4779
5022
|
if (root === "names") path.push(pickName(pos.names));
|
|
4780
5023
|
if (root === "world") path.push(String(rng.pick(types)[0]));
|
|
4781
|
-
for (let index = rng.int(
|
|
5024
|
+
for (let index = rng.int(steps + 1); index > 0; index -= 1) if (stepTypes.length > 0 && rng.chance(.2)) {
|
|
4782
5025
|
const type = rng.pick(stepTypes);
|
|
4783
5026
|
const kind = kindOf(type);
|
|
4784
5027
|
const value = refKind?.parts?.shape === "deep" && kind?.parts !== void 0 ? valueOf(kind.parts, [], {
|
|
@@ -5000,6 +5243,6 @@ function generate(world, options) {
|
|
|
5000
5243
|
});
|
|
5001
5244
|
}
|
|
5002
5245
|
//#endregion
|
|
5003
|
-
export { CONSTRUCTS, ENVELOPE_KEYS, Failure, Held, PARTS, PART_INFO, ROOTS, RUNGS, STD_CAPS, STD_EVALUATORS, STD_EXT, STD_MACHINE, STD_RUNNERS, STD_WALKERS, STD_WORLD, THING, agree, ask, capKeys, check, checkSteps, classify, context, dataEdges, derefStep, describe, docEquals, effectEdges, entriesAsJson, evaluate, fail, failures, field, flatten, formulaDefinitions, formulaEvaluators, formulaKinds, formulaKnown, formulaMachine, fromJson, generate, intersectCaps, isAlias, isAllowedOrder, isClosure, isEnvelope, isHostThing, isKey, isKind, isNamespace, isRecord, isRef, isStackOverflow, isTypeRef, jsTruthy, kindDocument, kindNamed, kindOf, layers, looksLikeKind, lookupKind, makeContext, mapRefs, narrow, nearestWalker, nodeAt, ok, partCaps, partsOf, pathMatches, permits, placed, planner, prepare, random, ref, reference, refsOf, resolve, run, sameValue, splitParts, stored, tag, thrown, toJson, typeName, typePath, typed, typesOf, valueOfThing, walk, worldThing };
|
|
5246
|
+
export { CONSTRUCTS, ENVELOPE_KEYS, Failure, Held, PARTS, PART_INFO, ROOTS, RUNGS, STD_CAPS, STD_DEFINITIONS, STD_EVALUATORS, STD_EXT, STD_MACHINE, STD_RUNNERS, STD_WALKERS, STD_WORLD, THING, agree, ask, capKeys, check, checkSteps, classify, context, dataEdges, derefStep, describe, docEquals, effectEdges, entriesAsJson, evaluate, fail, failures, field, flatten, formulaDefinitions, formulaEvaluators, formulaKinds, formulaKnown, formulaMachine, fromJson, generate, intersectCaps, isAlias, isAllowedOrder, isClosure, isEnvelope, isHostThing, isKey, isKind, isNamespace, isRecord, isRef, isStackOverflow, isTypeRef, jsTruthy, kindDocument, kindNamed, kindOf, layers, looksLikeKind, lookupKind, makeContext, mapRefs, narrow, nearestWalker, nodeAt, ok, partCaps, partsOf, pathMatches, permits, placed, planner, prepare, random, ref, reference, refsOf, resolve, run, sameValue, splitParts, stored, tag, thrown, toJson, typeName, typePath, typed, typesOf, valueOfThing, walk, worldThing };
|
|
5004
5247
|
|
|
5005
5248
|
//# sourceMappingURL=index.js.map
|