parseman 0.50.7 → 0.51.1

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 (56) hide show
  1. package/dist/analysis/choice-cost.d.ts.map +1 -1
  2. package/dist/analysis/commitment.d.ts.map +1 -1
  3. package/dist/analysis/diagnostics.js +165 -21
  4. package/dist/analysis/diagnostics.js.map +2 -2
  5. package/dist/analysis/duplication.d.ts.map +1 -1
  6. package/dist/analysis/gating.d.ts.map +1 -1
  7. package/dist/cli/index.js +171 -22
  8. package/dist/cli/index.js.map +2 -2
  9. package/dist/combinators/dispatch.d.ts.map +1 -1
  10. package/dist/combinators/scanTo.d.ts +23 -1
  11. package/dist/combinators/scanTo.d.ts.map +1 -1
  12. package/dist/compiler/fields.d.ts.map +1 -1
  13. package/dist/compiler/grammar-coverage-ids.d.ts.map +1 -1
  14. package/dist/compiler/ir-serialize.d.ts.map +1 -1
  15. package/dist/compiler/token-capability.js +2 -2
  16. package/dist/compiler/token-capability.js.map +1 -1
  17. package/dist/coverage.d.ts.map +1 -1
  18. package/dist/cst/reflection.d.ts.map +1 -1
  19. package/dist/index.js +198 -30
  20. package/dist/index.js.map +2 -2
  21. package/dist/plugin/index.js +185 -27
  22. package/dist/plugin/index.js.map +2 -2
  23. package/dist/spec/index.js +127 -12
  24. package/dist/spec/index.js.map +2 -2
  25. package/dist/table/assemble.d.ts.map +1 -1
  26. package/dist/table/emit.d.ts.map +1 -1
  27. package/dist/table/encode.d.ts.map +1 -1
  28. package/dist/table/exec.d.ts.map +1 -1
  29. package/dist/table/index.js +171 -22
  30. package/dist/table/index.js.map +2 -2
  31. package/dist/table/program.d.ts +2 -0
  32. package/dist/table/program.d.ts.map +1 -1
  33. package/dist/types.d.ts +2 -0
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/version.d.ts +1 -1
  36. package/package.json +1 -1
  37. package/src/analysis/choice-cost.ts +6 -1
  38. package/src/analysis/commitment.ts +10 -2
  39. package/src/analysis/duplication.ts +7 -2
  40. package/src/analysis/gating.ts +6 -1
  41. package/src/analysis/rebuild.ts +1 -1
  42. package/src/combinators/dispatch.ts +4 -1
  43. package/src/combinators/scanTo.ts +163 -9
  44. package/src/compiler/fields.ts +8 -2
  45. package/src/compiler/grammar-coverage-ids.ts +6 -1
  46. package/src/compiler/ir-serialize.ts +14 -5
  47. package/src/compiler/token-alphabet.ts +1 -1
  48. package/src/coverage.ts +7 -1
  49. package/src/cst/reflection.ts +6 -1
  50. package/src/table/assemble.ts +11 -1
  51. package/src/table/emit.ts +4 -0
  52. package/src/table/encode.ts +6 -0
  53. package/src/table/exec.ts +7 -1
  54. package/src/table/program.ts +2 -0
  55. package/src/types.ts +1 -1
  56. package/src/version.ts +1 -1
@@ -487,6 +487,8 @@ export function assemble(t: ResolvedTable, prog: TableProgram, cfg: RunCfg): Ass
487
487
  for (const s of prog.scans ?? []) {
488
488
  for (const r of s.skip) labelExtraIps.push(r[0])
489
489
  if (s.sentinel !== undefined) labelExtraIps.push(s.sentinel[0])
490
+ if (s.recoverAt !== undefined) labelExtraIps.push(s.recoverAt[0])
491
+ if (s.stopAt !== undefined) labelExtraIps.push(s.stopAt[0])
490
492
  }
491
493
  for (const set of prog.scanSkip ?? []) for (const r of set) labelExtraIps.push(r[0])
