hclang 0.50.0 → 0.52.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 +144 -0
- package/esm/lib/frames/fourth-hash.js +30 -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, 007.43h, 007.43i, 007.44). The Count of the Denum is its rank `r`, and",
|
|
2797
|
+
"each geometry wants a definite number of slots for that rank: the simplex (SSL,",
|
|
2798
|
+
"`%`) `r+1`, the cross-polytope (KPSL, `%%%`) `2r` and the Cayley–Dickson signed",
|
|
2799
|
+
"basis (KDSL, `%%`) `2^r`. The stored loads are aligned to the wanted length:",
|
|
2800
|
+
"missing slots are 0 and excess slots wrap by index modulo the wanted length,",
|
|
2801
|
+
"adding into the slot they wrap to. The observer is the geometry's ordinary",
|
|
2802
|
+
"formula on that virtual array, so every Count has a defined reading under every",
|
|
2803
|
+
"observer, Count zero included. `.#%` is not applied and is unchanged. The `##`",
|
|
2804
|
+
"spelling answers a squared magnitude, exact and nonnegative: a Count when whole",
|
|
2805
|
+
"and a rational otherwise. The `###` spelling answers a fresh list of signed",
|
|
2806
|
+
"coordinates, never a Denum and never a single number. They are observations",
|
|
2807
|
+
"only: no load, native observer or operator changes, and no algebra product is",
|
|
2808
|
+
"installed",
|
|
2809
|
+
"",
|
|
2810
|
+
"The centered simplex, `%`, places the `r+1` slots on the vertices of a regular",
|
|
2811
|
+
"simplex centred at zero. `.##%` is `(C·Σbi² − S²)/(C−1)` with `S = Σbi` and",
|
|
2812
|
+
"`C = r+1`, and `.###%` is the centred coefficients `bi − S/C`, which sum to",
|
|
2813
|
+
"zero. Adding the same amount to every slot changes neither, and rank 0 is the",
|
|
2814
|
+
"degenerate simplex, of magnitude 0",
|
|
2815
|
+
"```",
|
|
2816
|
+
"; .Sd (Denum [2, [2, 5, 3, 7, 4]]);",
|
|
2817
|
+
"; [Sd.##%, Sd.###%, “” Sd]",
|
|
2818
|
+
"# [36, [2, 2, -4], “Denum(2,[2, 5, 3, 7, 4])”]",
|
|
2819
|
+
"; [(Denum [1, [3, 1]]).##%, (Denum [3, [2, 4, 2, 4]]).##%, (Denum [2, [1]]).###%, (Denum [2, [4, 4, 4]]).##%, (Denum [0, [5, 3]]).###%]",
|
|
2820
|
+
"# [4, 16/3, [2/3, -1/3, -1/3], 0, [0]]",
|
|
2821
|
+
"```",
|
|
2822
|
+
"The Cayley–Dickson signed-basis observers, `%%`, read `2^r` slots in the",
|
|
2823
|
+
"reference order `+e0 … +e(n−1), −e0 … −e(n−1)` with `n = 2^(r−1)`. `.###%%` is",
|
|
2824
|
+
"`ri = vi − v(i+n)`, i = 0 … n−1, including the real coordinate; at rank 0 it is",
|
|
2825
|
+
"the single value. `.##%%` is `Σ ri²`. Each antipodal pair cancels on its own, so",
|
|
2826
|
+
"the load `[2, 4, 2, 4]` at rank 2 reads `[0, 0]` and `0`, and `[3, 2, 1, 4]`",
|
|
2827
|
+
"reads `[2, -2]` and `8`. Equal magnitudes would not make products agree, and no",
|
|
2828
|
+
"Cayley–Dickson product is installed",
|
|
2829
|
+
"```",
|
|
2830
|
+
"; [(Denum [2, [2, 4, 2, 4]]).###%%, (Denum [2, [2, 4, 2, 4]]).##%%, (Denum [2, [3, 2, 1, 4]]).###%%, (Denum [2, [3, 2, 1, 4]]).##%%]",
|
|
2831
|
+
"# [[0, 0], 0, [2, -2], 8]",
|
|
2832
|
+
"; [(Denum [0, [5, 3, 9]]).###%%, (Denum [1, [5, 3, 9]]).###%%, (Denum [3, [9, 1, 2, 3, 4, 5, 6, 7]]).###%%, (Denum [2, [3, 1]]).##%%]",
|
|
2833
|
+
"# [[17], [11], [5, -4, -4, -4], 10]",
|
|
2834
|
+
"```",
|
|
2835
|
+
"The cross-polytope observers, `%%%`, place `2r` slots on the vertices",
|
|
2836
|
+
"`+e0 … +e(r−1), −e0 … −e(r−1)`, so `bi` and `b(i+r)` are opposite. `.###%%%` is",
|
|
2837
|
+
"the antipodal residual `ri = bi − b(i+r)` and `.##%%%` is `Σ ri²`, zero exactly",
|
|
2838
|
+
"when every opposite pair matches. Rank 0 wants no slots and reads `[]` and 0",
|
|
2839
|
+
"```",
|
|
2840
|
+
"; [(Denum [2, [2, 4, 2, 4]]).###%%%, (Denum [2, [2, 4, 2, 4]]).##%%%, (Denum [3, [5, 2, 3, 5, 1, 3]]).###%%%, (Denum [3, [5, 2, 3, 5, 1, 3]]).##%%%, (Denum [1, [3, 1]]).###%%%]",
|
|
2841
|
+
"# [[0, 0], 0, [0, 1, 0], 1, [2]]",
|
|
2842
|
+
"; [(Denum [0, [1]]).###%%%, (Denum [1, [5]]).##%%%, (Denum [2, [1, 2]]).###%%%]",
|
|
2843
|
+
"# [[], 25, [1, 2]]",
|
|
2844
|
+
"```",
|
|
2845
|
+
"Only a Denum is observed, and no class can declare an observer of its own. A",
|
|
2846
|
+
"rank whose wanted slots pass the binding capacity of 65536 is refused",
|
|
2847
|
+
"```",
|
|
2848
|
+
"; [[5, 3].##%, 3.###%%, (Denum [70000, [1]]).###%, (Denum [17, [1]]).##%%, [.##% {7}].##%]",
|
|
2849
|
+
"# [$!.denum-binding-receiver, $!.denum-binding-receiver, $!.denum-binding-capacity, $!.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 [1, [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,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Geometric observers of a Denum, read by rank (occurrence/figure 007.41b,
|
|
3
|
+
* 007.41c, 007.43h, 007.43i, 007.44). They read a Denum and answer numbers and
|
|
4
|
+
* lists, and change nothing native.
|
|
5
|
+
*
|
|
6
|
+
* The Count of the Denum is the rank `r`. Each geometry wants a definite
|
|
7
|
+
* number of slots for that rank, and the Denum's stored loads are aligned to
|
|
8
|
+
* it into a virtual array: missing slots are 0, and excess slots wrap by index
|
|
9
|
+
* modulo the wanted length, their loads adding into the slot they wrap to, as
|
|
10
|
+
* `.#%` folds. The residual is then the geometry's ordinary formula on that
|
|
11
|
+
* virtual array, so every Count has a defined reading under every observer.
|
|
12
|
+
* The Count binding `.#%` itself is unchanged and is not applied here.
|
|
13
|
+
*
|
|
14
|
+
* | Geometry | Size-like | Residual-like | Wanted slots |
|
|
15
|
+
* | --- | --- | --- | --- |
|
|
16
|
+
* | centered simplex (SSL) `%` | `.##%` | `.###%` | r + 1 |
|
|
17
|
+
* | cross-polytope (KPSL) `%%%` | `.##%%%` | `.###%%%` | 2r |
|
|
18
|
+
* | Cayley–Dickson signed basis (KDSL) `%%` | `.##%%` | `.###%%` | 2ʳ |
|
|
19
|
+
*
|
|
20
|
+
* KDSL (007.43h) reads signed basis pairs: at rank 0 the single value, at rank
|
|
21
|
+
* r ≥ 1 the 2^(r−1) differences `vᵢ − v(i+2^(r−1))`. Its Size-like is the sum
|
|
22
|
+
* of their squares. A wanted length past `DENUM_BINDING_CAPACITY` is refused as
|
|
23
|
+
* `$!.denum-binding-capacity`.
|
|
24
|
+
*
|
|
25
|
+
* Return types: a squared magnitude is exact and nonnegative, a FrameCount
|
|
26
|
+
* when whole and a FrameRational otherwise. Coordinates are a fresh array of
|
|
27
|
+
* signed exact numbers, never a Denum. No native observer, operator or Denum
|
|
28
|
+
* load changes, and no algebra product is installed.
|
|
29
|
+
*
|
|
30
|
+
* @module
|
|
31
|
+
*/
|
|
32
|
+
import { Frame } from "./frame.js";
|
|
33
|
+
import { FrameArray } from "./frame-array.js";
|
|
34
|
+
import { FrameCount } from "./frame-count.js";
|
|
35
|
+
import { FrameInt } from "./frame-int.js";
|
|
36
|
+
import { FrameRational } from "./frame-rational.js";
|
|
37
|
+
import { DENUM_BINDING_CAPACITY, denumState } from "./fourth-hash.js";
|
|
38
|
+
/** An exact nonnegative magnitude: a Count when whole, a rational otherwise. */
|
|
39
|
+
function magnitude(num, den) {
|
|
40
|
+
const value = FrameRational.create(num, den);
|
|
41
|
+
return value instanceof FrameInt ? new FrameCount(value.data) : value;
|
|
42
|
+
}
|
|
43
|
+
const sum = (values) => values.reduce((total, value) => total + value, 0n);
|
|
44
|
+
/**
|
|
45
|
+
* Centered simplex (SSL), `.##%`: `Q_S = (C·Σbᵢ² − S²)/(C−1)` with `S = Σbᵢ`, the
|
|
46
|
+
* squared length of `Σbᵢvᵢ` over the C unit vertices of a centered regular
|
|
47
|
+
* simplex. Count 1 is degenerate and answers 0.
|
|
48
|
+
*/
|
|
49
|
+
function simplexSize(loads) {
|
|
50
|
+
const c = BigInt(loads.length);
|
|
51
|
+
if (c === 1n)
|
|
52
|
+
return new FrameCount(0n);
|
|
53
|
+
const total = sum(loads);
|
|
54
|
+
const squares = sum(loads.map((load) => load * load));
|
|
55
|
+
return magnitude(c * squares - total * total, c - 1n);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Centered simplex, `.###%`: the centered coefficients `zᵢ = bᵢ − S/C`, whose
|
|
59
|
+
* numerators over C are `C·bᵢ − S` (007.41b §3). They sum to zero. They are
|
|
60
|
+
* coefficients on the C unit vertices, not orthonormal coordinates, so `.##%`
|
|
61
|
+
* is their norm in the simplex Gram metric, `C/(C−1)·Σzᵢ²` (007.41e).
|
|
62
|
+
*/
|
|
63
|
+
function simplexResidual(loads) {
|
|
64
|
+
const c = BigInt(loads.length);
|
|
65
|
+
const total = sum(loads);
|
|
66
|
+
return new FrameArray(loads.map((load) => FrameRational.create(c * load - total, c)));
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Cross-polytope (KPSL), 2n slots (007.41b §5.A): the slots sit on the
|
|
70
|
+
* vertices `+e₀ … +e(n−1), −e₀ … −e(n−1)`, so `bᵢ` and `b(i+n)` are opposite,
|
|
71
|
+
* and the antipodal residual is `rᵢ = bᵢ − b(i+n)`, i = 0 … n−1.
|
|
72
|
+
*/
|
|
73
|
+
function antipodalResidual(slots) {
|
|
74
|
+
const n = slots.length / 2;
|
|
75
|
+
return slots.slice(0, n).map((slot, i) => slot - slots[i + n]);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Cayley–Dickson signed basis (KDSL, 007.43h), 2ʳ slots in the reference order
|
|
79
|
+
* `+e₀ … +e(n−1), −e₀ … −e(n−1)`: rank 0 is the single value, and rank r ≥ 1
|
|
80
|
+
* is `Rᵢ = vᵢ − v(i+n)` with n = 2^(r−1). The real coordinate is included.
|
|
81
|
+
*/
|
|
82
|
+
function signedBasisResidual(slots) {
|
|
83
|
+
return slots.length === 1 ? [slots[0]] : antipodalResidual(slots);
|
|
84
|
+
}
|
|
85
|
+
const sumSquares = (values) => new FrameCount(sum(values.map((value) => value * value)));
|
|
86
|
+
const integers = (values) => new FrameArray(values.map((value) => new FrameInt(value)));
|
|
87
|
+
/**
|
|
88
|
+
* The geometries by the `%` suffix that follows `##` or `###`. Their keys are
|
|
89
|
+
* `Frame.GEOMETRY_SUFFIXES`, from which `Frame.GEOMETRIC_OBSERVERS` is spelled.
|
|
90
|
+
*/
|
|
91
|
+
export const GEOMETRIES = {
|
|
92
|
+
"%": {
|
|
93
|
+
wanted: (r) => r + 1n,
|
|
94
|
+
size: simplexSize,
|
|
95
|
+
residual: simplexResidual,
|
|
96
|
+
},
|
|
97
|
+
"%%": {
|
|
98
|
+
// 2ʳ, saturated so a huge rank is refused rather than computed.
|
|
99
|
+
wanted: (r) => r > 64n ? DENUM_BINDING_CAPACITY + 1n : 1n << r,
|
|
100
|
+
size: (slots) => sumSquares(signedBasisResidual(slots)),
|
|
101
|
+
residual: (slots) => integers(signedBasisResidual(slots)),
|
|
102
|
+
},
|
|
103
|
+
"%%%": {
|
|
104
|
+
wanted: (r) => 2n * r,
|
|
105
|
+
size: (slots) => sumSquares(antipodalResidual(slots)),
|
|
106
|
+
residual: (slots) => integers(antipodalResidual(slots)),
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Aligns stored loads to a wanted length: shorter is zero-filled, longer wraps
|
|
111
|
+
* by index modulo the wanted length, adding into the slot it wraps to.
|
|
112
|
+
*/
|
|
113
|
+
function align(loads, wanted) {
|
|
114
|
+
const slots = new Array(wanted).fill(0n);
|
|
115
|
+
if (wanted === 0)
|
|
116
|
+
return slots;
|
|
117
|
+
loads.forEach((load, index) => {
|
|
118
|
+
slots[index % wanted] += load;
|
|
119
|
+
});
|
|
120
|
+
return slots;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Answers one geometric observer of a source: recognizes the Denum, takes its
|
|
124
|
+
* Count as the rank, aligns its stored loads to the rank's wanted slots, and
|
|
125
|
+
* reads the virtual array.
|
|
126
|
+
*
|
|
127
|
+
* @param source The observed Frame.
|
|
128
|
+
* @param key One of `Frame.GEOMETRIC_OBSERVERS`.
|
|
129
|
+
* @returns The observation, or an error.
|
|
130
|
+
*/
|
|
131
|
+
function observeGeometry(source, key) {
|
|
132
|
+
const residual = key.startsWith("###");
|
|
133
|
+
const geometry = GEOMETRIES[key.slice(residual ? 3 : 2)];
|
|
134
|
+
const state = denumState(source);
|
|
135
|
+
if (state instanceof Frame)
|
|
136
|
+
return state;
|
|
137
|
+
const wanted = geometry.wanted(state.count);
|
|
138
|
+
if (wanted > DENUM_BINDING_CAPACITY) {
|
|
139
|
+
return Frame.error("$!.denum-binding-capacity");
|
|
140
|
+
}
|
|
141
|
+
const slots = align(state.loads, Number(wanted));
|
|
142
|
+
return residual ? geometry.residual(slots) : geometry.size(slots);
|
|
143
|
+
}
|
|
144
|
+
Frame.observeGeometry = observeGeometry;
|
|
@@ -127,6 +127,20 @@ 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 recognized Denum state of `source`, or the error `.#%` answers for a
|
|
137
|
+
* failed or non-Denum receiver. The rank observers (007.43i, 007.44) read this
|
|
138
|
+
* stored Count and the stored loads as they are, without binding.
|
|
139
|
+
*
|
|
140
|
+
* @param source The observed Frame.
|
|
141
|
+
* @returns The Count and stored loads, or the receiver's error.
|
|
142
|
+
*/
|
|
143
|
+
export function denumState(source) {
|
|
130
144
|
const failure = source.observationError();
|
|
131
145
|
if (failure)
|
|
132
146
|
return failure;
|
|
@@ -135,6 +149,21 @@ export function bindDenumCount(source) {
|
|
|
135
149
|
const state = recognizeDenum(source);
|
|
136
150
|
if (!state)
|
|
137
151
|
return Frame.error("$!.denum-binding-receiver");
|
|
152
|
+
return { count: state.count, loads: state.loads };
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The loads of `source.#%`, the C sums `bj = Σ ai` over `i mod C = j`, folded
|
|
156
|
+
* without building the bound Denum, or the binding's error in the order
|
|
157
|
+
* `bindDenumCount` documents. The geometric observers (007.41b) read these, so
|
|
158
|
+
* they consume the same genuine binding as `.#%` at no extra cost.
|
|
159
|
+
*
|
|
160
|
+
* @param source The observed Frame.
|
|
161
|
+
* @returns The C bound loads, or the binding's error.
|
|
162
|
+
*/
|
|
163
|
+
export function boundLoads(source) {
|
|
164
|
+
const state = denumState(source);
|
|
165
|
+
if (state instanceof Frame)
|
|
166
|
+
return state;
|
|
138
167
|
if (state.count === 0n)
|
|
139
168
|
return Frame.error("$!.denum-binding-zero-count");
|
|
140
169
|
if (state.count > DENUM_BINDING_CAPACITY) {
|
|
@@ -145,7 +174,7 @@ export function bindDenumCount(source) {
|
|
|
145
174
|
state.loads.forEach((load, index) => {
|
|
146
175
|
bound[index % arity] += load;
|
|
147
176
|
});
|
|
148
|
-
return
|
|
177
|
+
return bound;
|
|
149
178
|
}
|
|
150
179
|
/**
|
|
151
180
|
* 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.52.0";
|