hclang 0.20.2 → 0.21.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.
@@ -1,4 +1,4 @@
1
- import { Frame, FrameInt, FrameString, FrameSymbol, } from "../frames.js";
1
+ import { Frame, FrameCount, FrameString, FrameSymbol, } from "../frames.js";
2
2
  import { EvalPipe, makeSourcePipe } from "./eval-pipe.js";
3
3
  import { evaluateResourceSource } from "./resource-import.js";
4
4
  import { sigilizer } from "./sigilizer.js";
@@ -12,7 +12,8 @@ import { sigilizer } from "./sigilizer.js";
12
12
  * This method iterates over the entries and determines the type of each value
13
13
  * based on its first character:
14
14
  * - If alphabetic, the value is wrapped in a `FrameString`.
15
- * - If numeric, the value is wrapped in a `FrameInt`.
15
+ * - If numeric, the value is wrapped in a `FrameCount`, as the same digits
16
+ * written in source would be.
16
17
  * - If neither, an error is logged and the key is set to `Frame.nil`.
17
18
  *
18
19
  * If the context contains a `DEBUG_ENV` key, the context is logged to the console
@@ -32,7 +33,7 @@ export function make_context(entries) {
32
33
  const context = {};
33
34
  Object.entries(entries).forEach(([key, value]) => {
34
35
  if (/^\p{Nd}+$/u.test(value)) {
35
- context[key] = FrameInt.for(value);
36
+ context[key] = FrameCount.for(value);
36
37
  }
37
38
  else {
38
39
  context[key] = new FrameString(value);
@@ -31,6 +31,78 @@ class ImportProgress extends Frame {
31
31
  return value;
32
32
  }
33
33
  }
34
+ /** The prefix of a testdoc example line, `HCEval.SOURCE`. */
35
+ const EXAMPLE = "; ";
36
+ /**
37
+ * Drops a testdoc's example lines from imported source, so importing a file
38
+ * runs its code and not its examples.
39
+ *
40
+ * A line is an example when it begins with `; ` outside prose, the same test
41
+ * `HCEval.checkInput` applies when the file runs as a testdoc. Every example is
42
+ * one line, and its expectation line (`# …`) is already a comment, so dropping
43
+ * the line up to its newline leaves the rest of the source as written.
44
+ */
45
+ class ExampleFilter {
46
+ constructor() {
47
+ Object.defineProperty(this, "head", {
48
+ enumerable: true,
49
+ configurable: true,
50
+ writable: true,
51
+ value: ""
52
+ });
53
+ Object.defineProperty(this, "atLineStart", {
54
+ enumerable: true,
55
+ configurable: true,
56
+ writable: true,
57
+ value: true
58
+ });
59
+ Object.defineProperty(this, "skipping", {
60
+ enumerable: true,
61
+ configurable: true,
62
+ writable: true,
63
+ value: false
64
+ });
65
+ }
66
+ /**
67
+ * Answers the characters to scan for one character of source.
68
+ *
69
+ * @param character The next character of the source.
70
+ * @param prose Whether the lexer is inside a document, where `; ` is text.
71
+ * @returns The characters to scan now, possibly none.
72
+ */
73
+ filter(character, prose) {
74
+ if (this.skipping) {
75
+ if (character !== "\n")
76
+ return [];
77
+ this.skipping = false;
78
+ this.atLineStart = true;
79
+ return [character];
80
+ }
81
+ if (!this.atLineStart || prose) {
82
+ this.atLineStart = character === "\n";
83
+ return [character];
84
+ }
85
+ this.head += character;
86
+ if (this.head === EXAMPLE) {
87
+ this.head = "";
88
+ this.atLineStart = false;
89
+ this.skipping = true;
90
+ return [];
91
+ }
92
+ if (EXAMPLE.startsWith(this.head))
93
+ return [];
94
+ const kept = this.head.split("");
95
+ this.head = "";
96
+ this.atLineStart = character === "\n";
97
+ return kept;
98
+ }
99
+ /** Answers any characters still held when the source ends. */
100
+ flush() {
101
+ const kept = this.head.split("");
102
+ this.head = "";
103
+ return kept;
104
+ }
105
+ }
34
106
  const sourceTypeFailure = (value) => Frame.error(`$!.resource-import-source-type ${value.toString()}`);
35
107
  /** Evaluate a resource's character elements through the existing HC pipeline. */
36
108
  export function evaluateResourceSource(resource, scope) {
@@ -53,6 +125,13 @@ function evaluateResourceSourceWithChain(resource, scope, activeImports) {
53
125
  strictStructure: true,
54
126
  });
55
127
  let receiver = lexer;
128
+ const scan = (character) => {
129
+ receiver = sigilizer.scan(receiver, FrameSymbol.for(character));
130
+ if (receiver.isFailedResult())
131
+ return receiver;
132
+ return progress.firstFailure;
133
+ };
134
+ const examples = new ExampleFilter();
56
135
  const elements = resource.elements();
57
136
  for (const element of elements) {
58
137
  if (element.isFailedResult())
@@ -60,13 +139,19 @@ function evaluateResourceSourceWithChain(resource, scope, activeImports) {
60
139
  if (!hasCharacterContent(element))
61
140
  return sourceTypeFailure(element);
62
141
  for (const character of element.characterContent().split("")) {
63
- receiver = sigilizer.scan(receiver, FrameSymbol.for(character));
64
- if (receiver.isFailedResult())
65
- return receiver;
66
- if (progress.firstFailure)
67
- return progress.firstFailure;
142
+ const prose = receiver.is.document === true;
143
+ for (const kept of examples.filter(character, prose)) {
144
+ const failure = scan(kept);
145
+ if (failure)
146
+ return failure;
147
+ }
68
148
  }
69
149
  }
150
+ for (const kept of examples.flush()) {
151
+ const failure = scan(kept);
152
+ if (failure)
153
+ return failure;
154
+ }
70
155
  if (receiver !== lexer) {
71
156
  receiver = sigilizer.finish(receiver, FrameSymbol.end());
72
157
  if (receiver.isFailedResult())
@@ -27,7 +27,7 @@ export const syntaxFacets = [
27
27
  frame.FrameDoc.SYNTAX,
28
28
  frame.FrameName.SYNTAX,
29
29
  frame.FrameScopeAnchor.SYNTAX,
30
- frame.FrameInt.SYNTAX,
30
+ frame.FrameCount.SYNTAX,
31
31
  frame.FrameOperator.SYNTAX,
32
32
  frame.FrameString.SYNTAX,
33
33
  frame.FrameStringEnd.SYNTAX,
@@ -1,4 +1,4 @@
1
- import { FrameInt } from "./frame-int.js";
1
+ import { FrameCount } from "./frame-count.js";
2
2
  import { FrameAtom } from "./frame-atom.js";
3
3
  import { NilContext } from "./context.js";
4
4
  import { completeAtEnd, includeOrReserve } from "./atom-syntax.js";
@@ -174,7 +174,7 @@ Object.defineProperty(FrameBlob, "SYNTAX", {
174
174
  fromSource: (source) => {
175
175
  const lexeme = `${FrameBlob.BLOB_START}${source}`;
176
176
  return /^\d+$/.test(lexeme)
177
- ? FrameInt.for(lexeme)
177
+ ? FrameCount.for(lexeme)
178
178
  : new FrameBlob(lexeme);
179
179
  },
180
180
  }
@@ -0,0 +1,67 @@
1
+ import { completeAtEnd, includeOrReserve } from "./atom-syntax.js";
2
+ import { NilContext } from "./context.js";
3
+ import { FrameInt } from "./frame-int.js";
4
+ import { NUMERIC_RANK, } from "./frame-numeric.js";
5
+ /**
6
+ * Exact nonnegative integer, the root of the numeric ladder, and owner of
7
+ * decimal-digit source syntax: every digit literal is a count, `0` and
8
+ * `1234567890` alike.
9
+ *
10
+ * A count is a FrameInt that cannot be negative, so whatever accepts an integer
11
+ * accepts a count, and it prints exactly as the same integer does. It is closed
12
+ * under `+`, `*`, `%%`, and a nonnegative integral `**`, which therefore answer
13
+ * counts. The operations that can leave the domain answer the rung that holds
14
+ * their result whatever its sign: unary minus and `-` answer a FrameInt, and
15
+ * `/` answers a ratio, which collapses to a FrameInt when it is whole.
16
+ */
17
+ export class FrameCount extends FrameInt {
18
+ static for(source) {
19
+ return new FrameCount(source);
20
+ }
21
+ constructor(source, meta = NilContext, spelling) {
22
+ super(source, meta, spelling);
23
+ Object.defineProperty(this, "rank", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: NUMERIC_RANK.count
28
+ });
29
+ if (this.data < 0n || this.spelling.startsWith("-")) {
30
+ throw new RangeError(`count must not be negative: ${this.spelling}`);
31
+ }
32
+ }
33
+ promoteOne() {
34
+ return new FrameInt(this.data);
35
+ }
36
+ sameRung(value) {
37
+ return new FrameCount(value);
38
+ }
39
+ unaryPlus() {
40
+ return this.spelling.startsWith("+")
41
+ ? this
42
+ : new FrameCount(this.data, NilContext, `+${this.spelling}`);
43
+ }
44
+ }
45
+ Object.defineProperty(FrameCount, "SIGIL_STARTS", {
46
+ enumerable: true,
47
+ configurable: true,
48
+ writable: true,
49
+ value: [
50
+ { key: FrameCount.NUMBER_BEGIN.toString(), mode: "atom" },
51
+ ]
52
+ });
53
+ Object.defineProperty(FrameCount, "SYNTAX", {
54
+ enumerable: true,
55
+ configurable: true,
56
+ writable: true,
57
+ value: {
58
+ NAME: "FrameCount",
59
+ SIGIL_STARTS: FrameCount.SIGIL_STARTS,
60
+ recognize: (symbol, source = "") => {
61
+ const char = symbol.toString();
62
+ return includeOrReserve(char, FrameCount.NUMBER_CHAR.test(char), source);
63
+ },
64
+ finish: completeAtEnd,
65
+ fromSource: (source) => FrameCount.for(source),
66
+ }
67
+ });
@@ -1,6 +1,6 @@
1
1
  import { NilContext } from "./context.js";
2
2
  import { Frame } from "./frame.js";
3
- import { exactBigIntPower, exactPowerWithinLimit, FrameNumeric, projectBigIntRatio, } from "./frame-numeric.js";
3
+ import { exactBigIntPower, exactPowerWithinLimit, FrameNumeric, NUMERIC_RANK, projectBigIntRatio, } from "./frame-numeric.js";
4
4
  import { FrameNumber } from "./frame-number.js";
5
5
  import { FrameRational } from "./frame-rational.js";
6
6
  import { FrameSequence } from "./frame-sequence.js";
@@ -32,7 +32,7 @@ export class FrameDecimal extends FrameNumeric {
32
32
  enumerable: true,
33
33
  configurable: true,
34
34
  writable: true,
35
- value: 1
35
+ value: NUMERIC_RANK.decimal
36
36
  });
37
37
  Object.defineProperty(this, "numerator", {
38
38
  enumerable: true,
@@ -1,8 +1,7 @@
1
- import { completeAtEnd, includeOrReserve } from "./atom-syntax.js";
2
1
  import { NilContext } from "./context.js";
3
2
  import { FrameDecimal } from "./frame-decimal.js";
4
3
  import { Frame } from "./frame.js";
5
- import { exactBigIntPower, exactPowerWithinLimit, FrameNumeric, REPETITION_LIMIT, REPETITION_TEXT_LIMIT, } from "./frame-numeric.js";
4
+ import { exactBigIntPower, exactPowerWithinLimit, FrameNumeric, NUMERIC_RANK, REPETITION_LIMIT, REPETITION_TEXT_LIMIT, } from "./frame-numeric.js";
6
5
  import { hasCharacterContent } from "./frame-text.js";
7
6
  import { FrameNumber } from "./frame-number.js";
8
7
  const INTEGER_SOURCE = /^[+-]?[\p{Nd}]+$/u;
@@ -22,7 +21,13 @@ function normalizeDecimalDigits(source) {
22
21
  return ((codePoint - blockStart) % 10).toString();
23
22
  }).join("");
24
23
  }
25
- /** Exact bigint-backed integer and owner of decimal-digit source syntax. */
24
+ /**
25
+ * Exact bigint-backed signed integer.
26
+ *
27
+ * No literal produces one: the digits a source spells are a `FrameCount`, which
28
+ * owns that syntax. A FrameInt is what an operation answers once its result may
29
+ * be negative, such as unary minus or subtraction.
30
+ */
26
31
  export class FrameInt extends FrameNumeric {
27
32
  static for(source) {
28
33
  return new FrameInt(source);
@@ -33,7 +38,7 @@ export class FrameInt extends FrameNumeric {
33
38
  enumerable: true,
34
39
  configurable: true,
35
40
  writable: true,
36
- value: 0
41
+ value: NUMERIC_RANK.int
37
42
  });
38
43
  Object.defineProperty(this, "data", {
39
44
  enumerable: true,
@@ -119,22 +124,31 @@ export class FrameInt extends FrameNumeric {
119
124
  const spelling = this.spelling.startsWith("-") ? unsigned : `-${unsigned}`;
120
125
  return new FrameInt(-this.data, NilContext, spelling);
121
126
  }
127
+ /**
128
+ * The integer `value` on this frame's own rung, for the operations every
129
+ * integer rung is closed under: `+`, `*`, `%%`, and a nonnegative integral
130
+ * `**`. A count is not closed under `-`, which is why subtraction builds a
131
+ * FrameInt rather than asking here.
132
+ */
133
+ sameRung(value) {
134
+ return new FrameInt(value);
135
+ }
122
136
  addSame(right) {
123
- return new FrameInt(this.data + right.data);
137
+ return this.sameRung(this.data + right.data);
124
138
  }
125
139
  subtractSame(right) {
126
140
  return new FrameInt(this.data - right.data);
127
141
  }
128
142
  multiplySame(right) {
129
- return new FrameInt(this.data * right.data);
143
+ return this.sameRung(this.data * right.data);
130
144
  }
131
145
  divideSame(_right) {
132
- return Frame.error("$!.numeric-internal / FrameInt");
146
+ return Frame.error(`$!.numeric-internal / ${this.className()}`);
133
147
  }
134
148
  moduloSame(right) {
135
149
  const divisor = right.data;
136
150
  const remainder = this.data % divisor;
137
- return new FrameInt(remainder !== 0n && (remainder < 0n) !== (divisor < 0n)
151
+ return this.sameRung(remainder !== 0n && (remainder < 0n) !== (divisor < 0n)
138
152
  ? remainder + divisor
139
153
  : remainder);
140
154
  }
@@ -144,12 +158,12 @@ export class FrameInt extends FrameNumeric {
144
158
  }
145
159
  powerIntegral(exponent) {
146
160
  if (exponent < 0n) {
147
- return Frame.error("$!.numeric-internal ** FrameInt");
161
+ return Frame.error(`$!.numeric-internal ** ${this.className()}`);
148
162
  }
149
163
  if (!exactPowerWithinLimit([this.data], exponent)) {
150
- return Frame.error("$!.numeric-range ** FrameInt");
164
+ return Frame.error(`$!.numeric-range ** ${this.className()}`);
151
165
  }
152
- return new FrameInt(exactBigIntPower(this.data, exponent));
166
+ return this.sameRung(exactBigIntPower(this.data, exponent));
153
167
  }
154
168
  compareSame(right) {
155
169
  const value = right.data;
@@ -183,26 +197,3 @@ Object.defineProperty(FrameInt, "NUMBER_CHAR", {
183
197
  writable: true,
184
198
  value: /\d/
185
199
  });
186
- Object.defineProperty(FrameInt, "SIGIL_STARTS", {
187
- enumerable: true,
188
- configurable: true,
189
- writable: true,
190
- value: [
191
- { key: FrameInt.NUMBER_BEGIN.toString(), mode: "atom" },
192
- ]
193
- });
194
- Object.defineProperty(FrameInt, "SYNTAX", {
195
- enumerable: true,
196
- configurable: true,
197
- writable: true,
198
- value: {
199
- NAME: "FrameInt",
200
- SIGIL_STARTS: FrameInt.SIGIL_STARTS,
201
- recognize: (symbol, source = "") => {
202
- const char = symbol.toString();
203
- return includeOrReserve(char, FrameInt.NUMBER_CHAR.test(char), source);
204
- },
205
- finish: completeAtEnd,
206
- fromSource: (source) => FrameInt.for(source),
207
- }
208
- });
@@ -1,5 +1,5 @@
1
1
  import { NilContext } from "./context.js";
2
- import { FrameNumeric } from "./frame-numeric.js";
2
+ import { FrameNumeric, NUMERIC_RANK, } from "./frame-numeric.js";
3
3
  /** Inexact host-number rung, reached only by projection or inexact arithmetic. */
4
4
  export class FrameNumber extends FrameNumeric {
5
5
  static for(value) {
@@ -16,7 +16,7 @@ export class FrameNumber extends FrameNumeric {
16
16
  enumerable: true,
17
17
  configurable: true,
18
18
  writable: true,
19
- value: 3
19
+ value: NUMERIC_RANK.number
20
20
  });
21
21
  Object.defineProperty(this, "data", {
22
22
  enumerable: true,
@@ -1,5 +1,17 @@
1
1
  import { FrameAtom } from "./frame-atom.js";
2
2
  import { Frame } from "./frame.js";
3
+ /**
4
+ * The promotion ladder, root first: a rung's rank is its position here. The
5
+ * dispatch below names rungs only through this table, so a rung inserted below
6
+ * the root, such as a future `FrameBit`, renumbers this table and nothing else.
7
+ */
8
+ export const NUMERIC_RANK = {
9
+ count: 0,
10
+ int: 1,
11
+ decimal: 2,
12
+ rational: 3,
13
+ number: 4,
14
+ };
3
15
  /** The largest count accepted by integer repetition. */
4
16
  export const REPETITION_LIMIT = 65536n;
5
17
  /** The largest UTF-16 text result accepted by integer repetition. */
@@ -82,13 +94,15 @@ export class FrameNumeric extends FrameAtom {
82
94
  }
83
95
  if (right.isZero())
84
96
  return Frame.error("$!.division-by-zero /");
85
- const target = this.rank === 3 || right.rank === 1 ||
86
- right.rank === 3
87
- ? 3
88
- : 2;
89
- if (target === 3 && this.rank !== 3 && right.rank !== 3) {
90
- const projectedLeft = this.promoteTo(3);
91
- const projectedRight = right.promoteTo(3);
97
+ const { decimal, number, rational } = NUMERIC_RANK;
98
+ // Never below the rational rung: an exact quotient is a ratio, and one
99
+ // whose denominator reduces to 1 collapses to FrameInt, never to a count.
100
+ const target = this.rank === number || right.rank === decimal || right.rank === number
101
+ ? number
102
+ : rational;
103
+ if (target === number && this.rank !== number && right.rank !== number) {
104
+ const projectedLeft = this.promoteTo(number);
105
+ const projectedRight = right.promoteTo(number);
92
106
  const leftValue = Number(projectedLeft.valueOf());
93
107
  const rightValue = Number(projectedRight.valueOf());
94
108
  if (Number.isFinite(leftValue) && Number.isFinite(rightValue) &&
@@ -105,13 +119,16 @@ export class FrameNumeric extends FrameAtom {
105
119
  }
106
120
  return this.promoteTo(target).divideSame(right.promoteTo(target));
107
121
  }
122
+ /** Integer rungs only, joined like `+`, so two counts answer a count. */
108
123
  modulo(right) {
109
- if (this.rank !== 0 || right.rank !== 0) {
124
+ if (this.rank == null || right.rank == null ||
125
+ this.rank > NUMERIC_RANK.int || right.rank > NUMERIC_RANK.int) {
110
126
  return this.operationError("%%", right);
111
127
  }
112
128
  if (right.isZero())
113
129
  return Frame.error("$!.modulo-by-zero %%");
114
- return this.moduloSame(right);
130
+ const target = Math.max(this.rank, right.rank);
131
+ return this.promoteTo(target).moduloSame(right.promoteTo(target));
115
132
  }
116
133
  power(right) {
117
134
  if (this.rank == null || right.rank == null) {
@@ -119,15 +136,15 @@ export class FrameNumeric extends FrameAtom {
119
136
  }
120
137
  const exponent = right.integralValue();
121
138
  if (exponent == null) {
122
- const leftNumber = this.promoteTo(3);
123
- const rightNumber = right.promoteTo(3);
139
+ const leftNumber = this.promoteTo(NUMERIC_RANK.number);
140
+ const rightNumber = right.promoteTo(NUMERIC_RANK.number);
124
141
  return leftNumber.powerSame(rightNumber);
125
142
  }
126
143
  if (exponent < 0n && this.isZero()) {
127
144
  return Frame.error("$!.division-by-zero **");
128
145
  }
129
- if (exponent < 0n && this.rank !== 3) {
130
- return this.promoteTo(2).powerIntegral(exponent);
146
+ if (exponent < 0n && this.rank !== NUMERIC_RANK.number) {
147
+ return this.promoteTo(NUMERIC_RANK.rational).powerIntegral(exponent);
131
148
  }
132
149
  return this.powerIntegral(exponent);
133
150
  }
@@ -1,7 +1,7 @@
1
1
  import { NilContext } from "./context.js";
2
2
  import { FrameInt } from "./frame-int.js";
3
3
  import { Frame } from "./frame.js";
4
- import { exactBigIntPower, exactPowerWithinLimit, FrameNumeric, projectBigIntRatio, } from "./frame-numeric.js";
4
+ import { exactBigIntPower, exactPowerWithinLimit, FrameNumeric, NUMERIC_RANK, projectBigIntRatio, } from "./frame-numeric.js";
5
5
  import { FrameNumber } from "./frame-number.js";
6
6
  function greatestCommonDivisor(left, right) {
7
7
  let a = left < 0n ? -left : left;
@@ -13,6 +13,7 @@ function greatestCommonDivisor(left, right) {
13
13
  }
14
14
  /** Reduced exact ratio with a positive denominator. */
15
15
  export class FrameRational extends FrameNumeric {
16
+ /** A whole result collapses to FrameInt, never to a count, whatever its sign. */
16
17
  static create(numerator, denominator) {
17
18
  if (denominator === 0n)
18
19
  return Frame.error("$!.division-by-zero /");
@@ -27,7 +28,7 @@ export class FrameRational extends FrameNumeric {
27
28
  enumerable: true,
28
29
  configurable: true,
29
30
  writable: true,
30
- value: 2
31
+ value: NUMERIC_RANK.rational
31
32
  });
32
33
  Object.defineProperty(this, "numerator", {
33
34
  enumerable: true,
@@ -22,7 +22,7 @@
22
22
  * @module
23
23
  */
24
24
  import { Frame } from "./frame.js";
25
- import { FrameInt } from "./frame-int.js";
25
+ import { FrameCount } from "./frame-count.js";
26
26
  import { FrameString } from "./frame-string.js";
27
27
  import { FrameURI } from "./frame-uri.js";
28
28
  import { hasCharacterContent } from "./frame-text.js";
@@ -107,12 +107,12 @@ export class FrameResource extends FrameURI {
107
107
  if (placement.kind === "scheme") {
108
108
  const written = placement.handler.write(placement.parts, content);
109
109
  return written.ok
110
- ? FrameInt.for(written.count.toString())
110
+ ? FrameCount.for(written.count.toString())
111
111
  : this.storeRefusal(written.reason);
112
112
  }
113
113
  const written = this.store.write(placement.path, content);
114
114
  return written.ok
115
- ? FrameInt.for(written.content.length.toString())
115
+ ? FrameCount.for(written.content.length.toString())
116
116
  : this.storeRefusal(written.reason);
117
117
  }
118
118
  /**
package/esm/lib/frames.js CHANGED
@@ -22,8 +22,9 @@ export { FrameList } from "./frames/frame-list.js";
22
22
  export { FrameName } from "./frames/frame-name.js";
23
23
  export { FrameNote } from "./frames/frame-note.js";
24
24
  export { FrameScopeAnchor, } from "./frames/frame-scope-anchor.js";
25
- export { FrameNumeric } from "./frames/frame-numeric.js";
25
+ export { FrameNumeric, NUMERIC_RANK, } from "./frames/frame-numeric.js";
26
26
  export { FrameInt } from "./frames/frame-int.js";
27
+ export { FrameCount } from "./frames/frame-count.js";
27
28
  export { FrameDecimal } from "./frames/frame-decimal.js";
28
29
  export { FrameSequence } from "./frames/frame-sequence.js";
29
30
  export { FrameTypedNumber } from "./frames/frame-typed-number.js";
@@ -1 +1 @@
1
- export const VERSION = "0.20.2";
1
+ export const VERSION = "0.21.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hclang",
3
- "version": "0.20.2",
3
+ "version": "0.21.0",
4
4
  "description": "Homoiconic C command-line interpreter and REPL",
5
5
  "keywords": [
6
6
  "language",
@@ -1,36 +0,0 @@
1
- /**
2
- * The standard modules every supported host serves, read-only, under canonical
3
- * keys.
4
- *
5
- * A standard module is HC source the package maintains: every
6
- * `lib/modules/*.hc` is one, under the key `modules/<file>`, so
7
- * `lib/modules/figures.hc` is reached from a program as
8
- * `'./modules/figures.hc'`. The key is root-relative like every other path, so
9
- * it names a location inside the root binding, never one beside a source file
10
- * or the working directory. A host lays the modules over its root's store as
11
- * fixed entries: reading one answers the maintained source, writing one is
12
- * refused, and every other path, a sibling under `modules/` included, still
13
- * resolves inside that root. No permission flag and no root widens, so a program
14
- * gains these reads and nothing else.
15
- *
16
- * The sources are compiled into the program from the generated
17
- * `lib/modules/standard-sources.ts` (`deno task modules:embed`, checked by
18
- * `deno task modules:check`), so the CLI, the compiled binary, the npm package,
19
- * `HCLang`, and the browser playground serve the same text without reading a
20
- * file at run time.
21
- *
22
- * @module
23
- */
24
- import { ResourceMapStore, } from "../frames/resource-store.js";
25
- import { STANDARD_SOURCES } from "./standard-sources.js";
26
- /** Checked and copied once, so a host start or `reset()` only wraps a store. */
27
- const overlayStandardModules = ResourceMapStore.overlay(STANDARD_SOURCES);
28
- /**
29
- * Lays the standard modules over a store as read-only entries.
30
- *
31
- * @param store The root's store, which keeps every other path.
32
- * @returns A store that serves the standard modules and delegates the rest.
33
- */
34
- export function withStandardModules(store) {
35
- return overlayStandardModules(store);
36
- }