parseman 0.59.0 → 0.59.2

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.
Files changed (65) hide show
  1. package/README.md +5 -4
  2. package/dist/analysis/diagnostics.js +19 -45
  3. package/dist/analysis/diagnostics.js.map +1 -1
  4. package/dist/cli/index.js +19 -45
  5. package/dist/cli/index.js.map +1 -1
  6. package/dist/combinators/choice.d.ts +0 -5
  7. package/dist/combinators/choice.d.ts.map +1 -1
  8. package/dist/combinators/scanTo.d.ts +1 -16
  9. package/dist/combinators/scanTo.d.ts.map +1 -1
  10. package/dist/compiler/ir-serialize.d.ts.map +1 -1
  11. package/dist/compiler/linker.d.ts +0 -3
  12. package/dist/compiler/linker.d.ts.map +1 -1
  13. package/dist/compiler/token-alphabet.d.ts +5 -25
  14. package/dist/compiler/token-alphabet.d.ts.map +1 -1
  15. package/dist/compiler/token-capability.js.map +1 -1
  16. package/dist/compiler/token-dispatch.d.ts +8 -79
  17. package/dist/compiler/token-dispatch.d.ts.map +1 -1
  18. package/dist/cst/root-trivia-scope.d.ts +0 -3
  19. package/dist/cst/root-trivia-scope.d.ts.map +1 -1
  20. package/dist/cst/trivia-entries.d.ts +0 -2
  21. package/dist/cst/trivia-entries.d.ts.map +1 -1
  22. package/dist/cst/trivia-kinds.d.ts +0 -5
  23. package/dist/cst/trivia-kinds.d.ts.map +1 -1
  24. package/dist/index.js +20 -46
  25. package/dist/index.js.map +1 -1
  26. package/dist/language-service/index.js.map +1 -1
  27. package/dist/plugin/index.js +20 -46
  28. package/dist/plugin/index.js.map +1 -1
  29. package/dist/run/index.js.map +1 -1
  30. package/dist/spec/index.js.map +1 -1
  31. package/dist/spec/model.d.ts +0 -8
  32. package/dist/spec/model.d.ts.map +1 -1
  33. package/dist/table/encode.d.ts.map +1 -1
  34. package/dist/table/index.js +19 -45
  35. package/dist/table/index.js.map +1 -1
  36. package/dist/table/ops.d.ts +6 -6
  37. package/dist/table/ops.d.ts.map +1 -1
  38. package/dist/table/program.d.ts +0 -1
  39. package/dist/table/program.d.ts.map +1 -1
  40. package/dist/table/scalar-terminal.d.ts +0 -7
  41. package/dist/table/scalar-terminal.d.ts.map +1 -1
  42. package/dist/table/scan-shapes.d.ts +0 -8
  43. package/dist/table/scan-shapes.d.ts.map +1 -1
  44. package/dist/table/site-labels.d.ts +0 -2
  45. package/dist/table/site-labels.d.ts.map +1 -1
  46. package/dist/version.d.ts +1 -1
  47. package/package.json +1 -1
  48. package/src/combinators/choice.ts +1 -1
  49. package/src/combinators/scanTo.ts +1 -1
  50. package/src/compiler/ir-serialize.ts +2 -1
  51. package/src/compiler/linker.ts +1 -1
  52. package/src/compiler/token-alphabet.ts +14 -10
  53. package/src/compiler/token-dispatch.ts +10 -313
  54. package/src/compiler/token-scanner.ts +2 -2
  55. package/src/cst/root-trivia-scope.ts +1 -1
  56. package/src/cst/trivia-entries.ts +1 -1
  57. package/src/cst/trivia-kinds.ts +1 -1
  58. package/src/spec/model.ts +1 -1
  59. package/src/table/encode.ts +16 -39
  60. package/src/table/ops.ts +6 -6
  61. package/src/table/program.ts +1 -1
  62. package/src/table/scalar-terminal.ts +1 -1
  63. package/src/table/scan-shapes.ts +15 -46
  64. package/src/table/site-labels.ts +1 -1
  65. package/src/version.ts +1 -1
