parseman 0.44.0 → 0.45.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.
Files changed (77) hide show
  1. package/dist/analysis/diagnose.d.ts +118 -0
  2. package/dist/analysis/diagnose.d.ts.map +1 -0
  3. package/dist/analysis/gating.d.ts +9 -9
  4. package/dist/analysis/gating.d.ts.map +1 -1
  5. package/dist/analysis/grammar.d.ts.map +1 -1
  6. package/dist/combinators/choice.d.ts.map +1 -1
  7. package/dist/combinators/dispatch.d.ts +19 -1
  8. package/dist/combinators/dispatch.d.ts.map +1 -1
  9. package/dist/combinators/expect.d.ts.map +1 -1
  10. package/dist/combinators/first-set.d.ts.map +1 -1
  11. package/dist/combinators/node.d.ts +19 -0
  12. package/dist/combinators/node.d.ts.map +1 -1
  13. package/dist/compiler/build-arity.d.ts +28 -0
  14. package/dist/compiler/build-arity.d.ts.map +1 -1
  15. package/dist/compiler/codegen.d.ts +80 -60
  16. package/dist/compiler/codegen.d.ts.map +1 -1
  17. package/dist/compiler/degradation.d.ts +123 -0
  18. package/dist/compiler/degradation.d.ts.map +1 -0
  19. package/dist/compiler/fields.d.ts.map +1 -1
  20. package/dist/compiler/grammar-coverage-ids.d.ts.map +1 -1
  21. package/dist/compiler/inline-build.d.ts.map +1 -1
  22. package/dist/compiler/ir-serialize.d.ts.map +1 -1
  23. package/dist/compiler/linker.d.ts +1 -1
  24. package/dist/compiler/linker.d.ts.map +1 -1
  25. package/dist/coverage.d.ts +13 -0
  26. package/dist/coverage.d.ts.map +1 -1
  27. package/dist/cst/reflection.d.ts.map +1 -1
  28. package/dist/functional/run.d.ts.map +1 -1
  29. package/dist/index.cjs +707 -471
  30. package/dist/index.cjs.map +4 -4
  31. package/dist/index.d.ts +4 -6
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +707 -471
  34. package/dist/index.js.map +4 -4
  35. package/dist/language-service/index.cjs +40 -30
  36. package/dist/language-service/index.cjs.map +3 -3
  37. package/dist/language-service/index.js +40 -30
  38. package/dist/language-service/index.js.map +3 -3
  39. package/dist/oracle/digest.d.ts +132 -6
  40. package/dist/oracle/digest.d.ts.map +1 -1
  41. package/dist/oracle/index.cjs +136 -305
  42. package/dist/oracle/index.cjs.map +4 -4
  43. package/dist/oracle/index.d.ts +43 -31
  44. package/dist/oracle/index.d.ts.map +1 -1
  45. package/dist/oracle/index.js +136 -305
  46. package/dist/oracle/index.js.map +4 -4
  47. package/dist/plugin/evaluator.d.ts +3 -0
  48. package/dist/plugin/evaluator.d.ts.map +1 -1
  49. package/dist/plugin/index.cjs +1127 -747
  50. package/dist/plugin/index.cjs.map +4 -4
  51. package/dist/plugin/index.d.ts +18 -0
  52. package/dist/plugin/index.d.ts.map +1 -1
  53. package/dist/plugin/index.js +1127 -747
  54. package/dist/plugin/index.js.map +4 -4
  55. package/dist/plugin/reducer-resolver.d.ts +41 -0
  56. package/dist/plugin/reducer-resolver.d.ts.map +1 -0
  57. package/dist/run/index.cjs +33 -30
  58. package/dist/run/index.cjs.map +2 -2
  59. package/dist/run/index.js +33 -30
  60. package/dist/run/index.js.map +2 -2
  61. package/dist/spec/index.cjs +221 -34
  62. package/dist/spec/index.cjs.map +4 -4
  63. package/dist/spec/index.js +221 -34
  64. package/dist/spec/index.js.map +4 -4
  65. package/dist/spec/model.d.ts.map +1 -1
  66. package/dist/types.d.ts +6 -1
  67. package/dist/types.d.ts.map +1 -1
  68. package/dist/version.d.ts +1 -1
  69. package/package.json +7 -3
  70. package/dist/combinators/guard.d.ts +0 -8
  71. package/dist/combinators/guard.d.ts.map +0 -1
  72. package/dist/cst/offset-model.d.ts +0 -119
  73. package/dist/cst/offset-model.d.ts.map +0 -1
  74. package/dist/oracle/corpus.d.ts +0 -32
  75. package/dist/oracle/corpus.d.ts.map +0 -1
  76. package/dist/oracle/identity.d.ts +0 -117
  77. package/dist/oracle/identity.d.ts.map +0 -1
@@ -325,6 +325,35 @@ function assertHostModeCompatible(mode, build, hostBranchElided = true) {
325
325
  }
326
326
 
327
327
  // src/functional/run.ts
