parseman 0.61.4 → 0.61.6

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 (46) hide show
  1. package/dist/analysis/diagnostics.js +844 -522
  2. package/dist/analysis/diagnostics.js.map +3 -3
  3. package/dist/cli/index.js +846 -522
  4. package/dist/cli/index.js.map +3 -3
  5. package/dist/cst/capture-buffer.d.ts +3 -2
  6. package/dist/cst/capture-buffer.d.ts.map +1 -1
  7. package/dist/index.js +890 -523
  8. package/dist/index.js.map +3 -3
  9. package/dist/plugin/entry-supercompiler.d.ts +15 -0
  10. package/dist/plugin/entry-supercompiler.d.ts.map +1 -1
  11. package/dist/plugin/index.js +959 -503
  12. package/dist/plugin/index.js.map +3 -3
  13. package/dist/table/assemble.d.ts.map +1 -1
  14. package/dist/table/child-slots.d.ts.map +1 -1
  15. package/dist/table/emit-assembly.d.ts +1 -1
  16. package/dist/table/emit-assembly.d.ts.map +1 -1
  17. package/dist/table/encode.d.ts.map +1 -1
  18. package/dist/table/exec.d.ts.map +1 -1
  19. package/dist/table/fail-clean.d.ts.map +1 -1
  20. package/dist/table/hold-gap.d.ts.map +1 -1
  21. package/dist/table/index.js +421 -54
  22. package/dist/table/index.js.map +3 -3
  23. package/dist/table/late-frame.d.ts +18 -0
  24. package/dist/table/late-frame.d.ts.map +1 -0
  25. package/dist/table/ops.d.ts +17 -0
  26. package/dist/table/ops.d.ts.map +1 -1
  27. package/dist/table/select-hot.d.ts +9 -0
  28. package/dist/table/select-hot.d.ts.map +1 -1
  29. package/dist/table/site-labels.d.ts +5 -1
  30. package/dist/table/site-labels.d.ts.map +1 -1
  31. package/dist/version.d.ts +1 -1
  32. package/package.json +1 -1
  33. package/src/cst/capture-buffer.ts +20 -11
  34. package/src/plugin/entry-supercompiler.ts +110 -1
  35. package/src/table/assemble.ts +124 -4
  36. package/src/table/child-slots.ts +9 -1
  37. package/src/table/emit-assembly.ts +101 -14
  38. package/src/table/encode.ts +69 -6
  39. package/src/table/exec.ts +7 -1
  40. package/src/table/fail-clean.ts +8 -1
  41. package/src/table/hold-gap.ts +5 -1
  42. package/src/table/late-frame.ts +54 -0
  43. package/src/table/ops.ts +19 -0
  44. package/src/table/select-hot.ts +96 -18
  45. package/src/table/site-labels.ts +38 -14
  46. package/src/version.ts +1 -1
@@ -60,7 +60,7 @@
60
60
  * label licenses at a leaf is dropping the TEST — never the capture.
61
61
  */
62
62
  import {
63
- OP_ATTEMPT, OP_CHOICE, OP_DISPATCH, OP_EXPECT, OP_FIELD, OP_GATE, OP_LABEL, OP_LEAF, OP_LIT, OP_SOURCE_LEAF,
63
+ OP_CONT, OP_SEED, OP_ATTEMPT, OP_CHOICE, OP_DISPATCH, OP_EXPECT, OP_FIELD, OP_GATE, OP_LABEL, OP_LEAF, OP_LIT, OP_SOURCE_LEAF,
64
64
  OP_NODE, OP_NODE_TRACK, OP_NOT, OP_OPT, OP_PEEK, OP_REP, OP_REPV, OP_ROUTED, OP_RULE,
65
65
  OP_SCAN, OP_SCOPE, OP_SCOPE_CAP, OP_SCOPE_PLAIN, SCOPE_INHERIT, OP_SEQ, OP_SEQV, OP_SEQX, OP_TOKEN, OP_XFORM,
66
66
  } from './ops.ts'
@@ -161,7 +161,7 @@ export function passCollapse(code: Int32Array, ip: number, hostCst: boolean): bo
161
161
  else if (op === OP_RULE) at = code[at + 1]!
