hclang 0.21.2 → 0.22.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.
@@ -406,6 +406,8 @@ export const HC_SOURCES = new Map([
406
406
  "# 6",
407
407
  "; 2 “a”",
408
408
  "# “aa”",
409
+ "; 2 [1, 2]",
410
+ "# [1, 2, 1, 2]",
409
411
  "; [] 1",
410
412
  "# [1]",
411
413
  "; [1] 2",
@@ -559,6 +561,16 @@ export const HC_SOURCES = new Map([
559
561
  "; [1] 2",
560
562
  "# [1, 2]",
561
563
  "```",
564
+ "Integer repetition consults the same declaration. A count concatenates a plain",
565
+ "aggregate's elements, even where the scope binds `apply`, but repeats an",
566
+ "aggregate that declares `apply` by its rule: the first of the n steps answers",
567
+ "the receiver, and each later step applies the running answer to it, so here the",
568
+ "rule runs four times",
569
+ "```",
570
+ "; .Units {[.row _; .apply {Units (_^.row + 1)}]};",
571
+ "; [(5 (Units 0)).row, (5 [Units 0]).#]",
572
+ "# [4, 5]",
573
+ "```",
562
574
  "",
563
575
  "## An empty reduce answers its receiver; an empty map is empty",
564
576
  "",
@@ -1076,6 +1088,20 @@ export const HC_SOURCES = new Map([
1076
1088
  "`x.children.#` counts x's children. A Figure's own `.#` and `.##` are `0`,",
1077
1089
  "because its children are a property rather than its elements (#407, #411).",
1078
1090
  "",
1091
+ "Size, Multiplication and Tally multiplication count first and then construct.",
1092
+ "Each computes a count n natively, with Cells and the size operators, and builds",
1093
+ "`Figure (n [U])` or `Figure (n [y])`, with the guards for zero that their",
1094
+ "paragraphs give. Repeating an aggregate concatenates its elements and shares",
1095
+ "them, so `n [U]` is n units, each `U` itself. Before v0.22.0 Size joined its",
1096
+ "children's Sizes one unit at a time, so tallies added by joining. Tallies still",
1097
+ "are the natural numbers in unary, they still join, `ys | x`, and two of them",
1098
+ "add as the Size of a Figure holding both, `(Figure [x, y]).size()`. Size now",
1099
+ "trades the joining derivation for construction from a native count.",
1100
+ "Repetition holds at most 1,000,000 elements, so Size, Multiplication and Tally",
1101
+ "multiplication answer `$!.repetition-size 1000000` once their count passes",
1102
+ "that. The joining Size had no such ceiling, but its time grew quadratically",
1103
+ "with the cells.",
1104
+ "",
1079
1105
  "A method names its own Figure `_^`, because a bare name is looked up on the",
1080
1106
  "argument first (spec 7), and the argument is usually another Figure. For the",
1081
1107
  "same reason, a block inside a method reads only names the method bound",
@@ -1100,36 +1126,36 @@ export const HC_SOURCES = new Map([
1100
1126
  " .many {Figure (_^.children & {B})};",
1101
1127
  "```",
1102
1128
  "**Size**, `x.size()`: a tally with one unit cell `U` per cell. Any Figure shaped",
1103
- "like `U` is a cell; every other Figure adds up the Sizes of its children by",
1104
- "joining them into `Tally Z`. It keeps the cell count and forgets shape, nesting,",
1105
- "order, reuse and identity. The unit case comes first, because a unit's only",
1106
- "child is `Z`",
1129
+ "like `U` is a cell. Size counts them with Cells, below, and repeats `U` that",
1130
+ "many times, and a Figure with no cells answers `Z` itself. It keeps the cell",
1131
+ "count and forgets shape, nesting, order, reuse and identity",
1107
1132
  "```;",
1108
- " .size {.kids _^.children;",
1109
- " (kids = U.children) ? {Figure [U]} : {((kids & {_.size()}) | (Tally Z)).row}};",
1133
+ " .size {.n ((_^.cells()).##); (n = 0) ? {Z} : {Figure (n [U])}};",
1110
1134
  "```",
1111
1135
  "**Cells**, `x.cells()`: the bracket tree of x with `1` in place of each cell,",
1112
1136
  "so `(x.cells()).##` is the Size of x as a natural number, counted without",
1113
1137
  "joining a tally. A count is its own size, so the `1` of a unit is already its",
1114
1138
  "count. It keeps the cell count and where the cells are, and forgets identity.",
1115
- "The unit case comes first, as in Size",
1139
+ "The unit case comes first, because a unit's only child is `Z`",
1116
1140
  "```;",
1117
1141
  " .cells {.kids _^.children;",
1118
1142
  " (kids = U.children) ? {1} : {kids & {_.cells()}}};",
1119
1143
  "```",
1120
- "**Multiplication**, `x.mul y`: y once for every cell of x, and `Z` when y is",
1121
- "`Z`. It keeps y's identity in every position and forgets x's shape",
1144
+ "**Multiplication**, `x.mul y`: y once for every cell of x, counted as Size",
1145
+ "counts them, and `Z` when y is `Z`. Repetition shares what it repeats, so it",
1146
+ "keeps y's identity in every position, and it forgets x's shape",
1122
1147
  "```;",
1123
- " .mul {.y _; .units ((_^.size()).children);",
1124
- " (y = Z) ? {Z} : {Figure (units & {y})}};",
1148
+ " .mul {.y _; .n ((_^.cells()).##); (y = Z) ? {Z} : {Figure (n [y])}};",
1125
1149
  "```",
1126
1150
  "**Tally multiplication**, `x.size_mul y`: the Size of a Figure holding y once",
1127
- "per child of x, and `Z` when y is `Z`, as in Multiplication: one row of",
1128
- "nothing, `Figure [Z]`, has the form of `U` and would count as a cell. It keeps",
1129
- "the cell count and forgets both shapes",
1151
+ "per child of x. That is x's number of children times y's cells, so it is",
1152
+ "counted rather than built, and it is `Z` when the product is `0`, a y of `Z`",
1153
+ "included. Building the Figure would go wrong there, as Multiplication would",
1154
+ "without its guard: one row of nothing, `Figure [Z]`, has the form of `U` and",
1155
+ "would count as a cell. It keeps the cell count and forgets both shapes",
1130
1156
  "```;",
1131
- " .size_mul {.y _; .kids _^.children;",
1132
- " (y = Z) ? {Z} : {(Figure (kids & {y})).size()}};",
1157
+ " .size_mul {.n ((_^.children.#) * ((_.cells()).##));",
1158
+ " (n = 0) ? {Z} : {Figure (n [U])}};",
1133
1159
  "```",
1134
1160
  "**Size-equivalence**, `x.size_equivalent y`: `U` when the two Sizes agree and",
1135
1161
  "`Z` otherwise. It compares the two cell counts as natural numbers, which",
@@ -1172,12 +1198,6 @@ export const HC_SOURCES = new Map([
1172
1198
  " .toText {“” (_^.form())}",
1173
1199
  "]};",
1174
1200
  "```",
1175
- "**Tally** is a helper receiver, not a Figure. Its `row` starts at `Z`, and",
1176
- "applying a tally to it appends that tally's units, one at a time, through",
1177
- "`x y`, so a reduce into `Tally Z` adds counts",
1178
- "```",
1179
- ".Tally {[.row _; .apply {Tally (_.children | _^.row)}]};",
1180
- "```",
1181
1201
  "**The marks.** The observers answer `A`, the Figure with no children, for no",
1182
1202
  "and `B`, the Figure holding `A`, for yes. Size counts in the same two: `Z`",
1183
1203
  "reuses `A` as the additive zero and `U` reuses `B` as the unit cell. The class",
@@ -1217,6 +1237,13 @@ export const HC_SOURCES = new Map([
1217
1237
  "; ([A, B] & (Figure [C])) = [Figure [C, A], Figure [C, B]]",
1218
1238
  "# <>",
1219
1239
  "```",
1240
+ "Repetition applies a Figure rather than concatenating, because a Figure",
1241
+ "declares its application: `3 U` is `(U U) U`, and each child it appends is `U`",
1242
+ "itself",
1243
+ "```",
1244
+ "; [(3 U) = ((U U) U), ((3 U).children .0) === Z, ((3 U).children .2) === U]",
1245
+ "# [<>, <>, <>]",
1246
+ "```",
1220
1247
  "## Manyness and Size",
1221
1248
  "",
1222
1249
  "Manyness marks the immediate children and looks no deeper",
@@ -1225,9 +1252,9 @@ export const HC_SOURCES = new Map([
1225
1252
  "# [<>, <>, <>, ()]",
1226
1253
  "```",
1227
1254
  "Size is recursive cell volume. `Z` is `A` and `U` is `B`, the same mark",
1228
- "Manyness uses, so a count is itself a Figure of units. Size maps each child to its Size and joins them into",
1229
- "`Tally Z`; the unit case comes first because a unit's only child is `Z`, and it",
1230
- "tests form, so any Figure shaped like `U` is a cell",
1255
+ "Manyness uses, so a count is itself a Figure of units. Size counts the cells",
1256
+ "with Cells and repeats `U` that many times. Cells tests form, so any Figure",
1257
+ "shaped like `U` is a cell",
1231
1258
  "```",
1232
1259
  "; [Z === A, U === B]",
1233
1260
  "# [<>, <>]",
@@ -1239,14 +1266,33 @@ export const HC_SOURCES = new Map([
1239
1266
  "# [<>, <>, <>]",
1240
1267
  "; [(row4.many()) = (row4.size()), (deep4.many()) = (deep4.size()), (two_fours.many()) = row2]",
1241
1268
  "# [<>, (), <>]",
1242
- "; ((Tally Z).row) = Z",
1243
- "# <>",
1269
+ "```",
1270
+ "Tallies add without a helper: the Size of a Figure holding two tallies joins",
1271
+ "them, and two `Z`s add to `Z`. Add two at a time, because two children are",
1272
+ "never shaped like `U`. One child can be: `Figure [Z]` has the form of `U`, so",
1273
+ "its Size is one cell, the rule that makes Multiplication and Tally",
1274
+ "multiplication guard `Z`",
1275
+ "```",
1276
+ "; [((Figure [row2, row3]).size()) = (row3.children | row2), ((Figure [Z, Z]).size()) = Z, ((Figure [Z]).size()) = (Figure [U])]",
1277
+ "# [<>, <>, <>]",
1278
+ "```",
1279
+ "Size answers `Z` itself for a Figure with no cells, and every unit of a Size is",
1280
+ "`U` itself, because repetition shares what it repeats",
1281
+ "```",
1282
+ "; [(Z.size()) === Z, ((Figure [Z, Z]).size()) === Z, ((U.size()).children .0) === U]",
1283
+ "# [<>, <>, <>]",
1244
1284
  "```",
1245
1285
  "A tally is its own Size, so Size is idempotent",
1246
1286
  "```",
1247
1287
  "; ((two_fours.size()).size()) = (two_fours.size())",
1248
1288
  "# <>",
1249
1289
  "```",
1290
+ "Counting first keeps a large Size quick: 256 cells, built by Multiplication",
1291
+ "```",
1292
+ "; .row16 (row4.mul row4); .row256 (row16.mul row16);",
1293
+ "; [(row256.size()).children.#, ((row256.size()).children .255) === U]",
1294
+ "# [256, <>]",
1295
+ "```",
1250
1296
  "A tally reads as a natural number, because its children are an aggregate and",
1251
1297
  "`.#` counts them. A Figure's own `.#` and `.##` are `0`: its children are a",
1252
1298
  "property, not its elements, and `.##` counts only what is not an aggregate",
@@ -1406,7 +1452,8 @@ export const HC_SOURCES = new Map([
1406
1452
  "",
1407
1453
  "A bare name inside a block that a map applies to Figures reads each Figure's",
1408
1454
  "own members first (spec 7), so it cannot reach the method's. That is why a",
1409
- "method names its own Figure `_^` and binds `kids` before its blocks read it",
1455
+ "method names its own Figure `_^` and binds `kids` or `n` before its blocks read",
1456
+ "it",
1410
1457
  "```",
1411
1458
  "; (E.children & {children}) = [A.children, B.children]",
1412
1459
  "# <>",
@@ -1416,9 +1463,9 @@ export const HC_SOURCES = new Map([
1416
1463
  "the scope that built it. The Fano plane above already binds `f`, the name",
1417
1464
  "Withness uses inside its blocks; these bind the other locals",
1418
1465
  "```",
1419
- "; .kids 9; .y 9; .units 9; .cells 9; .found 9; .absent 9;",
1420
- "; [(E.withness [A, B]) = B, (row2.mul row3) = rectangle23, (E.size()) = (Figure [U])]",
1421
- "# [<>, <>, <>]",
1466
+ "; .kids 9; .y 9; .n 9; .cells 9; .found 9; .absent 9;",
1467
+ "; [(E.withness [A, B]) = B, (row2.mul row3) = rectangle23, (E.size()) = (Figure [U]), (row2.size_mul row3) = (rectangle23.size())]",
1468
+ "# [<>, <>, <>, <>]",
1422
1469
  "```",
1423
1470
  "A method's free names resolve where the method was written, never where its",
1424
1471
  "receiver was read (#400). So a scope that binds its own `B` and reads a Figure",
@@ -1671,8 +1718,8 @@ export const HC_SOURCES = new Map([
1671
1718
  "```",
1672
1719
  "Imported methods compose with Figures built in this file, each with",
1673
1720
  "`Figures.Figure`. Size counts the cells of a Figure sum and of a Figure product.",
1674
- "On tallies, joining is a reduce, `ys | x`. `size_mul` multiplies, and `Tally Z`",
1675
- "collects a reduce",
1721
+ "On tallies, joining is a reduce, `ys | x`, `size_mul` multiplies, and the Size",
1722
+ "of a Figure holding two tallies adds them",
1676
1723
  "```",
1677
1724
  "; .duo (Figures.Figure [Figures.U, Figures.U]);",
1678
1725
  "; .trio (Figures.Figure [Figures.U, Figures.U, Figures.U]);",
@@ -1681,7 +1728,7 @@ export const HC_SOURCES = new Map([
1681
1728
  "# [<>, <>, <>]",
1682
1729
  "; (trio.children | (Figures.Figure [Figures.U])) = (Figures.Figure [Figures.U, Figures.U, Figures.U, Figures.U])",
1683
1730
  "# <>",
1684
- "; (([Figures.Figure [Figures.U], Figures.Figure [Figures.U]] | (Figures.Tally Figures.Z)).row) = duo",
1731
+ "; ((Figures.Figure [Figures.Figure [Figures.U], Figures.Figure [Figures.U]]).size()) = duo",
1685
1732
  "# <>",
1686
1733
  "```",
1687
1734
  "Identity crosses the import boundary. Withness asks for immediate containment",
@@ -1801,6 +1848,25 @@ export const HC_SOURCES = new Map([
1801
1848
  "# “HelloHelloHello”",
1802
1849
  "",
1803
1850
  "```",
1851
+ "Repeating an aggregate concatenates its elements (v0.22.0). The answer is a",
1852
+ "fresh aggregate of the same kind holding the receiver's properties once and its",
1853
+ "elements n times, shared rather than copied, so the receiver is never answered",
1854
+ "or written and no element holds its own aggregate",
1855
+ "```",
1856
+ "; 3 [1, 2]",
1857
+ "# [1, 2, 1, 2, 1, 2]",
1858
+ "; 0 [1, 2]",
1859
+ "# []",
1860
+ "; 2 [.k 1; 4, 5]",
1861
+ "# [.k 1; 4, 5, 4, 5]",
1862
+ "; 2 (1, 2)",
1863
+ "# (1, 2, 1, 2)",
1864
+ "; .xs [1, 2];",
1865
+ "; [3 xs, xs]",
1866
+ "# [[1, 2, 1, 2, 1, 2], [1, 2]]",
1867
+ "; [(1 xs) = xs, (1 xs) === xs, ((3 [xs]) .2) === xs, (2 [[1, 2]]).##]",
1868
+ "# [<>, (), <>, 4]",
1869
+ "```",
1804
1870
  "Cross-rung promotion and integer-only modulo",
1805
1871
  "```",
1806
1872
  "; 1 + 2.5",
@@ -1838,6 +1904,20 @@ export const HC_SOURCES = new Map([
1838
1904
  "; 2 ** 1000000",
1839
1905
  "# $!.numeric-range ** FrameCount",
1840
1906
  "```",
1907
+ "An aggregate's repetition applies nothing, so the application bound leaves it",
1908
+ "alone. Its answer is bounded instead, at 1,000,000 elements, and refused with",
1909
+ "the error repeated text uses. A negative or fractional count fails as it does",
1910
+ "for text",
1911
+ "```",
1912
+ "; (65537 [1]).#",
1913
+ "# 65537",
1914
+ "; 1000001 [1]",
1915
+ "# $!.repetition-size 1000000",
1916
+ "; (0 - 1) [1]",
1917
+ "# $!.repetition-count -1",
1918
+ "; 3.14 [1]",
1919
+ "# $!.repetition-domain FrameDecimal",
1920
+ "```",
1841
1921
  "Counts (#407). Every nonnegative integer literal is a `FrameCount`, the root of",
1842
1922
  "the ladder, and prints as the same integer does. A sequence's refusal names the",
1843
1923
  "class of its other operand, which is how these examples observe the rung",
@@ -59,6 +59,13 @@ export class FrameExpr extends FrameList {
59
59
  call(argument, parameter = Frame.nil) {
60
60
  return this.in(EvaluationScope.call(argument, parameter));
61
61
  }
62
+ /**
63
+ * An expression or a closure is called, not collected, so its terms are code
64
+ * rather than elements to concatenate: repetition applies it, as before.
65
+ */
66
+ repetitionFor(_count) {
67
+ return undefined;
68
+ }
62
69
  toStringDataArray() {
63
70
  const body = this.data
64
71
  .map((obj) => renderNested(obj, () => obj.toString()))
@@ -36,6 +36,14 @@ export class FrameGroup extends FrameList {
36
36
  this.data = this.data.map((frame) => frame.in(scope));
37
37
  return this;
38
38
  }
39
+ /**
40
+ * `()` is nil, so a repetition left with no term at all answers nil:
41
+ * `0 (1, 2)` is `()`, as the literal is. A group that holds properties keeps
42
+ * them, as every aggregate does, so `0 (.k 1; 4, 5)` holds `.k` alone.
43
+ */
44
+ finishRepetition() {
45
+ return this.size() === 0 ? Frame.nil : this;
46
+ }
39
47
  }
40
48
  Object.defineProperty(FrameGroup, "SIGIL_STARTS", {
41
49
  enumerable: true,
@@ -80,10 +80,16 @@ export class FrameInt extends FrameNumeric {
80
80
  ? count
81
81
  : Array.from({ length: count }, (_, index) => index);
82
82
  }
83
+ /** The refusal of a negative count, which every repetition answers first. */
84
+ negativeCount() {
85
+ return this.data < 0n
86
+ ? Frame.error(`$!.repetition-count ${this.spelling}`)
87
+ : undefined;
88
+ }
83
89
  repetitionCount() {
84
- if (this.data < 0n) {
85
- return Frame.error(`$!.repetition-count ${this.spelling}`);
86
- }
90
+ const negative = this.negativeCount();
91
+ if (negative)
92
+ return negative;
87
93
  if (this.data > REPETITION_LIMIT) {
88
94
  return Frame.error(`$!.repetition-limit ${REPETITION_LIMIT}`);
89
95
  }
@@ -170,6 +176,14 @@ export class FrameInt extends FrameNumeric {
170
176
  return this.data < value ? -1 : this.data > value ? 1 : 0;
171
177
  }
172
178
  repeat(argument, parameter) {
179
+ const negative = this.negativeCount();
180
+ if (negative)
181
+ return negative;
182
+ // An aggregate concatenates rather than applying itself (v0.22.0), and
183
+ // bounds the elements it answers rather than applications it performs.
184
+ const own = argument.referent().repetitionFor(this.data);
185
+ if (own !== undefined)
186
+ return own;
173
187
  const count = this.repetitionCount();
174
188
  if (count instanceof Frame)
175
189
  return count;
@@ -2,6 +2,7 @@ import { Frame } from "./frame.js";
2
2
  import { NilContext } from "./context.js";
3
3
  import { EvaluationScope } from "./evaluation-scope.js";
4
4
  import { FrameCount } from "./frame-count.js";
5
+ import { REPETITION_ELEMENT_LIMIT } from "./frame-numeric.js";
5
6
  import { renderNested } from "./stringify.js";
6
7
  /**
7
8
  * The declaration a term recorded, when it is a declaration echo.
@@ -104,7 +105,11 @@ export class FrameList extends Frame {
104
105
  * iterate.
105
106
  */
106
107
  elements() {
107
- return this.data.filter((item) => item.is.statement !== true && !this.holdsAsProperty(item));
108
+ return this.data.filter((item) => this.isElement(item));
109
+ }
110
+ /** Whether this term is one of the elements, as `elements()` reads them. */
111
+ isElement(term) {
112
+ return term.is.statement !== true && !this.holdsAsProperty(term);
108
113
  }
109
114
  /**
110
115
  * `.#` counts this aggregate's elements and `.##` the leaves below them
@@ -142,6 +147,55 @@ export class FrameList extends Frame {
142
147
  path.delete(this);
143
148
  return leaves;
144
149
  }
150
+ /**
151
+ * `n x` for an aggregate concatenates (v0.22.0). The answer is a fresh
152
+ * aggregate of x's kind holding the terms x keeps once, its properties and
153
+ * statements, followed by the terms it repeats, its elements, n times in
154
+ * order. The repeated terms are shared, as a collect shares what it
155
+ * collects, so each keeps its identity. x itself is never answered or
156
+ * written, so repeating a value builds no cycle. Properties stay once, as a
157
+ * reduce keeps only its receiver's: `[3, 4] | xs` concatenates into a copy
158
+ * of `xs`.
159
+ *
160
+ * An aggregate that declares its own application (#375) answers none, so
161
+ * repetition runs that application, as before. No application is performed
162
+ * here, so the answer is bounded by its size, at `REPETITION_ELEMENT_LIMIT`
163
+ * repeated terms, and refused with the error repeated text uses.
164
+ */
165
+ repetitionFor(count) {
166
+ if (this.applicationMethod() !== undefined)
167
+ return undefined;
168
+ const repeated = this.data.filter((term) => this.repeatsTerm(term));
169
+ if (BigInt(repeated.length) * count > REPETITION_ELEMENT_LIMIT) {
170
+ return Frame.error(`$!.repetition-size ${REPETITION_ELEMENT_LIMIT}`);
171
+ }
172
+ const result = this.copy();
173
+ const terms = result.data.filter((term) => !result.repeatsTerm(term));
174
+ // Within the limit, the loop runs at most that many times, and an
175
+ // aggregate with nothing to repeat skips it however large the count is.
176
+ const times = repeated.length === 0 ? 0 : Number(count);
177
+ for (let time = 0; time < times; time += 1) {
178
+ for (const term of repeated)
179
+ terms.push(term);
180
+ }
181
+ result.data = terms;
182
+ return result.finishRepetition();
183
+ }
184
+ /**
185
+ * Whether repetition repeats this term, rather than keeping it once. An
186
+ * aggregate repeats its elements and keeps its properties and statements
187
+ * once, as a reduce into it would.
188
+ */
189
+ repeatsTerm(term) {
190
+ return this.isElement(term);
191
+ }
192
+ /**
193
+ * What a repetition answers once its terms are in place: this aggregate,
194
+ * unless its kind has no value of that shape.
195
+ */
196
+ finishRepetition() {
197
+ return this;
198
+ }
145
199
  /**
146
200
  * The value a term answered, looking through a statement's wrapper.
147
201
  *
@@ -16,6 +16,8 @@ export const NUMERIC_RANK = {
16
16
  export const REPETITION_LIMIT = 65536n;
17
17
  /** The largest UTF-16 text result accepted by integer repetition. */
18
18
  export const REPETITION_TEXT_LIMIT = 1000000n;
19
+ /** The largest element count an aggregate's repetition may answer. */
20
+ export const REPETITION_ELEMENT_LIMIT = 1000000n;
19
21
  /** Maximum estimated bit width of an exact power result. */
20
22
  export const EXACT_POWER_BIT_LIMIT = 1000000n;
21
23
  /** Whether bigint exponentiation can stay within the exact-result budget. */
@@ -36,6 +36,32 @@ export class FrameSchema extends FrameList {
36
36
  const result = this.match(argument, parameter);
37
37
  return result.matched ? result.evidence : result.error;
38
38
  }
39
+ /**
40
+ * A schema's terms are all type terms, so repetition repeats every one, a
41
+ * statement too: `<.x; .y;>` and `<.x, .y>` are one type and repeat alike.
42
+ * A schema holds no properties, so only a held echo, were there one, would
43
+ * stay once.
44
+ */
45
+ repeatsTerm(term) {
46
+ return !this.holdsAsProperty(term);
47
+ }
48
+ /**
49
+ * A repeated schema matches what the literal with its terms written n times
50
+ * matches. With no term left that literal is `<>`, the total type. An
51
+ * enumeration matches by its terms, so it keeps its matcher. A compiled
52
+ * matcher was built from the terms, so it is rebuilt from the repeated ones;
53
+ * otherwise the schema would print and match as the one it repeated.
54
+ * `2 <.x, .y>` is `<.x, .y, .x, .y>`.
55
+ */
56
+ finishRepetition() {
57
+ if (this.size() === 0)
58
+ return Frame.all;
59
+ if (!(this.matcher instanceof EnumerationSchemaMatcher)) {
60
+ this.matcher = compileSchemaMatcher(this.data) ??
61
+ new EnumerationSchemaMatcher();
62
+ }
63
+ return this;
64
+ }
39
65
  match(value, origin = Frame.nil) {
40
66
  return this.matcher.match(this, value, origin);
41
67
  }
@@ -217,6 +217,16 @@ export class Frame extends MetaFrame {
217
217
  sizeFor(_key) {
218
218
  return Frame.nil;
219
219
  }
220
+ /**
221
+ * What integer repetition `n x` answers when this frame, x, has a rule of
222
+ * its own, or undefined when x is repeated by application: `FrameInt.repeat`
223
+ * then starts from nil and applies the running answer to x, n times. Only an
224
+ * aggregate has a rule (`FrameList`), so the base answers none. The caller
225
+ * has already refused a negative count.
226
+ */
227
+ repetitionFor(_count) {
228
+ return undefined;
229
+ }
220
230
  /**
221
231
  * Get a frame by key from this frame's own properties and its declared
222
232
  * parents only, never its lexical scope.
@@ -1 +1 @@
1
- export const VERSION = "0.21.2";
1
+ export const VERSION = "0.22.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hclang",
3
- "version": "0.21.2",
3
+ "version": "0.22.0",
4
4
  "description": "Homoiconic C command-line interpreter and REPL",
5
5
  "keywords": [
6
6
  "language",