328
+ var SELECT_EXAMPLE = "run(entry, input, { rootTrivia: { select: ['blockComment', 'lineComment'] } })";
329
+ var REMOVED_RUN_RESULT_FIELDS = [
330
+ [
331
+ "triviaMap",
332
+ `It was a dense root-trivia index built on every parse; root trivia is now an OPT-IN sparse capture, because most grammars paid for an index they never read. Migration: name the trivia labels your grammar defines \u2014 ${SELECT_EXAMPLE} \u2014 and read \`RunResult.rootTrivia\`, whose \`.index\` carries the labels and gap lookups \`triviaMap\` exposed.`
333
+ ],
334
+ [
335
+ "triviaLog",
336
+ `It was the flat \`start, end[, kindIndex]\` log every other trivia view was derived from, and it is no longer allocated at all \u2014 not empty, absent. Migration: request the labels you need \u2014 ${SELECT_EXAMPLE} \u2014 and read \`RunResult.rootTrivia.rows\`. Do NOT reuse a stride-2/3 reader: rows are a different width and a different unit (one row per SELECTED marker, not one per trivia chunk), so an old loop reads confidently wrong offsets rather than failing.`
337
+ ],
338
+ [
339
+ "triviaKindLabels",
340
+ `It was already optional, so nothing ever flagged its disappearance \u2014 and \`triviaKindMask(undefined, \u2026)\` means "capture everything", so reading it now silently WIDENS capture instead of erroring. Migration: request labels \u2014 ${SELECT_EXAMPLE} \u2014 then the set you asked for is \`RunResult.rootTrivia.select\` and the resolved table is \`RunResult.rootTrivia.index.labels\`.`
341
+ ]
342
+ ];
343
+ function guardRemovedFields(result) {
344
+ for (const [name, detail] of REMOVED_RUN_RESULT_FIELDS) {
345
+ Object.defineProperty(result, name, {
346
+ configurable: true,
347
+ enumerable: false,
348
+ get() {
349
+ throw new TypeError(
350
+ `RunResult.${name} was REMOVED in parseman 0.44.0 and has no default replacement. ${detail}`
351
+ );
352
+ }
353
+ });
354
+ }
355
+ return result;
356
+ }
328
357
  var invoke = (r, input, pos, ctx) => typeof r === "function" ? r(input, pos, ctx) : r.parse(input, pos, ctx);
329
358
  function triviaKindLabelsFromRunnable(r) {
330
359
  if (!r) return void 0;
@@ -427,37 +456,11 @@ function runOnce(entry, input, options, phase, profileState) {
427
456
  unconsumedFrom
428
457
  };
429
458
  }
430
- function clonePassState(state) {
431
- if (state === null || typeof state !== "object") return state;
432
- return Array.isArray(state) ? [...state] : { ...state };
433
- }
434
- function profilePass(entry, input, options, phase) {
435
- const state = { phase, nodes: 0, childSlots: 0, rawSlots: 0, triviaSlots: 0, fieldSlots: 0, hostCalls: 0 };
436
- const passOptions = options.state === void 0 ? options : { ...options, state: clonePassState(options.state) };
437
- const start = performance.now();
438
- const result = runOnce(entry, input, passOptions, phase, state);
439
- const { phase: _phase, ...counts } = state;
440
- return { result, profile: { ms: performance.now() - start, ...counts } };
441
- }
442
459
  function run(entry, input, options = {}) {
443
- if (!options.profile) return runOnce(entry, input, options);
444
- if (typeof entry !== "function") {
445
- throw new TypeError("run({ profile: true }) requires a compiled parser entry");
446
- }
447
- const recognizer = profilePass(entry, input, options, "recognizer");
448
- const capture = profilePass(entry, input, options, "capture");
449
- const host = profilePass(entry, input, options, "host");
450
- if (recognizer.result.ok !== host.result.ok || capture.result.ok !== host.result.ok || recognizer.result.unconsumedFrom !== host.result.unconsumedFrom || capture.result.unconsumedFrom !== host.result.unconsumedFrom) {
451
- throw new Error("run({ profile: true }) changed recognition; the grammar is not profile-safe");
452
- }
453
- return {
454
- ...host.result,
455
- profile: {
456
- recognizer: recognizer.profile,
457
- structuralCapture: capture.profile,
458
- hostConstruction: host.profile
459
- }
460
- };
460
+ if (!options.profile) return guardRemovedFields(runOnce(entry, input, options));
461
+ throw new TypeError(
462
+ "run({ profile: true }) is unavailable: profiling counters are no longer compiled into parser artifacts, and the interpreter does not implement them yet. Profiling is moving to interpreted mode."
463
+ );
461
464
  }
462
465
 
463
466
  // src/combinators/completions.ts
@@ -500,6 +503,13 @@ var SELECTED_ROOT_FINISH = [
500
503
  ` }`
501
504
  ].join("\n");
502
505
 
506
+ // src/compiler/inline-build.ts
507
+ var ANN = String.raw`\s*\??\s*(?::[^,)=]+)?`;
508
+ var ANY_P = String.raw`\w+${ANN}`;
509
+ var MK_BUILD_RE = new RegExp(
510
+ String.raw`^\(\s*(\w+)${ANN}\s*,\s*${ANY_P}\s*,\s*(\w+)${ANN}\s*,\s*(\w+)${ANN}\s*,\s*(\w+)${ANN}\s*\)\s*=>\s*mk\s*\(\s*(['"])([^'"]+)\5\s*,\s*\1\s*,\s*\3\s*,\s*\2\s*,\s*\4\s*\)\s*$`
511
+ );
512
+
503
513
  // src/compiler/linker.ts
504
514
  function normalizeCstCollapse(collapse) {
505
515
  if (collapse === true) return () => true;