parseman 0.58.0 → 0.58.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.
package/dist/version.d.ts CHANGED
@@ -13,5 +13,5 @@
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 declare const PARSEMAN_VERSION = "0.58.0";
16
+ export declare const PARSEMAN_VERSION = "0.58.1";
17
17
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "parseman",
3
- "version": "0.58.0",
3
+ "version": "0.58.1",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "engines": {
6
6
  "node": "^20.19.0 || >=22.13.0"
package/src/run/index.ts CHANGED
@@ -25,6 +25,11 @@
25
25
  * const result = run(myGrammar, source, { trivia })
26
26
  */
27
27
  export { buildRootTriviaIndex } from '../cst/trivia-entries.ts'
28
+ // Line/column lookup for the spans and errors `run()` returns. `line-index.ts` is
29
+ // already in the driver's closure (recovery annotates errors with it), so exposing
30
+ // it here costs no module — a caller reporting positions need not import the main entry.
31
+ export { buildLineIndex, offsetToLineCol } from '../line-index.ts'
32
+ export type { LineIndex } from '../line-index.ts'
28
33
  export { run } from '../functional/run.ts'
29
34
  export type { RootTriviaCapture, Runnable, RunOptions, RunResult } from '../functional/run.ts'
30
35
  export type { RootTriviaGap, RootTriviaIndex, TriviaEntriesView } from '../cst/trivia-entries.ts'
@@ -983,17 +983,20 @@ class Encoder {
983
983
  const rr = this.refResolver()
984
984
  const { next, boundary } = follow
985
985
  if (matchesEmpty(next, new Set(), rr) || mayCommitFailure(next, rr, this.commitFailureMemo)) return undefined
986
- // A miss reports `deriveExpected(next)`, a static set. Only a terminal or a
987
- // label fails with exactly that set: a sequence over an `optional` prefix
988
- // reports the prefix's labels statically but not when it runs, and a choice
989
- // whose arms share an opener reports that opener once statically, once per
990
- // arm when it runs.
991
- const nextTag = (next._def as ParserDef).tag
992
- if (nextTag !== 'literal' && nextTag !== 'regex' && nextTag !== 'keywords' && nextTag !== 'label') return undefined
986
+ // A miss reports the set `next` fails with at its start, so only a row with
987
+ // one such set is gated: a terminal, which fails with its own spelling
988
+ // (`directTerminalFailureExpected` — `keywords()` and `word()` say `keyword`,
989
+ // not each word as `deriveExpected` lists them), or a label, which fails with
990
+ // its name. A sequence over an `optional` prefix reports the prefix's labels
991
+ // statically but not when it runs, and a choice whose arms share an opener
992
+ // reports that opener once statically, once per arm when it runs.
993
+ const nextDef = next._def as ParserDef
994
+ if (nextDef.tag !== 'literal' && nextDef.tag !== 'regex' && nextDef.tag !== 'keywords' && nextDef.tag !== 'label') return undefined
993
995
  const first = firstSetOf(next, new Set(), rr, boundary)
994
996
  const cls = this.charClass(boundary === undefined ? first : union(first, firstSetOf(boundary, new Set(), rr)))
995
997
  if (cls < 0) return undefined
996
- return { cls, fx: this.expected(deriveExpected(next)) }
998
+ const miss = nextDef.tag === 'label' ? deriveExpected(next) : directTerminalFailureExpected(nextDef)
999
+ return { cls, fx: this.expected(miss) }
997
1000
  }
998
1001
 
999
1002
  node(p: Combinator<unknown>): Emitted {
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.58.0'
16
+ export const PARSEMAN_VERSION = '0.58.1'