package/README.md CHANGED
@@ -200,10 +200,11 @@ pnpm docs:dev # this documentation site, locally
200
200
  Benchmark and chart tasks (`pnpm bench`, `bench:svg`, `bench:parseman`, …) are described in
201
201
  the [benchmarks guide](https://matthew-dean.github.io/parseman/guide/benchmarks#reproducing-the-numbers).
202
202
 
203
- The frozen 0.48 runtime architecture and release specification is
204
- [`docs/design/parseman-0.48.md`](./docs/design/parseman-0.48.md). Detailed measurements
205
- and rejected experiments remain in the linked evidence registers rather than being
206
- treated as current design.
203
+ How the code fits together (the pipeline, the engines, the table format, macro builds
204
+ and how performance is measured) is in
205
+ [`docs/design/internals.md`](https://github.com/matthew-dean/parseman/blob/main/docs/design/internals.md). Start there before reading
206
+ `src/`. The token and lexical-body specification is
207
+ [`docs/design/parseman-0.48.md`](https://github.com/matthew-dean/parseman/blob/main/docs/design/parseman-0.48.md).
207
208
 
208
209
  ## License
209
210
 
@@ -7452,18 +7452,10 @@ var Encoder = class {
7452
7452
  /** TOKEN bodies are an all-program decision. A complete occurrence inside an
7453
7453
  * otherwise incomplete final graph stays on CHARACTER with every sibling. */
7454
7454
  selectLexicalBodies;
7455
- /**
7456
- * Decides the extra operands laid down below. ALWAYS TRUE — see
7457
- * `TableSettings.recovery`. Kept as a field rather than folded away because it
7458
- * is what every emit site reads, and the emit sites are where the shape of the
7459
- * row is stated.
7460
- */
7461
- rec;
7462
7455
  constructor(settings, selectLexicalBodies) {
7463
7456
  this.settings = settings;
7464
7457
  this.track = settings.trackLines === true;
7465
7458
  this.selectLexicalBodies = selectLexicalBodies;
7466
- this.rec = true;
7467
7459
  this.plan = settings.coverage;
7468
7460
  this.cov = settings.coverage === void 0 ? void 0 : settings.coverage.definitions.map((d) => [d.id, covKindCode(d.kind)]);
7469
7461
  this.covIndex = new Map((this.cov ?? []).map((d, i) => [d[0], i]));
@@ -7965,12 +7957,10 @@ var Encoder = class {
7965
7957
  }
7966
7958
  case "sequence": {
7967
7959
  const kids = d.parsers.map((c) => this.node(c).ip);
7968
- const head = this.emitHead(d.valueUnused ? OP_SEQV : OP_SEQ, 1 + kids.length + (this.rec ? kids.length : 0));
7960
+ const head = this.emitHead(d.valueUnused ? OP_SEQV : OP_SEQ, 1 + 2 * kids.length);
7969
7961
  this.code[head + 1] = kids.length;
7970
7962
  for (let i = 0; i < kids.length; i++) this.code[head + 2 + i] = kids[i];
7971
- if (this.rec) {
7972
- for (let i = 0; i < kids.length; i++) this.code[head + 2 + kids.length + i] = this.followClass(d.parsers, i);
7973
- }
7963
+ for (let i = 0; i < kids.length; i++) this.code[head + 2 + kids.length + i] = this.followClass(d.parsers, i);
7974
7964
  return head;
7975
7965
  }
7976
7966
  case "choice": {
@@ -8072,25 +8062,22 @@ var Encoder = class {
8072
8062
  const itemClass = matchesEmpty(d.parser, /* @__PURE__ */ new Set(), rr) ? -1 : this.charClass(firstSetOf(d.parser, /* @__PURE__ */ new Set(), rr, this.activeTrivia));
8073
8063
  const op = d.valueUnused ? OP_REPV : OP_REP;
8074
8064
  const min = d.tag === "many" ? 0 : d.min;
8075
- return this.rec ? this.emit(op, child, min, d.max ?? -1, -1, 0, this.expected(deriveExpected(d.parser)), itemClass) : this.emit(op, child, min, d.max ?? -1, -1, 0);
8065
+ return this.emit(op, child, min, d.max ?? -1, -1, 0, this.expected(deriveExpected(d.parser)), itemClass);
8076
8066
  }
8077
8067
  case "sepBy": {
8078
8068
  const child = this.node(d.parser).ip;
8079
8069
  const sep = this.node(d.separator).ip;
8080
8070
  const flags = (d.trailing === "allow" ? 1 : 0) | (d.keepSeparators === true ? 2 : 0) | (d.min >= 2 ? 4 : 0);
8081
- if (this.rec) {
8082
- return this.emit(
8083
- OP_REP,
8084
- child,
8085
- d.min,
8086
- d.max ?? -1,
8087
- sep,
8088
- flags,
8089
- this.expected(deriveExpected(d.parser)),
8090
- this.charClass(firstSetOf(d.separator, /* @__PURE__ */ new Set(), this.refResolver(), this.activeTrivia))
8091
- );
8092
- }
8093
- return d.min >= 2 ? this.emit(OP_REP, child, d.min, d.max ?? -1, sep, flags, this.expected(deriveExpected(d.parser))) : this.emit(OP_REP, child, d.min, d.max ?? -1, sep, flags);
8071
+ return this.emit(
8072
+ OP_REP,
8073
+ child,
8074
+ d.min,
8075
+ d.max ?? -1,
8076
+ sep,
8077
+ flags,
8078
+ this.expected(deriveExpected(d.parser)),
8079
+ this.charClass(firstSetOf(d.separator, /* @__PURE__ */ new Set(), this.refResolver(), this.activeTrivia))
8080
+ );
8094
8081
  }
8095
8082
  case "optional": {
8096
8083
  const head = this.emit(OP_OPT, this.lookaheadGate(d.parser, this.node(d.parser).ip));
@@ -8101,14 +8088,12 @@ var Encoder = class {
8101
8088
  const inner = d.parser._def;
8102
8089
  if (inner.tag === "sequence" && !this.memo.has(d.parser) && !this.pending.has(d.parser)) {
8103
8090
  const kids = inner.parsers.map((c) => this.node(c).ip);
8104
- const head = this.emitHead(OP_SEQX, 2 + kids.length + (this.rec ? kids.length : 0));
8091
+ const head = this.emitHead(OP_SEQX, 2 + 2 * kids.length);
8105
8092
  const projection = directArrayProjection(d.fn, d.fnSrc, kids.length);
8106
8093
  this.code[head + 1] = projection === null ? this.fn(d.fn, d.fnSrc ?? null) : ~projection;
8107
8094
  this.code[head + 2] = kids.length;
8108
8095
  for (let i = 0; i < kids.length; i++) this.code[head + 3 + i] = kids[i];
8109
- if (this.rec) {
8110
- for (let i = 0; i < kids.length; i++) this.code[head + 3 + kids.length + i] = this.followClass(inner.parsers, i);
8111
- }
8096
+ for (let i = 0; i < kids.length; i++) this.code[head + 3 + kids.length + i] = this.followClass(inner.parsers, i);
8112
8097
  return head;
8113
8098
  }
8114
8099
  const child = this.node(d.parser).ip;
@@ -8431,7 +8416,7 @@ var Encoder = class {
8431
8416
  ...this.settings.hostMode === void 0 ? {} : { hostMode: this.settings.hostMode },
8432
8417
  ...this.runtimeOnly.size === 0 ? {} : { runtimeOnly: [...this.runtimeOnly].sort() },
8433
8418
  ...this.triviaSpecs.length === 0 ? {} : { triviaSpecs: this.triviaSpecs },
8434
- ...this.rec ? { rec: 1 } : {},
8419
+ rec: 1,
8435
8420
  ...this.cov === void 0 ? {} : { cov: this.cov },
8436
8421
  lines: this.track ? 1 : 0
8437
8422
  }, void 0, {
@@ -9195,7 +9180,6 @@ function caseFoldLiteralOrAlt(source) {
9195
9180
  }
9196
9181
  return { kind: "alt", arms: litArms, disjoint: false, firsts: litArms.map(() => null) };
9197
9182
  }
9198
- var scanToIndexOfEnabled = () => process.env.PARSEMAN_SCANTO === "indexof";
9199
9183
  var classCond = (cVar, ranges) => ranges.map(([lo, hi]) => lo === hi ? `${cVar} === ${lo}` : `(${cVar} >= ${lo} && ${cVar} <= ${hi})`).join(" || ");
9200
9184
  var litCond = (base, cps, firstVar) => cps.map(
9201
9185
  (cp, k) => k === 0 && firstVar ? `${firstVar} === ${cp}` : `input.charCodeAt(${base}${k ? ` + ${k}` : ""}) === ${cp}`
@@ -9425,13 +9409,7 @@ function emitShapeMatch(shape, start, mint, ind, firstChar) {
9425
9409
  const j2 = mint("_j");
9426
9410
  const openLen2 = shape.open.length;
9427
9411
  const openChk2 = openLen2 === 1 ? `${codeAt(start, firstChar)} === ${shape.open[0]}` : litCond(start, shape.open, firstChar);
9428
- const stopCp = shape.stop.length === 1 && shape.stop[0][0] === shape.stop[0][1] ? shape.stop[0][0] : null;
9429
- const scanLine = stopCp !== null && stopCp <= 65535 && scanToIndexOfEnabled() ? (
9430
- // No temp is minted: a temp would renumber every later variable in the
9431
- // function and show up as an artifact-size delta that is counter
9432
- // renumbering rather than this change (the §9.1.4 / §9.2 effect).
9433
- `${ind} ${j2} = input.indexOf(${JSON.stringify(String.fromCharCode(stopCp))}, ${j2}); if (${j2} < 0) ${j2} = input.length`
9434
- ) : `${ind} while (${j2} < input.length && !(${classCond(`input.charCodeAt(${j2})`, shape.stop)})) ${j2}++`;
9412
+ const scanLine = `${ind} while (${j2} < input.length && !(${classCond(`input.charCodeAt(${j2})`, shape.stop)})) ${j2}++`;
9435
9413
  return {
9436
9414
  setup: [
9437
9415
  `${ind}let ${j2} = ${start}`,
@@ -9489,11 +9467,7 @@ function emitShapeMatch(shape, start, mint, ind, firstChar) {
9489
9467
  const closeLen = shape.close.length;
9490
9468
  const openChk = openLen === 1 ? `${codeAt(start, firstChar)} === ${shape.open[0]}` : litCond(start, shape.open, firstChar);
9491
9469
  const closeChk = litCond(j, shape.close);
9492
- const closeStr = String.fromCharCode(...shape.close);
9493
- const scanLines = scanToIndexOfEnabled() ? [
9494
- `${ind} ${j} = input.indexOf(${JSON.stringify(closeStr)}, ${j}); if (${j} < 0) ${j} = input.length`,
9495
- `${ind} if (${j} + ${closeLen} <= input.length) ${endV} = ${j} + ${closeLen}`
9496
- ] : [
9470
+ const scanLines = [
9497
9471
  `${ind} while (${j} + ${closeLen - 1} < input.length && !(${closeChk})) ${j}++`,
9498
9472
  `${ind} if (${j} + ${closeLen} <= input.length && (${closeChk})) ${endV} = ${j} + ${closeLen}`
9499
9473
  ];
@@ -16409,7 +16383,7 @@ function tableRules(source, metadataOrEntry = {}) {
16409
16383
  }
16410
16384
 
16411
16385
  // src/version.ts
16412
- var PARSEMAN_VERSION = "0.59.0";
16386
+ var PARSEMAN_VERSION = "0.59.2";
16413
16387
 
16414
16388
  // src/table/emit.ts
16415
16389
  var FACTORY_ARITY_GUARD = `if(arguments.length<${EMITTED_PARAMS.length})throw new Error(${JSON.stringify(`parseman: this parser was printed by parseman ${PARSEMAN_VERSION}; upgrade the parseman runtime to at least that version`)});`;