492
494
  const closureLabels = computeSiteLabels(
@@ -3659,6 +3661,8 @@ export function assemble(t: ResolvedTable, prog: TableProgram, cfg: RunCfg): Ass
3659
3661
  for (const s of prog.scans ?? []) {
3660
3662
  for (const r of s.skip) extraIps.push(r[0])
3661
3663
  if (s.sentinel !== undefined) extraIps.push(s.sentinel[0])
3664
+ if (s.recoverAt !== undefined) extraIps.push(s.recoverAt[0])
3665
+ if (s.stopAt !== undefined) extraIps.push(s.stopAt[0])
3662
3666
  }
3663
3667
  for (const set of prog.scanSkip ?? []) for (const r of set) extraIps.push(r[0])
3664
3668
  const roots = [...Object.values(prog.rules), ...extraIps]
@@ -3855,7 +3859,13 @@ export function assemble(t: ResolvedTable, prog: TableProgram, cfg: RunCfg): Ass
3855
3859
  const sentDef: ParserDef | undefined = typeof s.sent === 'string'
3856
3860
  ? { tag: 'literal', value: s.sent, caseInsensitive: false } as unknown as ParserDef
3857
3861
  : undefined
3858
- scansArr.push(scanTo(subtreeComb(s.sentinel!, sentDef), { skip, raw, orEOF: (s.flags & 2) !== 0 }) as Combinator<unknown>)
3862
+ scansArr.push(scanTo(subtreeComb(s.sentinel!, sentDef), {
3863
+ skip,
3864
+ raw,
3865
+ orEOF: (s.flags & 2) !== 0,
3866
+ ...(s.recoverAt === undefined ? {} : { recoverAt: subtreeComb(s.recoverAt) }),
3867
+ ...(s.stopAt === undefined ? {} : { stopAt: subtreeComb(s.stopAt) }),
3868
+ }) as Combinator<unknown>)
3859
3869
  }
3860
3870
  const scans: readonly Combinator<unknown>[] = scansArr
3861
3871
 
package/src/table/emit.ts CHANGED
@@ -104,6 +104,8 @@ function emitRef(r: import('./program.ts').SubtreeRef): string {
104
104
  function emitScanSpec(s: import('./program.ts').ScanSpec): string {
105
105
  const parts = [`kind:${s.kind}`, `flags:${s.flags}`, `skip:[${s.skip.map(emitRef).join(',')}]`]
106
106
  if (s.sentinel !== undefined) parts.push(`sentinel:${emitRef(s.sentinel)}`)
107
+ if (s.recoverAt !== undefined) parts.push(`recoverAt:${emitRef(s.recoverAt)}`)
108
+ if (s.stopAt !== undefined) parts.push(`stopAt:${emitRef(s.stopAt)}`)
107
109
  if (s.sent !== undefined) parts.push(`sent:${s.sent === null ? 'null' : jsString(s.sent)}`)
108
110
  if (s.open !== undefined) parts.push(`open:${jsString(s.open)}`)
109
111
  if (s.close !== undefined) parts.push(`close:${jsString(s.close)}`)
@@ -197,6 +199,8 @@ function emitAssemblies(prog: TableProgram, cfgs: readonly RunCfg[]): string[] {
197
199
  for (const s of prog.scans ?? []) {
198
200
  for (const r of s.skip) extraIps.push(r[0])
199
201
  if (s.sentinel !== undefined) extraIps.push(s.sentinel[0])
202
+ if (s.recoverAt !== undefined) extraIps.push(s.recoverAt[0])
203
+ if (s.stopAt !== undefined) extraIps.push(s.stopAt[0])
200
204
  }
201
205
  for (const set of prog.scanSkip ?? []) for (const r of set) extraIps.push(r[0])
202
206
 
@@ -1005,6 +1005,8 @@ class Encoder {
1005
1005
  flags: (d.raw ? 1 : 0) | (d.orEOF ? 2 : 0),
1006
1006
  skip: d.skip.map(c => this.subtree(c)),
1007
1007
  sentinel: this.subtree(d.sentinel),
1008
+ ...(d.recoverAt === undefined ? {} : { recoverAt: this.subtree(d.recoverAt) }),
1009
+ ...(d.stopAt === undefined ? {} : { stopAt: this.subtree(d.stopAt) }),
1008
1010
  sent: sentDef.tag === 'literal' ? sentDef.value : null,
1009
1011
  }))
1010
1012
  }
