hclang 0.50.0 → 0.51.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/esm/lib/bundle/hc-sources.js +68 -2
- package/esm/lib/frames/denum-observers.js +181 -0
- package/esm/lib/frames/fourth-hash.js +16 -1
- package/esm/lib/frames/frame-name.js +12 -20
- package/esm/lib/frames/frame.js +31 -2
- package/esm/lib/frames.js +2 -0
- package/esm/lib/version.js +1 -1
- package/package.json +1 -1
|
@@ -2784,12 +2784,78 @@ export const HC_SOURCES = new Map([
|
|
|
2784
2784
|
"; [Edge.#, (Edge.loads).#, Edge.##, (Edge.loads) .0, (Edge.loads) .1, (Edge.loads) .65535, (Denum [65537, [1, 2]]).#%]",
|
|
2785
2785
|
"# [65536, 65536, 3, 1, 2, 0, $!.denum-binding-capacity]",
|
|
2786
2786
|
"```",
|
|
2787
|
-
"`.#%` is one token. `.#`, `%%` and a comment are read as before
|
|
2788
|
-
"
|
|
2787
|
+
"`.#%` is one token. `.#`, `%%` and a comment are read as before. A name is",
|
|
2788
|
+
"never split, so `.#%%` is one unbound name rather than `.#%` before a `%`: write",
|
|
2789
|
+
"`.# %%` for the modulo",
|
|
2789
2790
|
"```",
|
|
2790
2791
|
"; [[5, 3, 1].# %% 2, (Denum [3, [1]]).# %% 2, (Denum [3, [1]]).#% .#] # a comment after",
|
|
2791
2792
|
"# [1, 1, 3]",
|
|
2792
2793
|
"```",
|
|
2794
|
+
"## Geometric observers, `.##%` … `.###%%%`",
|
|
2795
|
+
"Six observers read a Denum through a geometry (occurrence/figure 007.41b,",
|
|
2796
|
+
"007.41c). Each first binds the Denum with `.#%`, so all of them read the same",
|
|
2797
|
+
"C loads `B = [b0, …, b(C−1)]`, and every refusal of `.#%` is theirs too. The",
|
|
2798
|
+
"`##` spelling answers a squared magnitude, exact and nonnegative: a Count when",
|
|
2799
|
+
"whole and a rational otherwise. The `###` spelling answers a fresh list of",
|
|
2800
|
+
"signed coordinates, never a Denum and never a single number. They are",
|
|
2801
|
+
"observations only: no load, native observer or operator changes, and no",
|
|
2802
|
+
"algebra product is installed",
|
|
2803
|
+
"",
|
|
2804
|
+
"The centered simplex, `%`, places the C loads on the vertices of a regular",
|
|
2805
|
+
"simplex centred at zero. `.##%` is `(C·Σbi² − S²)/(C−1)` with `S = Σbi`, and",
|
|
2806
|
+
"`.###%` is the centred coefficients `bi − S/C`, which sum to zero; their",
|
|
2807
|
+
"numerators over C are `C·bi − S`. Adding the same amount to every load",
|
|
2808
|
+
"changes neither, and Count 1 is the degenerate simplex, of magnitude 0",
|
|
2809
|
+
"```",
|
|
2810
|
+
"; .Sd (Denum [3, [2, 5, 3, 7, 4]]);",
|
|
2811
|
+
"; [Sd.##%, Sd.###%, (Sd.#%).##% = Sd.##%, “” Sd]",
|
|
2812
|
+
"# [36, [2, 2, -4], <>, “Denum(3,[2, 5, 3, 7, 4])”]",
|
|
2813
|
+
"; [(Denum [2, [3, 1]]).##%, (Denum [4, [2, 4, 2, 4]]).##%, (Denum [3, [1]]).###%, (Denum [3, [4, 4, 4]]).##%, (Denum [1, [5, 3]]).###%]",
|
|
2814
|
+
"# [4, 16/3, [2/3, -1/3, -1/3], 0, [0]]",
|
|
2815
|
+
"```",
|
|
2816
|
+
"The Cayley–Dickson observers, `%%`, need a Count that is a power of two, the",
|
|
2817
|
+
"dimension of a Cayley–Dickson algebra; any other Count is",
|
|
2818
|
+
"`$!.denum-cd-count`. They map the simplex coordinates isometrically onto the",
|
|
2819
|
+
"C−1 imaginary units with the fixed-sign Helmert basis of the 007.41",
|
|
2820
|
+
"experiment: `.###%%` is `[0, x1, …, x(C−1)]` with",
|
|
2821
|
+
"`xk = √(C/(C−1))·(b0 + … + b(k−1) − k·bk)/√(k(k+1))`, and `.##%%` is",
|
|
2822
|
+
"`Σ xk²`. Each `xk²` is rational, so `.##%%` is exact and equals `.##%`. A",
|
|
2823
|
+
"coordinate is exact when it is rational and a double where it has a radical.",
|
|
2824
|
+
"Equal magnitudes do not make the products agree: at C = 2, `B = [3, 1]` maps to",
|
|
2825
|
+
"`x = [0, 2]`, whose Cayley–Dickson square is −4, while the simplex magnitude is",
|
|
2826
|
+
"+4",
|
|
2827
|
+
"```",
|
|
2828
|
+
"; [(Denum [2, [3, 1]]).###%%, (Denum [2, [3, 1]]).##%%, (Denum [4, [2, 4, 2, 7]]).##%% = (Denum [4, [2, 4, 2, 7]]).##%, ((Denum [4, [2, 4, 2, 7]]).###%%) .3]",
|
|
2829
|
+
"# [[0, 2], 4, <>, -13/3]",
|
|
2830
|
+
"; [(Denum [3, [1]]).##%%, (Denum [6, [1]]).###%%, (Denum [1, [5]]).###%%]",
|
|
2831
|
+
"# [$!.denum-cd-count, $!.denum-cd-count, [0]]",
|
|
2832
|
+
"```",
|
|
2833
|
+
"The cross-polytope observers, `%%%`, place one load on each vertex of a",
|
|
2834
|
+
"cross-polytope, `C = 2n` vertices `+e0 … +e(n−1), −e0 … −e(n−1)`, so `bi` and",
|
|
2835
|
+
"`b(i+n)` are opposite. `.###%%%` is the antipodal residual `ri = bi − b(i+n)`",
|
|
2836
|
+
"and `.##%%%` is `Σ ri²`, zero exactly when every opposite pair matches. An odd",
|
|
2837
|
+
"Count has no such pairing and is `$!.denum-cross-count`; that refuses only this",
|
|
2838
|
+
"one-load-per-vertex binding, since a cross-polytope exists in every dimension n",
|
|
2839
|
+
"```",
|
|
2840
|
+
"; [(Denum [4, [2, 4, 2, 4]]).###%%%, (Denum [4, [2, 4, 2, 4]]).##%%%, (Denum [6, [5, 2, 3, 5, 1, 3]]).###%%%, (Denum [6, [5, 2, 3, 5, 1, 3]]).##%%%, (Denum [2, [3, 1]]).###%%%]",
|
|
2841
|
+
"# [[0, 0], 0, [0, 1, 0], 1, [2]]",
|
|
2842
|
+
"; [(Denum [3, [1]]).##%%%, (Denum [1, [1]]).###%%%]",
|
|
2843
|
+
"# [$!.denum-cross-count, $!.denum-cross-count]",
|
|
2844
|
+
"```",
|
|
2845
|
+
"Only a Denum is observed, as `.#%` binds only a Denum, and no class can declare",
|
|
2846
|
+
"an observer of its own",
|
|
2847
|
+
"```",
|
|
2848
|
+
"; [[5, 3].##%, 3.###%%, (Denum [0, [1]]).##%%%, (Denum [70000, [1]]).###%, [.##% {7}].##%]",
|
|
2849
|
+
"# [$!.denum-binding-receiver, $!.denum-binding-receiver, $!.denum-binding-zero-count, $!.denum-binding-capacity, $!.denum-binding-receiver]",
|
|
2850
|
+
"```",
|
|
2851
|
+
"Each observer is one token. A longer run, such as `.##%%%%`, is one unbound",
|
|
2852
|
+
"name, never an observer before a `%`.",
|
|
2853
|
+
"**Breaking:** `.##%%` and `.###%%` written without a space used to read as",
|
|
2854
|
+
"`.##` or `.###` before `%%`; write `.## %%` for the modulo",
|
|
2855
|
+
"```",
|
|
2856
|
+
"; [[5, 3, 1].## %% 2, [5, 3, 1].### %% 2, (Denum [2, [3, 1]]).##%.#]",
|
|
2857
|
+
"# [1, 1, 4]",
|
|
2858
|
+
"```",
|
|
2793
2859
|
"## Importing",
|
|
2794
2860
|
"",
|
|
2795
2861
|
"Imported, the file binds the same class. The import is an example line, so",
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Geometric observers of a Count-bound Denum (occurrence/figure 007.41b,
|
|
3
|
+
* 007.41c). They read a Denum and answer numbers and lists, and change nothing
|
|
4
|
+
* native.
|
|
5
|
+
*
|
|
6
|
+
* Each observer first applies the real Count binding `.#%` to its receiver,
|
|
7
|
+
* so every one of them reads the same bound loads `B = (C; [b0, …, b(C−1)])`,
|
|
8
|
+
* and every failure of `.#%` (a receiver that is not a Denum, Count zero, a
|
|
9
|
+
* Count past the binding capacity) is answered as it is. The six spellings
|
|
10
|
+
* pair a Size-like squared magnitude (`##…`) with a Residual-like list of
|
|
11
|
+
* signed coordinates (`###…`) for three geometries:
|
|
12
|
+
*
|
|
13
|
+
* | Geometry | Size-like | Residual-like | Count domain |
|
|
14
|
+
* | --- | --- | --- | --- |
|
|
15
|
+
* | centered simplex `%` | `.##%` | `.###%` | C ≥ 1 (C = 1 is zero) |
|
|
16
|
+
* | Cayley–Dickson imaginaries `%%` | `.##%%` | `.###%%` | C = 2ⁿ |
|
|
17
|
+
* | cross-polytope `%%%` | `.##%%%` | `.###%%%` | C = 2n, one load per vertex |
|
|
18
|
+
*
|
|
19
|
+
* Return types (007.41b §2): a squared magnitude is exact and nonnegative, a
|
|
20
|
+
* FrameCount when whole and a FrameRational otherwise. Coordinates are a fresh
|
|
21
|
+
* array of signed numbers, never a Denum: a FrameInt or FrameRational when the
|
|
22
|
+
* coordinate is rational, and an IEEE double (FrameNumber) only where it is
|
|
23
|
+
* irrational, which happens only for Cayley–Dickson coordinates. No native
|
|
24
|
+
* observer, operator or Denum load changes, and no algebra product is
|
|
25
|
+
* installed.
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
import { Frame } from "./frame.js";
|
|
30
|
+
import { FrameArray } from "./frame-array.js";
|
|
31
|
+
import { FrameCount } from "./frame-count.js";
|
|
32
|
+
import { FrameInt } from "./frame-int.js";
|
|
33
|
+
import { FrameNumber } from "./frame-number.js";
|
|
34
|
+
import { FrameRational } from "./frame-rational.js";
|
|
35
|
+
import { boundLoads } from "./fourth-hash.js";
|
|
36
|
+
/** An exact nonnegative magnitude: a Count when whole, a rational otherwise. */
|
|
37
|
+
function magnitude(num, den) {
|
|
38
|
+
const value = FrameRational.create(num, den);
|
|
39
|
+
return value instanceof FrameInt ? new FrameCount(value.data) : value;
|
|
40
|
+
}
|
|
41
|
+
/** The exact square root of a nonnegative bigint, or undefined. */
|
|
42
|
+
function exactRoot(value) {
|
|
43
|
+
if (value < 2n)
|
|
44
|
+
return value;
|
|
45
|
+
let root = value;
|
|
46
|
+
let next = (root + 1n) / 2n;
|
|
47
|
+
while (next < root) {
|
|
48
|
+
root = next;
|
|
49
|
+
next = (root + value / root) / 2n;
|
|
50
|
+
}
|
|
51
|
+
return root * root === value ? root : undefined;
|
|
52
|
+
}
|
|
53
|
+
const sum = (values) => values.reduce((total, value) => total + value, 0n);
|
|
54
|
+
/**
|
|
55
|
+
* Centered simplex, `.##%`: `Q_S = (C·Σbᵢ² − S²)/(C−1)` with `S = Σbᵢ`, the
|
|
56
|
+
* squared length of `Σbᵢvᵢ` over the C unit vertices of a centered regular
|
|
57
|
+
* simplex. Count 1 is degenerate and answers 0.
|
|
58
|
+
*
|
|
59
|
+
* It is also the Cayley–Dickson norm `.##%%`: the Helmert map φ_C is an
|
|
60
|
+
* isometry, so `N(φ_C(B)) = Σxₖ²` equals this form exactly. The identity is
|
|
61
|
+
* checked by test rather than computed twice.
|
|
62
|
+
*/
|
|
63
|
+
function simplexSize(loads) {
|
|
64
|
+
const c = BigInt(loads.length);
|
|
65
|
+
if (c === 1n)
|
|
66
|
+
return new FrameCount(0n);
|
|
67
|
+
const total = sum(loads);
|
|
68
|
+
const squares = sum(loads.map((load) => load * load));
|
|
69
|
+
return magnitude(c * squares - total * total, c - 1n);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Centered simplex, `.###%`: the centered coefficients `zᵢ = bᵢ − S/C`, whose
|
|
73
|
+
* numerators over C are `C·bᵢ − S` (007.41b §3). They sum to zero. They are
|
|
74
|
+
* coefficients on the C unit vertices, not orthonormal coordinates, so `.##%`
|
|
75
|
+
* is their norm in the simplex Gram metric, `C/(C−1)·Σzᵢ²` (007.41e).
|
|
76
|
+
*/
|
|
77
|
+
function simplexResidual(loads) {
|
|
78
|
+
const c = BigInt(loads.length);
|
|
79
|
+
const total = sum(loads);
|
|
80
|
+
return new FrameArray(loads.map((load) => FrameRational.create(c * load - total, c)));
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The Helmert numerators `sₖ = b₀ + … + b(k−1) − k·bₖ`, k = 1 … C−1, of the
|
|
84
|
+
* fixed-sign Helmert basis the 007.41 experiment's φ_C uses.
|
|
85
|
+
*/
|
|
86
|
+
function helmertNumerators(loads) {
|
|
87
|
+
const numerators = [];
|
|
88
|
+
let prefix = 0n;
|
|
89
|
+
for (let k = 1; k < loads.length; k++) {
|
|
90
|
+
prefix += loads[k - 1];
|
|
91
|
+
numerators.push(prefix - BigInt(k) * loads[k]);
|
|
92
|
+
}
|
|
93
|
+
return numerators;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Cayley–Dickson, `.###%%`: the coefficients `[0, x₁, …, x(C−1)]` of
|
|
97
|
+
* `x = φ_C(B)` on the basis `e₀ = 1, e₁, …`, with
|
|
98
|
+
* `xₖ = sₖ·√(C/((C−1)k(k+1)))`. Writing `d = (C−1)k(k+1)`, that is
|
|
99
|
+
* `sₖ·√(C·d)/d`, so a coordinate is the exact rational `sₖ·√m/d` when
|
|
100
|
+
* `m = C·d` is a perfect square, and a double otherwise, computed as the
|
|
101
|
+
* 007.41 experiment computes it. The real part is the exact 0. A double past
|
|
102
|
+
* the finite range is refused as `$!.numeric-range .###%%`, though `.##%%` of
|
|
103
|
+
* the same Denum stays exact: the two readings have different ranges by
|
|
104
|
+
* design (007.41e).
|
|
105
|
+
*/
|
|
106
|
+
function cdResidual(loads) {
|
|
107
|
+
const c = loads.length;
|
|
108
|
+
const coordinates = [new FrameInt(0n)];
|
|
109
|
+
const scale = c > 1 ? Math.sqrt(c / (c - 1)) : 0;
|
|
110
|
+
for (const [index, s] of helmertNumerators(loads).entries()) {
|
|
111
|
+
const k = BigInt(index + 1);
|
|
112
|
+
const d = BigInt(c - 1) * k * (k + 1n);
|
|
113
|
+
const root = s === 0n ? 0n : exactRoot(BigInt(c) * d);
|
|
114
|
+
if (root !== undefined) {
|
|
115
|
+
coordinates.push(FrameRational.create(s * root, d));
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const kk = index + 1;
|
|
119
|
+
const value = (scale * Number(s)) / Math.sqrt(kk * (kk + 1));
|
|
120
|
+
if (!Number.isFinite(value)) {
|
|
121
|
+
return Frame.error("$!.numeric-range .###%%");
|
|
122
|
+
}
|
|
123
|
+
coordinates.push(new FrameNumber(value));
|
|
124
|
+
}
|
|
125
|
+
return new FrameArray(coordinates);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Cross-polytope, one load per vertex (007.41b §5.A): C = 2n loads sit on the
|
|
129
|
+
* vertices `+e₀ … +e(n−1), −e₀ … −e(n−1)`, so `bᵢ` and `b(i+n)` are opposite,
|
|
130
|
+
* and the antipodal residual is `rᵢ = bᵢ − b(i+n)`, i = 0 … n−1.
|
|
131
|
+
*/
|
|
132
|
+
function antipodalResidual(loads) {
|
|
133
|
+
const n = loads.length / 2;
|
|
134
|
+
return loads.slice(0, n).map((load, i) => load - loads[i + n]);
|
|
135
|
+
}
|
|
136
|
+
/** Whether C is a power of two, the Cayley–Dickson dimensions. */
|
|
137
|
+
const isPowerOfTwo = (c) => c > 0 && (c & (c - 1)) === 0;
|
|
138
|
+
/**
|
|
139
|
+
* The geometries by the `%` suffix that follows `##` or `###`. Their keys are
|
|
140
|
+
* `Frame.GEOMETRY_SUFFIXES`, from which `Frame.GEOMETRIC_OBSERVERS` is spelled.
|
|
141
|
+
* Odd C has no antipodal pairing, so `$!.denum-cross-count` refuses only this
|
|
142
|
+
* binding, not odd-dimensional cross-polytopes.
|
|
143
|
+
*/
|
|
144
|
+
export const GEOMETRIES = {
|
|
145
|
+
"%": {
|
|
146
|
+
domain: () => undefined,
|
|
147
|
+
size: simplexSize,
|
|
148
|
+
residual: simplexResidual,
|
|
149
|
+
},
|
|
150
|
+
"%%": {
|
|
151
|
+
domain: (c) => isPowerOfTwo(c) ? undefined : Frame.error("$!.denum-cd-count"),
|
|
152
|
+
size: simplexSize,
|
|
153
|
+
residual: cdResidual,
|
|
154
|
+
},
|
|
155
|
+
"%%%": {
|
|
156
|
+
domain: (c) => c % 2 === 0 ? undefined : Frame.error("$!.denum-cross-count"),
|
|
157
|
+
size: (loads) => new FrameCount(sum(antipodalResidual(loads).map((r) => r * r))),
|
|
158
|
+
residual: (loads) => new FrameArray(antipodalResidual(loads).map((r) => new FrameInt(r))),
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Answers one geometric observer of a source: binds it with `.#%`, answering
|
|
163
|
+
* that binding's failure as it is, checks the geometry's Count domain once,
|
|
164
|
+
* then reads the bound loads.
|
|
165
|
+
*
|
|
166
|
+
* @param source The observed Frame.
|
|
167
|
+
* @param key One of `Frame.GEOMETRIC_OBSERVERS`.
|
|
168
|
+
* @returns The observation, or an error.
|
|
169
|
+
*/
|
|
170
|
+
function observeGeometry(source, key) {
|
|
171
|
+
const residual = key.startsWith("###");
|
|
172
|
+
const geometry = GEOMETRIES[key.slice(residual ? 3 : 2)];
|
|
173
|
+
const loads = boundLoads(source);
|
|
174
|
+
if (loads instanceof Frame)
|
|
175
|
+
return loads;
|
|
176
|
+
const refusal = geometry.domain(loads.length);
|
|
177
|
+
if (refusal)
|
|
178
|
+
return refusal;
|
|
179
|
+
return residual ? geometry.residual(loads) : geometry.size(loads);
|
|
180
|
+
}
|
|
181
|
+
Frame.observeGeometry = observeGeometry;
|
|
@@ -127,6 +127,21 @@ export const DENUM_BINDING_CAPACITY = 65536n;
|
|
|
127
127
|
* @returns The bound Denum, or an error.
|
|
128
128
|
*/
|
|
129
129
|
export function bindDenumCount(source) {
|
|
130
|
+
const bound = boundLoads(source);
|
|
131
|
+
if (bound instanceof Frame)
|
|
132
|
+
return bound;
|
|
133
|
+
return construct(new FrameCount(BigInt(bound.length)), bound.map((load) => new FrameCount(load)));
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The loads of `source.#%`, the C sums `bj = Σ ai` over `i mod C = j`, folded
|
|
137
|
+
* without building the bound Denum, or the binding's error in the order
|
|
138
|
+
* `bindDenumCount` documents. The geometric observers (007.41b) read these, so
|
|
139
|
+
* they consume the same genuine binding as `.#%` at no extra cost.
|
|
140
|
+
*
|
|
141
|
+
* @param source The observed Frame.
|
|
142
|
+
* @returns The C bound loads, or the binding's error.
|
|
143
|
+
*/
|
|
144
|
+
export function boundLoads(source) {
|
|
130
145
|
const failure = source.observationError();
|
|
131
146
|
if (failure)
|
|
132
147
|
return failure;
|
|
@@ -145,7 +160,7 @@ export function bindDenumCount(source) {
|
|
|
145
160
|
state.loads.forEach((load, index) => {
|
|
146
161
|
bound[index % arity] += load;
|
|
147
162
|
});
|
|
148
|
-
return
|
|
163
|
+
return bound;
|
|
149
164
|
}
|
|
150
165
|
/**
|
|
151
166
|
* The router path (007.27). A router of k channels routes to channel C mod k,
|
|
@@ -7,8 +7,14 @@ import { EvaluationScope } from "./evaluation-scope.js";
|
|
|
7
7
|
import { completeAtEnd, includeOrReserve } from "./atom-syntax.js";
|
|
8
8
|
import { authorizedReceiverWriteTarget } from "./bound-method.js";
|
|
9
9
|
import { ScanDisposition, } from "../scan.js";
|
|
10
|
+
/**
|
|
11
|
+
* Inside a name, `#` is an operator character like `%`. Elsewhere it opens a
|
|
12
|
+
* comment, but after the dot it spells the size operators `.#` … `.####`, the
|
|
13
|
+
* Count binding `.#%` and the geometric observers, so it joins the run.
|
|
14
|
+
*/
|
|
15
|
+
const isOperatorChar = (char) => char === Frame.kCOUNT || FrameOperator.Accepts(char);
|
|
10
16
|
/** A name accepts identifier and operator characters alike. */
|
|
11
|
-
const includes = (char) => FrameSymbol.SYMBOL_CHAR.test(char) ||
|
|
17
|
+
const includes = (char) => FrameSymbol.SYMBOL_CHAR.test(char) || isOperatorChar(char);
|
|
12
18
|
/** A name continues while its spelling stays one kind of identifier. */
|
|
13
19
|
const recognizeName = (symbol, source = "") => {
|
|
14
20
|
const char = symbol.toString();
|
|
@@ -26,23 +32,6 @@ const recognizeName = (symbol, source = "") => {
|
|
|
26
32
|
(source.endsWith("^") && source !== "<^")) {
|
|
27
33
|
return { disposition: ScanDisposition.CompleteRedispatch };
|
|
28
34
|
}
|
|
29
|
-
// `#` begins a comment except where it spells a size operator, `.#`, `.##`
|
|
30
|
-
// `.###`, `.####` or the Count binding `.#%` (011.18, 007.40). A fifth hash
|
|
31
|
-
// starts a comment; `.foo#bar` still ends at its first hash.
|
|
32
|
-
// `.#%%` cannot be split back into `.#` and `%%` once `%` is consumed, so it
|
|
33
|
-
// is refused rather than read as `.#%` before a `%`: write `.# %%`.
|
|
34
|
-
if (source === Frame.kBIND && char === "%") {
|
|
35
|
-
return {
|
|
36
|
-
disposition: ScanDisposition.Error,
|
|
37
|
-
message: "`.#%%` is ambiguous: write `.# %%` or `.#% %`",
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
if (Frame.SIZE_OPERATORS.includes(source + char)) {
|
|
41
|
-
return { disposition: ScanDisposition.Consume };
|
|
42
|
-
}
|
|
43
|
-
if (source.startsWith(Frame.kCOUNT)) {
|
|
44
|
-
return { disposition: ScanDisposition.CompleteRedispatch };
|
|
45
|
-
}
|
|
46
35
|
// `.^` needs no rule of its own: `^` is an operator character, so it is
|
|
47
36
|
// consumed and completed like any other name.
|
|
48
37
|
if (!includes(char)) {
|
|
@@ -53,9 +42,12 @@ const recognizeName = (symbol, source = "") => {
|
|
|
53
42
|
if (source.length === 0) {
|
|
54
43
|
return { disposition: ScanDisposition.Consume };
|
|
55
44
|
}
|
|
56
|
-
|
|
45
|
+
// An operator run is never split: `.%%%%`, `.##%%%%` and `.#####` are each
|
|
46
|
+
// one name, bound or not. An identifier ends where the kind changes, so
|
|
47
|
+
// `.foo#bar#` is `.foo` before a comment.
|
|
48
|
+
const startsWithOperator = isOperatorChar(source[0]);
|
|
57
49
|
const continuesIdentifier = char[0] === "-" && !startsWithOperator;
|
|
58
|
-
const sameKind =
|
|
50
|
+
const sameKind = isOperatorChar(char[0]) === startsWithOperator;
|
|
59
51
|
return {
|
|
60
52
|
disposition: continuesIdentifier || sameKind
|
|
61
53
|
? ScanDisposition.Consume
|
package/esm/lib/frames/frame.js
CHANGED
|
@@ -718,7 +718,8 @@ export class Frame extends MetaFrame {
|
|
|
718
718
|
return this.is.error || this.is.cyclicReference ? this : undefined;
|
|
719
719
|
}
|
|
720
720
|
/**
|
|
721
|
-
* Native Count, Size, residual
|
|
721
|
+
* Native Count, Size, residual, derived Denum, the Count binding `.#%` and
|
|
722
|
+
* the geometric observers. Missing Count falls back to
|
|
722
723
|
* Size, and missing residual to Count parity; kinds with their own rules
|
|
723
724
|
* (lists, schemas, Denum, all) supply them explicitly (011.18k, 011.18m).
|
|
724
725
|
* Nil has no Count, so no residual or Denum.
|
|
@@ -754,7 +755,7 @@ export class Frame extends MetaFrame {
|
|
|
754
755
|
case Frame.kBIND:
|
|
755
756
|
return Frame.bindCount(this);
|
|
756
757
|
default:
|
|
757
|
-
return Frame.
|
|
758
|
+
return Frame.observeGeometry(this, key);
|
|
758
759
|
}
|
|
759
760
|
}
|
|
760
761
|
/** Nonnegative represented quantity; path tracks recursive containment only. */
|
|
@@ -1154,6 +1155,33 @@ Object.defineProperty(Frame, "kBIND", {
|
|
|
1154
1155
|
writable: true,
|
|
1155
1156
|
value: "#%"
|
|
1156
1157
|
});
|
|
1158
|
+
/**
|
|
1159
|
+
* The `%` suffixes of the geometric observers of a Count-bound Denum
|
|
1160
|
+
* (occurrence/figure 007.41b, 007.41c): the centered simplex `%`, the
|
|
1161
|
+
* Cayley–Dickson imaginaries `%%` and the cross-polytope `%%%`. They key
|
|
1162
|
+
* `GEOMETRIES` in `denum-observers.ts`.
|
|
1163
|
+
*/
|
|
1164
|
+
Object.defineProperty(Frame, "GEOMETRY_SUFFIXES", {
|
|
1165
|
+
enumerable: true,
|
|
1166
|
+
configurable: true,
|
|
1167
|
+
writable: true,
|
|
1168
|
+
value: [
|
|
1169
|
+
"%",
|
|
1170
|
+
"%%",
|
|
1171
|
+
"%%%",
|
|
1172
|
+
]
|
|
1173
|
+
});
|
|
1174
|
+
/**
|
|
1175
|
+
* The geometric observers: for each of `GEOMETRY_SUFFIXES`, the Size-like
|
|
1176
|
+
* `##` then the Residual-like `###`. Each reads `.#%` of its receiver.
|
|
1177
|
+
*/
|
|
1178
|
+
Object.defineProperty(Frame, "GEOMETRIC_OBSERVERS", {
|
|
1179
|
+
enumerable: true,
|
|
1180
|
+
configurable: true,
|
|
1181
|
+
writable: true,
|
|
1182
|
+
value: Frame
|
|
1183
|
+
.GEOMETRY_SUFFIXES.flatMap((suffix) => [`##${suffix}`, `###${suffix}`])
|
|
1184
|
+
});
|
|
1157
1185
|
/**
|
|
1158
1186
|
* The size operators, the only names spelled with `#` (#411). Each answers
|
|
1159
1187
|
* for its receiver through `sizeFor`, never through name lookup.
|
|
@@ -1168,6 +1196,7 @@ Object.defineProperty(Frame, "SIZE_OPERATORS", {
|
|
|
1168
1196
|
Frame.kRESIDUAL,
|
|
1169
1197
|
Frame.kDENUM,
|
|
1170
1198
|
Frame.kBIND,
|
|
1199
|
+
...Frame.GEOMETRIC_OBSERVERS,
|
|
1171
1200
|
]
|
|
1172
1201
|
});
|
|
1173
1202
|
/**
|
package/esm/lib/frames.js
CHANGED
|
@@ -28,6 +28,8 @@ export { FrameNumeric, NUMERIC_RANK, } from "./frames/frame-numeric.js";
|
|
|
28
28
|
export { FrameInt } from "./frames/frame-int.js";
|
|
29
29
|
export { FrameCount } from "./frames/frame-count.js";
|
|
30
30
|
export { installDenumConstructor, installRouterRecognizer, observeDenum, } from "./frames/fourth-hash.js";
|
|
31
|
+
// Installs `Frame.observeGeometry`; the module exports no public API.
|
|
32
|
+
import "./frames/denum-observers.js";
|
|
31
33
|
export { FrameDecimal } from "./frames/frame-decimal.js";
|
|
32
34
|
export { FrameSequence } from "./frames/frame-sequence.js";
|
|
33
35
|
export { FrameTypedNumber } from "./frames/frame-typed-number.js";
|
package/esm/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.51.0";
|