hclang 0.36.1 → 0.37.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.
@@ -1178,18 +1178,20 @@ export const HC_SOURCES = new Map([
1178
1178
  "comparison wrappers. Use native operations directly. Star `x * y` places y at each terminal of x, preserving nesting.",
1179
1179
  "Flat repetition is `x.## [y]`. A tally, when wanted, is an explicit",
1180
1180
  "construction, such as `x & {[[]]}` for one fresh mark per immediate element.",
1181
- "Native `.##` weights nested counts by their Size and other atoms by one;",
1182
- "native `.###` answers nil on",
1183
- "anything that is not a Figure, so this module's traversals stay in the domain.",
1181
+ "Native `.##` uses each child's native Size, including numeric magnitude and",
1182
+ "text length. Native `.###` also accepts mixed arrays and evaluated groups.",
1183
+ "Star keeps its narrower array/Count composition domain.",
1184
1184
  "",
1185
1185
  "Only observation operations remain: `withness`, `gap` and `spin`, with `pure` and `need` for domain validation.",
1186
1186
  "The traversals validate at their public boundary; their recursive steps use",
1187
1187
  "native operations directly. Withness returns a native boolean, `<>` or `()`.",
1188
1188
  "```",
1189
1189
  "```",
1190
- "Supported domain: `pure x` accepts nested arrays, ignoring their properties",
1191
- "and declared parents at every level, and rejects atoms, strings, groups, schemas and closures anywhere in them. It is",
1192
- "the native `.###` check: a FrameInt, even 0, is true, and nil is false.",
1190
+ "`pure x` retains its name for compatibility but now accepts the native residual",
1191
+ "domain: mixed arrays and evaluated groups with finite child Sizes. Properties",
1192
+ "and declared parents are ignored. Standalone atoms, schemas and closures have",
1193
+ "no residual. It is the native `.###` check: a FrameInt, even 0, is true,",
1194
+ "and nil is false. Helper retirement is deferred to occurrence/figure 010.09.",
1193
1195
  "```",
1194
1196
  ".pure {.x _; (x.###) ? {<>} : {()}};",
1195
1197
  "```",
@@ -1243,7 +1245,7 @@ export const HC_SOURCES = new Map([
1243
1245
  "Native terminal counting needs no enumeration or tally construction.",
1244
1246
  "```",
1245
1247
  "; [(pure []), (pure [[], [[]]]), (pure [[], 5]), (pure [.k 1; []])]",
1246
- "# [<>, <>, (), <>]",
1248
+ "# [<>, <>, <>, <>]",
1247
1249
  "; [(need e) = e, (need e) === e]",
1248
1250
  "# [<>, <>]",
1249
1251
  "; [[], “a”] * [[]]",
@@ -1251,7 +1253,7 @@ export const HC_SOURCES = new Map([
1251
1253
  "; (0 - 5) * [[]]",
1252
1254
  "# $!.star-domain *",
1253
1255
  "; gap ([], [[], []])",
1254
- "# $!.name-missing “$:Frame.0.unsupported-figure”;",
1256
+ "# 1",
1255
1257
  "```",
1256
1258
  "Properties and declared parents never decide the observer domain or an observation.",
1257
1259
  "Star preserves metadata on rebuilt nonterminal ancestors and leaves its host",
@@ -1292,7 +1294,7 @@ export const HC_SOURCES = new Map([
1292
1294
  "```",
1293
1295
  "Native `.###` folds the immediate elements' terminal counts with alternating",
1294
1296
  "signs, one sign per element, and answers a FrameInt even when it is 0 or",
1295
- "positive. Anything that is not a Figure answers nil.",
1297
+ "positive. Mixed arrays and evaluated groups use the same rule.",
1296
1298
  "```",
1297
1299
  "; [[].###, [[]].###, [[], []].###, [[], [[], []]].###, [[[], []], []].###]",
1298
1300
  "# [0, 1, 0, -1, 1]",
@@ -1303,7 +1305,20 @@ export const HC_SOURCES = new Map([
1303
1305
  "; [[[], [[]]], [[[], []], []], [[[[], [], []]]]].###",
1304
1306
  "# 2",
1305
1307
  "; [[1, []].###, [[], “ab”].###, [[], ([], [])].###, 5.###]",
1306
- "# [(), (), (), ()]",
1308
+ "# [0, -1, -1, ()]",
1309
+ "```",
1310
+ "Native Size also measures mixed values, independently of structural Star.",
1311
+ "Numeric magnitude truncates exactly; text length uses native Unicode code-point iteration,",
1312
+ "blob width uses bits, and schemas count declared alternatives.",
1313
+ "```",
1314
+ "; [(7.9).##, (-7.9).##, (-3).##, (0.9).##, 0.##, (-7 / 2).##]",
1315
+ "# [7, 7, 3, 0, 0, 3]",
1316
+ "; [“”.##, “hello”.##, “é😀”.##, 0x00ff.##]",
1317
+ "# [0, 5, 2, 16]",
1318
+ "; [(1).<>.##, <2, 3, 5>.##, <2, 2, [3, 5]>.##, <.a, .b>.##, <>.##]",
1319
+ "# [1, 3, 3, 1, 1]",
1320
+ "; [[5, “hello”].##, [5, “hello”].###, (5, 3).###, [5, 3, 2, 7].###]",
1321
+ "# [10, 0, 2, -3]",
1307
1322
  "```",
1308
1323
  "Gap is `|x.###|` and Spin is `x.### / N`, including shared branches at every",
1309
1324
  "occurrence. Reversing two unequal branches reverses Spin's sign.",
@@ -138,10 +138,10 @@ export class FrameArray extends FrameList {
138
138
  return true;
139
139
  }
140
140
  /**
141
- * Every array is a Figure node, read through its elements; its properties
142
- * and declared parent are ignored (010.04).
141
+ * An evaluated array exposes ordered data for residual; properties and
142
+ * declared parents are excluded.
143
143
  */
144
- isFigureNode() {
144
+ supportsResidual() {
145
145
  return true;
146
146
  }
147
147
  /**
@@ -71,6 +71,9 @@ export class FrameBlob extends FrameAtom {
71
71
  const digits = "0".repeat(pad) + dataString;
72
72
  return this.string_prefix() + digits + this.string_suffix();
73
73
  }
74
+ nativeSize() {
75
+ return this.n_bits;
76
+ }
74
77
  /** The exact rendered width of this blob, including leading zero bits. */
75
78
  bitLength() {
76
79
  return Number(this.n_bits);
@@ -91,6 +91,9 @@ export class FrameBytes extends FrameAtom {
91
91
  this.data = new Uint8Array(values);
92
92
  this.length = values.length;
93
93
  }
94
+ nativeSize() {
95
+ return BigInt(this.data.length);
96
+ }
94
97
  string_prefix() {
95
98
  return FrameBytes.BYTES_BEGIN;
96
99
  }
@@ -1,5 +1,6 @@
1
1
  import { completeAtEnd, includeOrReserve } from "./atom-syntax.js";
2
2
  import { NilContext } from "./context.js";
3
+ import { Frame } from "./frame.js";
3
4
  import { FrameInt } from "./frame-int.js";
4
5
  import { NUMERIC_RANK, } from "./frame-numeric.js";
5
6
  /**
@@ -74,3 +75,4 @@ Object.defineProperty(FrameCount, "SYNTAX", {
74
75
  fromSource: (source) => FrameCount.for(source),
75
76
  }
76
77
  });
78
+ Frame.count = (value) => new FrameCount(value);
@@ -81,6 +81,9 @@ export class FrameExpr extends FrameList {
81
81
  elements() {
82
82
  return atomsOf(this.data, sitesAround(this.data));
83
83
  }
84
+ sizeElements() {
85
+ return sizeAtomsOf(this.data);
86
+ }
84
87
  /** A parsed expression of one atom is that atom; anything else is itself. */
85
88
  walked() {
86
89
  if (!isPlainExpr(this))
@@ -112,6 +115,13 @@ export class FrameExpr extends FrameList {
112
115
  const value = item.in(resumedScope(item, scope));
113
116
  if (value.is.error === true)
114
117
  return value;
118
+ // An explicit nil receiver still has a Size. The initial nil accumulator
119
+ // is not a receiver, so a leading .## remains an address (#411).
120
+ if (index > 0 && sum.is.void && value instanceof FrameSymbol &&
121
+ value.is.address &&
122
+ [Frame.kLEAVES, Frame.kRESIDUAL].includes(value.spelling())) {
123
+ return value.called_by(sum);
124
+ }
115
125
  if (index > 0 && value.is.operator === true) {
116
126
  return value.called_by(sum, Frame.nil).atSite(scope);
117
127
  }
@@ -292,6 +302,53 @@ export function atomsOf(terms, sites = new Map(), resume) {
292
302
  }
293
303
  return atoms;
294
304
  }
305
+ /**
306
+ * The same represented words as a syntax walk, without recording scope sites or
307
+ * binding names. Compound atoms stay whole; only trivial wrappers are unwrapped.
308
+ * A malformed cyclic wrapper is refused before it can recurse forever.
309
+ */
310
+ export function sizeAtomsOf(terms) {
311
+ const atoms = [];
312
+ let cyclic = false;
313
+ const walkAtom = (term, path = new Set()) => {
314
+ if (isPlainExpr(term) && term.size() === 1) {
315
+ if (path.has(term)) {
316
+ cyclic = true;
317
+ return;
318
+ }
319
+ path.add(term);
320
+ walkAtom(term.asArray()[0], path);
321
+ path.delete(term);
322
+ }
323
+ else if (term instanceof FrameName) {
324
+ atoms.push(FrameWord.address(term.source));
325
+ }
326
+ else if (term instanceof FrameSymbol) {
327
+ atoms.push(FrameWord.word(term.spelling()));
328
+ }
329
+ else {
330
+ atoms.push(term);
331
+ }
332
+ };
333
+ let previous;
334
+ for (const term of terms) {
335
+ if (isPlainExpr(term) && previous && isPlainExpr(previous) &&
336
+ !previous.is.statement) {
337
+ atoms.push(FrameWord.word(","));
338
+ }
339
+ if (isPlainExpr(term)) {
340
+ for (const inner of term.asArray())
341
+ walkAtom(inner);
342
+ if (term.is.statement)
343
+ atoms.push(FrameWord.word(";"));
344
+ }
345
+ else {
346
+ walkAtom(term);
347
+ }
348
+ previous = term;
349
+ }
350
+ return cyclic ? Frame.error("$!.cyclic-aggregate .##") : atoms;
351
+ }
295
352
  /**
296
353
  * Whether a body's terms are one comma expression: two or more parsed terms
297
354
  * the source separated with `,`, rather than bare atoms or statements.
@@ -371,8 +428,8 @@ export class FrameScoped extends Frame {
371
428
  live() {
372
429
  return isClosure(this.term) ? this.term.in(this.scope) : this.term;
373
430
  }
374
- referent() {
375
- return this.term.referent();
431
+ referent(path = new Set()) {
432
+ return this.referenceThrough(this.term, path);
376
433
  }
377
434
  elements() {
378
435
  const terms = this.term.asArray();
@@ -385,7 +442,10 @@ export class FrameScoped extends Frame {
385
442
  return this;
386
443
  }
387
444
  sizeFor(key) {
388
- return this.term.sizeFor(key);
445
+ return this.referent().sizeFor(key);
446
+ }
447
+ nativeSize(path) {
448
+ return this.referent().nativeSize(path);
389
449
  }
390
450
  /** Sizes as its term does, `.#`, `.##` and `.###`; anything else is applied. */
391
451
  call(argument, parameter = Frame.nil) {
@@ -429,6 +489,7 @@ function resumedScope(term, scope) {
429
489
  }
430
490
  /** A source aggregate walks as a body does. */
431
491
  FrameList.walkSource = (terms) => atomsOf(terms, sitesAround(terms));
492
+ FrameList.sizeSource = sizeAtomsOf;
432
493
  /** The declarations around a closure body, as far as a walk has seen them. */
433
494
  export function sitesAround(body) {
434
495
  return (body[0] && enclosingSites.get(body[0])) ?? new Map();
@@ -10,6 +10,9 @@ export class FrameGroup extends FrameList {
10
10
  constructor(data, meta = NilContext) {
11
11
  super(data, meta);
12
12
  }
13
+ supportsResidual() {
14
+ return true;
15
+ }
13
16
  /**
14
17
  * The scope this group's terms are evaluated in. `target` is the layer they
15
18
  * read the group's properties from and, for a group written in source, the
@@ -103,8 +103,14 @@ export class FrameHandle extends Frame {
103
103
  return this;
104
104
  }
105
105
  /** A handle is transparent to equality: it compares as its target. */
106
- referent() {
107
- return this.target.referent();
106
+ referent(path = new Set()) {
107
+ return this.referenceThrough(this.target, path);
108
+ }
109
+ sizeFor(key) {
110
+ return this.referent().sizeFor(key);
111
+ }
112
+ nativeSize(path) {
113
+ return this.referent().nativeSize(path);
108
114
  }
109
115
  equals(other) {
110
116
  return this.target.equals(other);
@@ -93,12 +93,11 @@ export class FrameLazy extends FrameExpr {
93
93
  : undefined;
94
94
  }
95
95
  /**
96
- * A closure walks as the atoms of its body (#429), so `.#` counts them and
97
- * `.##` the terminals below them, as for any aggregate (#411); an empty
98
- * body is one terminal. A closure is not a Figure, so `.###` is nil
99
- * (010.04). The operator
100
- * reaches a closure as its argument, where a body would otherwise run, so
101
- * it is answered here before the body is.
96
+ * `.#` counts the body's represented words (#429). `.##` sums their native
97
+ * Sizes without execution or evaluation-site registration; an empty body
98
+ * retains Size 1. A closure's words are executable syntax, so it has no
99
+ * ordered data plane for `.###` and answers nil (010.08). The operator
100
+ * reaches a closure as its argument and is answered before its body runs.
102
101
  */
103
102
  sizeOperator(argument) {
104
103
  if (argument instanceof FrameSymbol && argument.is.address === true &&
@@ -125,6 +125,12 @@ export class FrameList extends Frame {
125
125
  }
126
126
  return this.data.filter((item) => this.isElement(item)).map((item) => item.walked());
127
127
  }
128
+ /** Quantity walks must not record evaluation sites or bind source words. */
129
+ sizeElements() {
130
+ return this.is.source === true && FrameList.sizeSource
131
+ ? FrameList.sizeSource(this.data)
132
+ : this.countedElements();
133
+ }
128
134
  /**
129
135
  * The elements a size operator counts: `elements()`, unless a kind can
130
136
  * count them more cheaply, as a closure does without its scope (a17).
@@ -136,124 +142,57 @@ export class FrameList extends Frame {
136
142
  isElement(term) {
137
143
  return term.is.statement !== true && !this.holdsAsProperty(term);
138
144
  }
139
- /**
140
- * `.#` counts this aggregate's elements (#411) and `.##` the terminals of
141
- * its structure (issue occurrence/figure 010.02), so neither counts a
142
- * property. `.###` is a Figure's signed residual (010.04). Every aggregate
143
- * is a list, so each one answers here rather than in its own class.
144
- */
145
+ /** Immediate count is unchanged; Size and residual share native child sizes. */
145
146
  sizeFor(key) {
146
147
  if (key === Frame.kCOUNT) {
147
148
  return new FrameCount(BigInt(this.countedElements().length));
148
149
  }
149
- if (key === Frame.kRESIDUAL)
150
- return this.residual();
151
- const terminals = this.terminalCount(new Set());
152
- return terminals === undefined
153
- ? Frame.error(`$!.cyclic-aggregate .${key}`)
154
- : new FrameCount(terminals);
150
+ return key === Frame.kRESIDUAL ? this.residual() : super.sizeFor(key);
155
151
  }
156
- /**
157
- * The terminals of this aggregate's structure, the nodes with no elements
158
- * below them. An aggregate with no elements is itself one terminal, at the
159
- * root or nested, so `[]` counts 1. A nonempty aggregate counts its elements' terminals: each
160
- * count element contributes its count (including zero); another atom is one
161
- * terminal, and each aggregate
162
- * element counts its own, at any depth. Properties are not elements, so an
163
- * aggregate holding only properties is one terminal too.
164
- *
165
- * On finite, property-free nested arrays this is Figure terminal count:
166
- * `[[], [[], []]].##` is 3. Through v0.32.1 an empty aggregate counted 0,
167
- * so `.##` counted only the non-aggregate leaves (#411).
168
- *
169
- * `path` holds only the aggregates from the root down to this one, so a
170
- * branch reached twice counts twice, and one that contains itself answers
171
- * undefined.
172
- */
173
- terminalCount(path) {
152
+ /** Empty aggregates retain one terminal; shared descendants count per occurrence. */
153
+ nativeSize(path) {
174
154
  if (path.has(this))
175
- return undefined;
176
- const elements = this.countedElements();
177
- if (elements.length === 0)
178
- return 1n;
155
+ return Frame.error("$!.cyclic-aggregate .##");
179
156
  path.add(this);
180
- let terminals = 0n;
181
- for (const element of elements) {
182
- const value = element.referent();
183
- const below = value instanceof FrameList
184
- ? value.terminalCount(path)
185
- : value instanceof FrameCount
186
- ? value.data
187
- : 1n;
188
- if (below === undefined)
189
- return undefined;
190
- terminals += below;
157
+ try {
158
+ const elements = this.sizeElements();
159
+ if (elements instanceof Frame)
160
+ return elements;
161
+ if (elements.length === 0)
162
+ return 1n;
163
+ let size = 0n;
164
+ for (const element of elements) {
165
+ const below = element.referent().nativeSize(path);
166
+ if (typeof below !== "bigint")
167
+ return below;
168
+ size += below;
169
+ }
170
+ return size;
171
+ }
172
+ finally {
173
+ path.delete(this);
191
174
  }
192
- path.delete(this);
193
- return terminals;
194
175
  }
195
- /**
196
- * Whether this aggregate can be a node of a Figure, a finite nested array
197
- * (010.04). Only an array can, so groups, schemas and closures answer false
198
- * here. Properties are not elements, so they never decide it.
199
- */
200
- isFigureNode() {
176
+ /** Only concrete ordered data hosts opt in, never executable/matcher syntax. */
177
+ supportsResidual() {
201
178
  return false;
202
179
  }
203
- /**
204
- * `.###`, the signed alternating sum of the terminal counts of a Figure's
205
- * immediate elements, `T(x₁) − T(x₂) + T(x₃) − …`, always a FrameInt and 0
206
- * for `[]` (issue occurrence/figure 010.04). A terminal is an empty frame,
207
- * so on a Figure `T` is `.##`. Each element is folded with one sign; the
208
- * signs do not alternate over the terminals below it.
209
- *
210
- * A Figure is read through its elements only, so properties and a declared
211
- * parent are ignored at every level, as `.#` and `.##` ignore them. Anything
212
- * else is not a Figure and answers nil, as `.#` does for a non-aggregate:
213
- * an atom, a string, a group, a schema or a closure anywhere in the
214
- * structure, or an aggregate that contains itself.
215
- */
180
+ /** Alternate over immediate positions, using each child's complete Size. */
216
181
  residual() {
217
- if (!this.isFigureNode())
182
+ if (!this.supportsResidual() || this.is.source === true)
218
183
  return Frame.nil;
219
184
  const path = new Set([this]);
220
185
  let signed = 0n;
221
186
  let positive = true;
222
187
  for (const element of this.countedElements()) {
223
- const terminals = FrameList.figureTerminals(element.referent(), path);
224
- if (terminals === undefined)
188
+ const size = element.referent().nativeSize(path);
189
+ if (typeof size !== "bigint")
225
190
  return Frame.nil;
226
- signed += positive ? terminals : -terminals;
191
+ signed += positive ? size : -size;
227
192
  positive = !positive;
228
193
  }
229
194
  return new FrameInt(signed);
230
195
  }
231
- /**
232
- * The terminal count of `value` as a Figure: 1 for an empty frame, else the
233
- * sum over its elements. Answers undefined when any node is not a Figure
234
- * node or contains itself. `path` holds the nodes from the root down, as
235
- * for `terminalCount`, so a shared branch counts at every occurrence.
236
- */
237
- static figureTerminals(value, path) {
238
- if (!(value instanceof FrameList) || !value.isFigureNode()) {
239
- return undefined;
240
- }
241
- if (path.has(value))
242
- return undefined;
243
- const elements = value.countedElements();
244
- if (elements.length === 0)
245
- return 1n;
246
- path.add(value);
247
- let terminals = 0n;
248
- for (const element of elements) {
249
- const below = FrameList.figureTerminals(element.referent(), path);
250
- if (below === undefined)
251
- return undefined;
252
- terminals += below;
253
- }
254
- path.delete(value);
255
- return terminals;
256
- }
257
196
  /**
258
197
  * `n x` for an aggregate concatenates (v0.22.0). The answer is a fresh
259
198
  * aggregate of x's kind holding the terms x keeps once, its properties and
@@ -81,6 +81,21 @@ export function projectBigIntRatio(numerator, denominator) {
81
81
  }
82
82
  /** Shared rank-based numeric dispatch and unary/apply behavior. */
83
83
  export class FrameNumeric extends FrameAtom {
84
+ nativeSize(path) {
85
+ // Dimensional and dotted values have no implicit unit or magnitude.
86
+ if (this.rank === null)
87
+ return super.nativeSize(path);
88
+ const ratio = this.exactRatio();
89
+ if (ratio) {
90
+ const [numerator, denominator] = ratio;
91
+ const quotient = numerator / denominator;
92
+ return quotient < 0n ? -quotient : quotient;
93
+ }
94
+ const value = this.valueOf();
95
+ return typeof value === "number" && Number.isFinite(value)
96
+ ? BigInt(Math.trunc(Math.abs(value)))
97
+ : Frame.error("$!.nonquantifiable-size .##");
98
+ }
84
99
  add(right) {
85
100
  return this.join(right, "+", (left, joinedRight) => left.addSame(joinedRight));
86
101
  }
@@ -62,6 +62,14 @@ export class FrameSchema extends FrameList {
62
62
  }
63
63
  return this;
64
64
  }
65
+ nativeSize() {
66
+ // Empty enumeration means the total type, not an empty finite domain.
67
+ // Inspect the installed matcher only; never traverse/compile candidates.
68
+ return this.matcher instanceof EnumerationSchemaMatcher &&
69
+ this.data.length > 0
70
+ ? BigInt(this.data.length)
71
+ : 1n;
72
+ }
65
73
  match(value, origin = Frame.nil) {
66
74
  return this.matcher.match(this, value, origin);
67
75
  }
@@ -25,6 +25,15 @@ export class FrameText extends FrameAtom {
25
25
  value: data
26
26
  });
27
27
  }
28
+ nativeSize(path) {
29
+ if (!hasCharacterContent(this))
30
+ return super.nativeSize(path);
31
+ // Native string iteration counts a surrogate pair as one Unicode code point.
32
+ let characters = 0n;
33
+ for (const _character of this.characterContent())
34
+ characters += 1n;
35
+ return characters;
36
+ }
28
37
  toData() {
29
38
  return this.data;
30
39
  }
@@ -207,9 +207,25 @@ export class Frame extends MetaFrame {
207
207
  return left.typeEquals(right);
208
208
  }
209
209
  /** The frame a reference reaches. A handle answers its target. */
210
- referent() {
210
+ referent(_path) {
211
211
  return this;
212
212
  }
213
+ /** Reference ancestry is separate from aggregate containment ancestry. */
214
+ referenceThrough(target, path) {
215
+ if (path.has(this)) {
216
+ const refusal = Frame.error("$!.cyclic-reference");
217
+ // This failed traversal is not a stored opaque error atom of Size 1.
218
+ refusal.is.cyclicReference = true;
219
+ return refusal;
220
+ }
221
+ path.add(this);
222
+ try {
223
+ return target.referent(path);
224
+ }
225
+ finally {
226
+ path.delete(this);
227
+ }
228
+ }
213
229
  /**
214
230
  * Whether this is a plain parsed expression: a statement of a body or an
215
231
  * aggregate, or a tight expression nested in one (spec a16). A closure is
@@ -245,12 +261,18 @@ export class Frame extends MetaFrame {
245
261
  }
246
262
  /**
247
263
  * What this frame answers for a size operator, `.#`, `.##` or `.###`
248
- * (#411). Only an aggregate counts and a count is its own size, so anything
249
- * else is nil. `.###` answers only on Figures, nested arrays (issue
250
- * occurrence/figure 010.04).
264
+ * (#411). Size counts represented quantity; opaque atoms count once.
265
+ * Immediate count and signed residual are partial, with kind-specific rules.
251
266
  */
252
- sizeFor(_key) {
253
- return Frame.nil;
267
+ sizeFor(key) {
268
+ if (key !== Frame.kLEAVES)
269
+ return Frame.nil;
270
+ const size = this.nativeSize(new Set());
271
+ return typeof size === "bigint" ? Frame.count(size) : size;
272
+ }
273
+ /** Nonnegative represented quantity; path tracks recursive containment only. */
274
+ nativeSize(_path) {
275
+ return this.is.cyclicReference ? this : 1n;
254
276
  }
255
277
  /**
256
278
  * What integer repetition `n x` answers when this frame, x, has a rule of
@@ -533,6 +555,13 @@ export class Frame extends MetaFrame {
533
555
  }
534
556
  return replaced;
535
557
  }
558
+ static quantityOperator(argument) {
559
+ if (argument.className() !== "FrameSymbol" || !argument.is.address) {
560
+ return undefined;
561
+ }
562
+ const key = argument.spelling();
563
+ return key === Frame.kLEAVES || key === Frame.kRESIDUAL ? key : undefined;
564
+ }
536
565
  /**
537
566
  * Negation is decided by the symbol's name, never by how it prints.
538
567
  *
@@ -650,6 +679,9 @@ Object.defineProperty(Frame, "all", {
650
679
  return "<>";
651
680
  }
652
681
  call(argument) {
682
+ const key = Frame.quantityOperator(argument);
683
+ if (key)
684
+ return this.sizeFor(key);
653
685
  return Frame.isBooleanNegation(argument) ? Frame.nil : this;
654
686
  }
655
687
  })()
@@ -1 +1 @@
1
- export const VERSION = "0.36.1";
1
+ export const VERSION = "0.37.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hclang",
3
- "version": "0.36.1",
3
+ "version": "0.37.0",
4
4
  "description": "Homoiconic C command-line interpreter and REPL",
5
5
  "keywords": [
6
6
  "language",