162
162
  else break
163
163
  }
164
- return code[at] === OP_NODE
164
+ return code[at] === OP_NODE || code[at] === OP_CONT
165
165
  }
166
166
 
167
167
  /**
@@ -266,7 +266,11 @@ function transfer(code: Int32Array, ip: number, at: SiteLabel, hostCst: boolean)
266
266
  }
267
267
 
268
268
  /** A site's label, or `TOP` for anything the walk did not reach. */
269
- export type SiteLabels = { at: (ip: number) => SiteLabel }
269
+ export type SiteLabels = {
270
+ at: (ip: number) => SiteLabel
271
+ /** The `OP_CONT` sites whose corner runs in the parent's collector in every engine. */
272
+ late: ReadonlySet<number>
273
+ }
270
274
 
271
275
  /**
272
276
  * Compute a label for every site reachable from `roots`.
@@ -284,10 +288,11 @@ export function computeSiteLabels(
284
288
  code: Int32Array,
285
289
  roots: Iterable<number>,
286
290
  hostCst: boolean,
291
+ /** Does this assembly run this `OP_CONT` late, in EVERY engine it holds? Absent: none. */
292
+ late?: (ip: number, tri: number) => boolean,
287
293
  ): SiteLabels {
288
294
  const labels = new Map<number, SiteLabel>()
289
295
  const work: number[] = []
290
-
291
296
  const push = (ip: number, l: SiteLabel): void => {
292
297
  const cur = labels.get(ip)
293
298
  if (cur === undefined) {
@@ -300,19 +305,38 @@ export function computeSiteLabels(
300
305
  labels.set(ip, next)
301
306
  work.push(ip)
302
307
  }
303
-
304
- for (const r of roots) push(r, TOP)
305
-
308
+ // A corner a late frame never runs takes no label from that frame. So every frame is
309
+ // late until a site proves undecidable, when its seed's edge joins the same fixpoint: a
310
+ // frame does not change the trivia in force, so no other site's answer moves.
311
+ const opened = new Set<number>()
306
312
  const kids: number[] = []
307
- while (work.length > 0) {
308
- const ip = work.pop()!
309
- const down = transfer(code, ip, labels.get(ip)!, hostCst)
310
- kids.length = 0
311
- childSlots(code, ip, kids)
312
- for (const c of kids) push(c, down)
313
+ const lateIps = new Set<number>()
314
+ for (const r of roots) push(r, TOP)
315
+ for (let pass = 0; pass < 2; pass++) {
316
+ while (work.length > 0) {
317
+ const ip = work.pop()!
318
+ const down = transfer(code, ip, labels.get(ip)!, hostCst)
319
+ kids.length = 0
320
+ if (late === undefined || code[ip] !== OP_SEED || opened.has(ip)) childSlots(code, ip, kids)
321
+ for (const c of kids) push(c, down)
322
+ }
323
+ if (late === undefined || pass === 1) break
324
+ for (const [ip, l] of [...labels]) {
325
+ if (code[ip] !== OP_CONT) continue
326
+ if (late(ip, l.tri)) lateIps.add(ip)
327
+ else {
328
+ const seed = seedOf(code, ip)
329
+ opened.add(seed)
330
+ work.push(seed)
331
+ }
332
+ }
313
333
  }
334
+ return { at: (ip: number): SiteLabel => labels.get(ip) ?? TOP, late: lateIps }
335
+ }
314
336
 
315
- return { at: (ip: number): SiteLabel => labels.get(ip) ?? TOP }
337
+ /** `CONT corner wrapper tail`, `NODE … body`, `SEQ n seed tail`. */
338
+ function seedOf(code: ArrayLike<number>, cont: number): number {
339
+ return code[code[code[cont + 2]! + 2]! + 2]!
316
340
  }
317
341
 
318
342
  /**
package/src/version.ts CHANGED
@@ -13,4 +13,4 @@
13
13
  * Kept in sync with `package.json` by `test/unit/version-sync.test.ts`, which fails
14
14
  * the build if this constant drifts from the published version.
15
15
  */
16
- export const PARSEMAN_VERSION = '0.61.4'
16
+ export const PARSEMAN_VERSION = '0.61.6'