@@ -1764,6 +1766,8 @@ class Encoder {
1764
1766
  const refs: SubtreeRef[] = []
1765
1767
  for (const s of this.scans) {
1766
1768
  if (s.sentinel !== undefined) refs.push(s.sentinel)
1769
+ if (s.recoverAt !== undefined) refs.push(s.recoverAt)
1770
+ if (s.stopAt !== undefined) refs.push(s.stopAt)
1767
1771
  refs.push(...s.skip)
1768
1772
  }
1769
1773
  for (const set of this.scanSkipSets) refs.push(...set)
@@ -1784,6 +1788,8 @@ class Encoder {
1784
1788
  ...s,
1785
1789
  skip: s.skip.map(res),
1786
1790
  ...(s.sentinel === undefined ? {} : { sentinel: res(s.sentinel) }),
1791
+ ...(s.recoverAt === undefined ? {} : { recoverAt: res(s.recoverAt) }),
1792
+ ...(s.stopAt === undefined ? {} : { stopAt: res(s.stopAt) }),
1787
1793
  }))
1788
1794
  this.scanSkipSets = this.scanSkipSets.map(set => set.map(res))
1789
1795
  }
package/src/table/exec.ts CHANGED
@@ -1666,7 +1666,13 @@ function makeDriver(
1666
1666
  const sentDef: ParserDef | undefined = typeof s.sent === 'string'
1667
1667
  ? { tag: 'literal', value: s.sent, caseInsensitive: false } as unknown as ParserDef
1668
1668
  : undefined
1669
- return scanTo(subtreeComb(s.sentinel!, sentDef), { skip, raw, orEOF: (s.flags & 2) !== 0 }) as Combinator<unknown>
1669
+ return scanTo(subtreeComb(s.sentinel!, sentDef), {
1670
+ skip,
1671
+ raw,
1672
+ orEOF: (s.flags & 2) !== 0,
1673
+ ...(s.recoverAt === undefined ? {} : { recoverAt: subtreeComb(s.recoverAt) }),
1674
+ ...(s.stopAt === undefined ? {} : { stopAt: subtreeComb(s.stopAt) }),
1675
+ }) as Combinator<unknown>
1670
1676
  })
1671
1677
 
1672
1678
  const scanSkip: readonly (readonly Combinator<unknown>[])[] =
@@ -251,6 +251,8 @@ export type ScanSpec = {
251
251
  readonly flags: number
252
252
  readonly skip: readonly SubtreeRef[]
253
253
  readonly sentinel?: SubtreeRef
254
+ readonly recoverAt?: SubtreeRef
255
+ readonly stopAt?: SubtreeRef
254
256
  readonly sent?: string | null
255
257
  readonly open?: string
256
258
  readonly close?: string
package/src/types.ts CHANGED
@@ -107,7 +107,7 @@ export type ParserDef =
107
107
  // `scanSkip` are PREPENDED at parse/compile time (explicit skip EXTENDS the
108
108
  // ambient default). `raw`: hard opt-out — skip nothing ambiently, restoring the
109
109
  // pre-ambient raw byte-walk.
110
- | { tag: 'scanTo'; sentinel: Combinator<unknown>; skip: Combinator<unknown>[]; raw: boolean; orEOF: boolean }
110
+ | { tag: 'scanTo'; sentinel: Combinator<unknown>; skip: Combinator<unknown>[]; raw: boolean; orEOF: boolean; recoverAt?: Combinator<unknown>; stopAt?: Combinator<unknown> }
111
111
  | { tag: 'keywords'; words: readonly string[]; caseInsensitive: boolean; boundary: string | undefined }
112
112
  | { tag: 'unknown' }
113
113
 
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.50.7'
16
+ export const PARSEMAN_VERSION = '0.51.1'