hclang 0.26.1 → 0.27.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 +37 -14
- package/esm/lib/execute/parse-pipe.js +18 -2
- package/esm/lib/frames/evaluation-scope.js +41 -3
- package/esm/lib/frames/frame-expr.js +75 -45
- package/esm/lib/frames/frame-group.js +1 -1
- package/esm/lib/frames/frame-lazy.js +26 -4
- package/esm/lib/frames/frame-symbol.js +11 -3
- package/esm/lib/frames/reread.js +3 -0
- package/esm/lib/version.js +1 -1
- package/package.json +1 -1
|
@@ -933,7 +933,7 @@ export const HC_SOURCES = new Map([
|
|
|
933
933
|
"compares exactly as the same value written out would.`",
|
|
934
934
|
"; .point [.v 1; .set_ {@v _;}];",
|
|
935
935
|
"; point.set_ 2",
|
|
936
|
-
"# [.v 2; .set_ { @v _ };]",
|
|
936
|
+
"# [.v 2; .set_ { @v _; };]",
|
|
937
937
|
"; [(point.set_ 2) & {_}, (point.set_ 2) = [.v 2; .set_ {@v _;}]]",
|
|
938
938
|
"# [[], <>]",
|
|
939
939
|
"",
|
|
@@ -1178,14 +1178,17 @@ export const HC_SOURCES = new Map([
|
|
|
1178
1178
|
"construction. Manyness marks each child, Size marks each cell, and",
|
|
1179
1179
|
"Multiplication puts y at each cell. They are fewer than three constructions:",
|
|
1180
1180
|
"Size is Multiplication by the unit, and Tally multiplication is Multiplication",
|
|
1181
|
-
"of a Manyness, so Multiplication holds the only zero guard. No observer
|
|
1182
|
-
"
|
|
1181
|
+
"of a Manyness, so Multiplication holds the only zero guard. No observer",
|
|
1182
|
+
"computes: an observer may count, and may construct n things for a count n, but",
|
|
1183
|
+
"it never does arithmetic on counts (#435). A tally reads as a number because",
|
|
1184
|
+
"its children are an aggregate, so",
|
|
1183
1185
|
"`(x.size()).children.#` is the FrameCount it spells, as `(x.cells()).#` is, and",
|
|
1184
1186
|
"`x.children.#` counts x's children. A Figure's own `.#` and `.##` are `0`,",
|
|
1185
1187
|
"because its children are a property rather than its elements (#407, #411).",
|
|
1186
|
-
"
|
|
1187
|
-
"
|
|
1188
|
-
"
|
|
1188
|
+
"v0.22.0 counted cells and built from the count, but Tally multiplication also",
|
|
1189
|
+
"multiplied two counts (#414). v0.24.0 removed the counting along with the",
|
|
1190
|
+
"arithmetic (#415), and v0.26.2 restores the counting alone (#435). Before",
|
|
1191
|
+
"v0.22.0, Size joined its children's Sizes one unit at a time through a helper.",
|
|
1189
1192
|
"",
|
|
1190
1193
|
"Three Figures play the roles of zero and one, and keeping them apart is what",
|
|
1191
1194
|
"the guards below are for. `Z` is zero. `U` is the unit cell that Size counts.",
|
|
@@ -1228,18 +1231,21 @@ export const HC_SOURCES = new Map([
|
|
|
1228
1231
|
"**Cells**, `x.cells()`: the cells of x, in order, each one itself. Any Figure",
|
|
1229
1232
|
"shaped like `U` is a cell, and every other Figure's cells are its children's,",
|
|
1230
1233
|
"spliced into one array by `&|` (#421). The unit case comes first, because a",
|
|
1231
|
-
"unit's only child is `Z`.
|
|
1232
|
-
"
|
|
1233
|
-
"
|
|
1234
|
+
"unit's only child is `Z`. When every child is already a cell, the cells are the",
|
|
1235
|
+
"children themselves. Cells sees that by comparing the children with as many",
|
|
1236
|
+
"units, which counts rather than walks, so a tally answers at once. It keeps the",
|
|
1237
|
+
"cells and their order, and forgets where they were. A block in a method counts",
|
|
1238
|
+
"carets lexically, so the cell itself is `_^^` inside the branch",
|
|
1234
1239
|
"```;",
|
|
1235
1240
|
" .cells {.kids _^.children;",
|
|
1236
|
-
" (kids = U.children) ? {[_^^]} : {kids &| {_.cells()}}};",
|
|
1241
|
+
" (kids = U.children) ? {[_^^]} : {(kids = ((kids.#) [U])) ? {kids} : {kids &| {_.cells()}}}};",
|
|
1237
1242
|
"```",
|
|
1238
1243
|
"**Multiplication**, `x.mul y`: y at every cell of x, and `Z` when y is `Z`. It",
|
|
1239
|
-
"
|
|
1240
|
-
"
|
|
1244
|
+
"counts x's cells and constructs y that many times, so it keeps y's identity in",
|
|
1245
|
+
"every position and forgets x's shape. Without the guard, a one-cell x would",
|
|
1246
|
+
"answer `Figure [Z]`, which is a cell rather than zero",
|
|
1241
1247
|
"```;",
|
|
1242
|
-
" .mul {.y _; .
|
|
1248
|
+
" .mul {.y _; .n ((_^.cells()).#); (y = Z) ? {Z} : {Figure (n [y])}};",
|
|
1243
1249
|
"```",
|
|
1244
1250
|
"**Tally multiplication**, `x.size_mul y`: the Size of a Figure holding y once",
|
|
1245
1251
|
"per child of x, and `Z` when y is `Z`. Manyness marks each child with `B`,",
|
|
@@ -1345,7 +1351,7 @@ export const HC_SOURCES = new Map([
|
|
|
1345
1351
|
"quick, and the receiver and every child keep their identity. Each step still",
|
|
1346
1352
|
"copies the children it has so far, because a collect through a name always lands",
|
|
1347
1353
|
"on a fresh array (#386). That keeps a join quadratic in pointer copies, about",
|
|
1348
|
-
"0.
|
|
1354
|
+
"0.2 s for 4,096 units, and the observers never join: they construct from a",
|
|
1349
1355
|
"stream in one step (#415)",
|
|
1350
1356
|
"```",
|
|
1351
1357
|
"; .joined ((512 [U]) | Z);",
|
|
@@ -1412,6 +1418,23 @@ export const HC_SOURCES = new Map([
|
|
|
1412
1418
|
"; [E.children.#, (E.many()).children.#, (two_fours.size()).children.#, E.#, E.##, E.children.##] = [2, 2, 8, 0, 0, 0]",
|
|
1413
1419
|
"# <>",
|
|
1414
1420
|
"```",
|
|
1421
|
+
"A tally built by repetition is its own cells and its own Size, and every cell",
|
|
1422
|
+
"is `U` itself. Multiplication of it constructs y once per cell, each one y",
|
|
1423
|
+
"itself. A Figure whose children are not all cells is still walked",
|
|
1424
|
+
"```",
|
|
1425
|
+
"; .rep (Figure (6 [U]));",
|
|
1426
|
+
"; [(rep.cells()) = rep.children, ((rep.cells()) .5) === U, (rep.size()) = rep, (rep.mul row2) = (Figure (6 [row2])), ((rep.mul row2).children .5) === row2]",
|
|
1427
|
+
"# [<>, <>, <>, <>, <>]",
|
|
1428
|
+
"; [((Figure [row2, U]).cells()) = [U, U, U], (((Figure [row2, U]).cells()) .2) === U]",
|
|
1429
|
+
"# [<>, <>]",
|
|
1430
|
+
"```",
|
|
1431
|
+
"Zero is a quotient of zeros. A Figure made of nothing, or of several nothings,",
|
|
1432
|
+
"has no cells and a Size of `Z`'s form, but it is not `Z`, and it keeps its own",
|
|
1433
|
+
"form",
|
|
1434
|
+
"```",
|
|
1435
|
+
"; [((Figure [Z, Z]).cells()) = [], ((Figure [Z, Z]).size()) = Z, (Figure (0 [U])) = Z, (Figure (0 [U])) === Z, (Figure [Z, Z]) = Z]",
|
|
1436
|
+
"# [<>, <>, <>, (), ()]",
|
|
1437
|
+
"```",
|
|
1415
1438
|
"Cells answers the cells themselves, in order, wherever they were nested, and",
|
|
1416
1439
|
"`.#` reads how many there are, as it reads a tally",
|
|
1417
1440
|
"```",
|
|
@@ -109,8 +109,24 @@ export class ParsePipe extends FrameArray {
|
|
|
109
109
|
return out;
|
|
110
110
|
}
|
|
111
111
|
let value = this.makeFrame();
|
|
112
|
-
if (value instanceof FrameBind
|
|
113
|
-
|
|
112
|
+
if (value instanceof FrameBind) {
|
|
113
|
+
// A bind pipe holds what followed one whitespace. One term is itself:
|
|
114
|
+
// wrapping it added a node with no meaning, which printed as `((x))`
|
|
115
|
+
// and doubled the depth of every walk. Several terms that abut, as in
|
|
116
|
+
// `f o.x`, are one tight expression, evaluated before the term beside
|
|
117
|
+
// it applies, so they stay one `FrameExpr` node. No `FrameBind` reaches
|
|
118
|
+
// the graph (spec a16).
|
|
119
|
+
if (value.isEmpty())
|
|
120
|
+
return out;
|
|
121
|
+
const [expr] = value.asArray();
|
|
122
|
+
const term = expr instanceof FrameExpr && expr.size() === 1
|
|
123
|
+
? expr.asArray()[0]
|
|
124
|
+
: expr;
|
|
125
|
+
// Collected as a token is, by `apply`: `call` would double-dispatch,
|
|
126
|
+
// and a bare symbol or operator answers a call by resolving itself.
|
|
127
|
+
const result = out.apply(term, Frame.nil);
|
|
128
|
+
out.call(terminal);
|
|
129
|
+
return result;
|
|
114
130
|
}
|
|
115
131
|
if (value instanceof FrameSchema && value.isEmpty()) {
|
|
116
132
|
value = Frame.all;
|
|
@@ -273,7 +273,18 @@ export class EvaluationScope {
|
|
|
273
273
|
* receiver authority are deliberately not inherited.
|
|
274
274
|
*/
|
|
275
275
|
namedChild(namespace) {
|
|
276
|
-
|
|
276
|
+
// A module imported during a construction is not that construction's
|
|
277
|
+
// child: its statements are its own file's, and the aggregate under
|
|
278
|
+
// construction is an accident of where the import was written. So the
|
|
279
|
+
// namespace sees the importing file before the construction, as #391
|
|
280
|
+
// designed, though the construction's own terms see it first (spec a16).
|
|
281
|
+
const frames = this.writeTargetRole === "construction"
|
|
282
|
+
? [
|
|
283
|
+
...__classPrivateFieldGet(this, _EvaluationScope_lookupFrames, "f").filter((frame) => frame !== this.writeTarget),
|
|
284
|
+
this.writeTarget,
|
|
285
|
+
]
|
|
286
|
+
: __classPrivateFieldGet(this, _EvaluationScope_lookupFrames, "f");
|
|
287
|
+
namespace.up = new LiveLookupContext(frames, namespace);
|
|
277
288
|
const layers = EvaluationScope.layers([namespace]);
|
|
278
289
|
return new EvaluationScope({
|
|
279
290
|
argument: namespace,
|
|
@@ -296,7 +307,23 @@ export class EvaluationScope {
|
|
|
296
307
|
withLayer(frame) {
|
|
297
308
|
if (__classPrivateFieldGet(this, _EvaluationScope_lookupMembers, "f").has(frame))
|
|
298
309
|
return this;
|
|
299
|
-
|
|
310
|
+
return this.withLayers(this.appended(frame));
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Adds an aggregate literal's own frame ahead of every other layer.
|
|
314
|
+
*
|
|
315
|
+
* An aggregate under construction is the current child of spec 7 §2, so
|
|
316
|
+
* its own properties are searched first: a name it declares shadows the
|
|
317
|
+
* same name in an enclosing scope, as a closure's local does. Appending it
|
|
318
|
+
* instead searched it last, so `.gb 1; (.gb 2; gb)` read the outer `gb`
|
|
319
|
+
* (Figure 004.09a).
|
|
320
|
+
*/
|
|
321
|
+
withOwnLayer(frame) {
|
|
322
|
+
if (__classPrivateFieldGet(this, _EvaluationScope_lookupFrames, "f")[0] === frame)
|
|
323
|
+
return this;
|
|
324
|
+
return this.withLayers(this.prepended(frame));
|
|
325
|
+
}
|
|
326
|
+
withLayers(layers) {
|
|
300
327
|
return new EvaluationScope({
|
|
301
328
|
argument: this.argument,
|
|
302
329
|
parameter: this.parameter,
|
|
@@ -315,7 +342,11 @@ export class EvaluationScope {
|
|
|
315
342
|
}
|
|
316
343
|
/** Selects a declaration target explicitly instead of scanning syntax. */
|
|
317
344
|
withWriteTarget(target, role = "construction") {
|
|
318
|
-
|
|
345
|
+
// A construction target is the aggregate itself, searched first; any
|
|
346
|
+
// other target is a destination for writes, and joins lookup last.
|
|
347
|
+
const layers = role === "construction"
|
|
348
|
+
? this.prepended(target)
|
|
349
|
+
: this.appended(target);
|
|
319
350
|
return new EvaluationScope({
|
|
320
351
|
argument: this.argument,
|
|
321
352
|
parameter: this.parameter,
|
|
@@ -429,6 +460,13 @@ export class EvaluationScope {
|
|
|
429
460
|
? new FrameHandle(state.receiver, state.mutable, state.copyOnWrite, state.lexicalContext)
|
|
430
461
|
: state.receiver;
|
|
431
462
|
}
|
|
463
|
+
/** Copies this scope's lookup layers with `frame` first, wherever it was. */
|
|
464
|
+
prepended(frame) {
|
|
465
|
+
const frames = [frame, ...__classPrivateFieldGet(this, _EvaluationScope_lookupFrames, "f").filter((f) => f !== frame)];
|
|
466
|
+
const members = new Set(__classPrivateFieldGet(this, _EvaluationScope_lookupMembers, "f"));
|
|
467
|
+
members.add(frame);
|
|
468
|
+
return { frames, members };
|
|
469
|
+
}
|
|
432
470
|
/** Copies this scope's lookup layers with additions that are not present. */
|
|
433
471
|
appended(...additions) {
|
|
434
472
|
const frames = [...__classPrivateFieldGet(this, _EvaluationScope_lookupFrames, "f")];
|
|
@@ -66,10 +66,9 @@ export class FrameExpr extends FrameList {
|
|
|
66
66
|
}
|
|
67
67
|
/** A parsed expression of one atom is that atom; anything else is itself. */
|
|
68
68
|
walked() {
|
|
69
|
-
if (!isPlainExpr(this)
|
|
69
|
+
if (!isPlainExpr(this))
|
|
70
70
|
return this;
|
|
71
|
-
|
|
72
|
-
const atoms = atomsOf([this]);
|
|
71
|
+
const atoms = atomsOf([this], sitesAround(this.data));
|
|
73
72
|
return atoms.length === 1 ? atoms[0] : this;
|
|
74
73
|
}
|
|
75
74
|
/**
|
|
@@ -143,6 +142,11 @@ export class FrameExpr extends FrameList {
|
|
|
143
142
|
: term;
|
|
144
143
|
}
|
|
145
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* The parser's marker for a bind pipe, what one whitespace started. It names
|
|
147
|
+
* the pipe only: a bind emits its one term bare, or several abutting terms as
|
|
148
|
+
* a tight `FrameExpr`, so no `FrameBind` is ever a node of the graph (a16).
|
|
149
|
+
*/
|
|
146
150
|
export class FrameBind extends FrameExpr {
|
|
147
151
|
}
|
|
148
152
|
/** A parsed expression itself, not a closure or a bind. */
|
|
@@ -152,8 +156,7 @@ const isPlainExpr = (term) => term instanceof FrameExpr &&
|
|
|
152
156
|
* A closure literal. `FrameLazy` is the one other subclass of `FrameExpr`, and
|
|
153
157
|
* it cannot be imported here, because it extends this module's class.
|
|
154
158
|
*/
|
|
155
|
-
const isClosure = (term) => term instanceof FrameExpr && !isPlainExpr(term)
|
|
156
|
-
!(term instanceof FrameBind);
|
|
159
|
+
const isClosure = (term) => term instanceof FrameExpr && !isPlainExpr(term);
|
|
157
160
|
/**
|
|
158
161
|
* The declarations visible to each closure body a walk has passed through.
|
|
159
162
|
*
|
|
@@ -166,17 +169,18 @@ const enclosingSites = new WeakMap();
|
|
|
166
169
|
/**
|
|
167
170
|
* The atoms of parsed terms, in source order, as data (#429).
|
|
168
171
|
*
|
|
169
|
-
* The
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* a
|
|
174
|
-
*
|
|
175
|
-
*
|
|
172
|
+
* The terms are a body's statements. Each statement's atoms are yielded in
|
|
173
|
+
* order; a statement that ended in `;` is followed by the word `;`, and two
|
|
174
|
+
* statements the source separated with `,` get the word `,` between them, so
|
|
175
|
+
* the walk's text re-reads as the same source. A symbol, operator or name
|
|
176
|
+
* becomes a word, so it never resolves. Every other atom is yielded itself,
|
|
177
|
+
* unevaluated: a count, a string, a closure, an aggregate, or a tight
|
|
178
|
+
* expression, terms that abut as `o.x` does, which is evaluated before its
|
|
179
|
+
* neighbour applies and so is one atom that walks in turn (a16).
|
|
176
180
|
*
|
|
177
181
|
* Each word carries the declaration it resolves to, so `===` tells apart two
|
|
178
|
-
* names with one spelling. A name at the head of
|
|
179
|
-
*
|
|
182
|
+
* names with one spelling. A name at the head of a statement declares, and a
|
|
183
|
+
* lookup resolves to the nearest declaration before it in its own body or in
|
|
180
184
|
* a body around it, which is the order a call evaluates them in. A closure's
|
|
181
185
|
* locals come ahead of its argument, so that is static. A name declared
|
|
182
186
|
* nowhere it can see is free: it resolves per call, argument first (spec 7),
|
|
@@ -185,23 +189,36 @@ const enclosingSites = new WeakMap();
|
|
|
185
189
|
export function atomsOf(terms, sites = new Map()) {
|
|
186
190
|
const scope = new Map(sites);
|
|
187
191
|
const atoms = [];
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
+
const heads = new Set();
|
|
193
|
+
const declaredName = (expr) => {
|
|
194
|
+
const terms = expr.asArray();
|
|
195
|
+
if (terms.length < 2)
|
|
196
|
+
return undefined;
|
|
197
|
+
const head = firstAtom(terms[0]);
|
|
198
|
+
if (!(head instanceof FrameName) || /^\.*$/.test(head.source)) {
|
|
199
|
+
return undefined;
|
|
192
200
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
+
heads.add(head);
|
|
202
|
+
return head;
|
|
203
|
+
};
|
|
204
|
+
/** Records the declarations in view for a term that walks on its own. */
|
|
205
|
+
const noteTerms = (held) => {
|
|
206
|
+
if (held[0])
|
|
207
|
+
enclosingSites.set(held[0], scope);
|
|
208
|
+
atomsOf(held, scope);
|
|
209
|
+
};
|
|
210
|
+
const walkAtom = (term) => {
|
|
211
|
+
if (isPlainExpr(term)) {
|
|
212
|
+
const held = term.asArray();
|
|
213
|
+
if (held.length === 1) {
|
|
214
|
+
walkAtom(held[0]);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
noteTerms(held);
|
|
218
|
+
atoms.push(term);
|
|
219
|
+
}
|
|
201
220
|
}
|
|
202
221
|
else if (term instanceof FrameName) {
|
|
203
|
-
// A name at the head of an expression is its own declaration. Anywhere
|
|
204
|
-
// else it is a value or a member, `o .a`, which no local declares.
|
|
205
222
|
atoms.push(FrameWord.address(term.source, heads.has(term) ? term : undefined));
|
|
206
223
|
}
|
|
207
224
|
else if (term instanceof FrameSymbol) {
|
|
@@ -209,32 +226,45 @@ export function atomsOf(terms, sites = new Map()) {
|
|
|
209
226
|
atoms.push(FrameWord.word(spelling, scope.get(spelling)));
|
|
210
227
|
}
|
|
211
228
|
else {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
229
|
+
if (isClosure(term)) {
|
|
230
|
+
const first = term.asArray()[0];
|
|
231
|
+
if (first)
|
|
232
|
+
enclosingSites.set(first, scope);
|
|
233
|
+
}
|
|
234
|
+
else if (term instanceof FrameList) {
|
|
235
|
+
for (const element of term.asArray()) {
|
|
236
|
+
noteTerms(isPlainExpr(element) ? element.asArray() : [element]);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
215
239
|
atoms.push(term);
|
|
216
240
|
}
|
|
217
241
|
};
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const head = firstAtom(terms[0]);
|
|
224
|
-
if (!(head instanceof FrameName) || /^\.*$/.test(head.source)) {
|
|
225
|
-
return undefined;
|
|
242
|
+
let previous;
|
|
243
|
+
for (const term of terms) {
|
|
244
|
+
if (isPlainExpr(term) && previous && isPlainExpr(previous) &&
|
|
245
|
+
previous.is.statement !== true) {
|
|
246
|
+
atoms.push(FrameWord.word(","));
|
|
226
247
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
248
|
+
if (isPlainExpr(term)) {
|
|
249
|
+
const declared = declaredName(term);
|
|
250
|
+
for (const inner of term.asArray())
|
|
251
|
+
walkAtom(inner);
|
|
252
|
+
if (declared)
|
|
253
|
+
scope.set(declared.source, declared);
|
|
254
|
+
if (term.is.statement)
|
|
255
|
+
atoms.push(FrameWord.word(";"));
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
walkAtom(term);
|
|
259
|
+
}
|
|
260
|
+
previous = term;
|
|
261
|
+
}
|
|
232
262
|
return atoms;
|
|
233
263
|
}
|
|
234
264
|
/** The atom a term begins with, through the parser's one-term wrappers. */
|
|
235
265
|
function firstAtom(term) {
|
|
236
266
|
let atom = term;
|
|
237
|
-
while (
|
|
267
|
+
while (isPlainExpr(atom) && atom.size() === 1) {
|
|
238
268
|
atom = atom.asArray()[0];
|
|
239
269
|
}
|
|
240
270
|
return atom;
|
|
@@ -15,7 +15,7 @@ export class FrameGroup extends FrameList {
|
|
|
15
15
|
* frame their declarations land on.
|
|
16
16
|
*/
|
|
17
17
|
scoped(input, target) {
|
|
18
|
-
const scope = EvaluationScope.from(input).
|
|
18
|
+
const scope = EvaluationScope.from(input).withOwnLayer(target);
|
|
19
19
|
return this.declares
|
|
20
20
|
? scope.withWriteTarget(target, "construction")
|
|
21
21
|
: scope;
|
|
@@ -45,11 +45,33 @@ export class FrameLazy extends FrameExpr {
|
|
|
45
45
|
return result;
|
|
46
46
|
}
|
|
47
47
|
toStringDataArray() {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
// A body prints as it was written, so it reads back: `;` after a
|
|
49
|
+
// statement, `, ` between terms the source separated, and a tight
|
|
50
|
+
// expression, terms that abut as `o.x` does, in parentheses, since the
|
|
51
|
+
// spacing that bound them cannot be restored (spec a16).
|
|
52
|
+
const stringify = (obj) => renderNested(obj, () => obj instanceof FrameExpr && Object.getPrototypeOf(obj) ===
|
|
53
|
+
FrameExpr.prototype
|
|
54
|
+
? `(${obj.asArray().map(stringify).join(" ")})`
|
|
50
55
|
: obj.toString());
|
|
51
|
-
const parts =
|
|
52
|
-
|
|
56
|
+
const parts = [];
|
|
57
|
+
this.data.forEach((term, index) => {
|
|
58
|
+
const statement = term instanceof FrameExpr &&
|
|
59
|
+
Object.getPrototypeOf(term) ===
|
|
60
|
+
FrameExpr.prototype;
|
|
61
|
+
const text = statement
|
|
62
|
+
? term.asArray().map(stringify).join(" ")
|
|
63
|
+
: stringify(term);
|
|
64
|
+
// Only two statements the source separated take a comma; a body built
|
|
65
|
+
// from bare terms, as a test may build one, is one juxtaposition.
|
|
66
|
+
const previous = this.data[index - 1];
|
|
67
|
+
const separated = index > 0 && statement &&
|
|
68
|
+
previous instanceof FrameExpr &&
|
|
69
|
+
Object.getPrototypeOf(previous) === FrameExpr.prototype &&
|
|
70
|
+
previous.is.statement !== true;
|
|
71
|
+
parts.push((separated ? ", " : index > 0 ? " " : "") + text +
|
|
72
|
+
(term.is.statement ? ";" : ""));
|
|
73
|
+
});
|
|
74
|
+
const body = parts.join("").trim();
|
|
53
75
|
const display = body.length > 0 ? ` ${body} ` : body;
|
|
54
76
|
return [display + ","];
|
|
55
77
|
}
|
|
@@ -40,7 +40,15 @@ export class FrameLiteral extends FrameAtom {
|
|
|
40
40
|
});
|
|
41
41
|
this.is.declaration = true;
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* The echo's text, rendered the first time it is asked for. Rendering it at
|
|
45
|
+
* declaration spelled out the whole declared value every time, and the echo
|
|
46
|
+
* is rarely printed: a Figure built from 16,384 children rendered all of
|
|
47
|
+
* them, each with its methods, and spent most of its time there (#435).
|
|
48
|
+
*/
|
|
43
49
|
toData() {
|
|
50
|
+
if (typeof this.data !== "string")
|
|
51
|
+
this.data = this.data();
|
|
44
52
|
return this.data;
|
|
45
53
|
}
|
|
46
54
|
/**
|
|
@@ -212,7 +220,7 @@ export class FrameSymbol extends FrameAtom {
|
|
|
212
220
|
if (refused)
|
|
213
221
|
return refused;
|
|
214
222
|
return previous.is.missing
|
|
215
|
-
? new FrameLiteral(`.^ ${argument.toString()}`)
|
|
223
|
+
? new FrameLiteral(() => `.^ ${argument.toString()}`)
|
|
216
224
|
: argument;
|
|
217
225
|
}
|
|
218
226
|
const binding = out.resolve_here(this.data, out);
|
|
@@ -234,7 +242,7 @@ export class FrameSymbol extends FrameAtom {
|
|
|
234
242
|
}
|
|
235
243
|
out.set(assignmentKey, argument);
|
|
236
244
|
return previous.is.missing
|
|
237
|
-
? new FrameLiteral(`.${this.data} ${argument.toString()}`, {
|
|
245
|
+
? new FrameLiteral(() => `.${this.data} ${argument.toString()}`, {
|
|
238
246
|
target: out,
|
|
239
247
|
key: assignmentKey,
|
|
240
248
|
value: argument,
|
|
@@ -265,7 +273,7 @@ export class FrameSymbol extends FrameAtom {
|
|
|
265
273
|
}
|
|
266
274
|
out.set(assignmentKey, schema);
|
|
267
275
|
out.set(`${assignmentKey}.<>`, schema);
|
|
268
|
-
return new FrameLiteral(`.${this.data} ${schema.toString()}`, {
|
|
276
|
+
return new FrameLiteral(() => `.${this.data} ${schema.toString()}`, {
|
|
269
277
|
target: out,
|
|
270
278
|
key: assignmentKey,
|
|
271
279
|
value: schema,
|
package/esm/lib/frames/reread.js
CHANGED
package/esm/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.27.0";
|