parseman 0.51.2 → 0.53.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.
- package/dist/analysis/commitment.d.ts.map +1 -1
- package/dist/analysis/diagnostics.js +411 -28
- package/dist/analysis/diagnostics.js.map +3 -3
- package/dist/cli/index.js +6162 -6372
- package/dist/cli/index.js.map +3 -3
- package/dist/combinators/attempt.d.ts +11 -1
- package/dist/combinators/attempt.d.ts.map +1 -1
- package/dist/combinators/map.d.ts.map +1 -1
- package/dist/combinators/node.d.ts +6 -2
- package/dist/combinators/node.d.ts.map +1 -1
- package/dist/combinators/parser.d.ts +34 -0
- package/dist/combinators/parser.d.ts.map +1 -1
- package/dist/combinators/ref.d.ts +0 -13
- package/dist/combinators/ref.d.ts.map +1 -1
- package/dist/compiler/borrowed-rules.d.ts +30 -0
- package/dist/compiler/borrowed-rules.d.ts.map +1 -0
- package/dist/compiler/compile-linkable-table.d.ts +1 -1
- package/dist/compiler/grammar-coverage-ids.d.ts.map +1 -1
- package/dist/compiler/ir-serialize.d.ts +10 -4
- package/dist/compiler/ir-serialize.d.ts.map +1 -1
- package/dist/compiler/linker.d.ts +48 -91
- package/dist/compiler/linker.d.ts.map +1 -1
- package/dist/compiler/token-capability.js +4 -0
- package/dist/compiler/token-capability.js.map +1 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.d.ts.map +1 -1
- package/dist/cst/reflection.d.ts.map +1 -1
- package/dist/cst/trivia-kinds.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +470 -725
- package/dist/index.js.map +3 -3
- package/dist/language-service/index.js.map +1 -1
- package/dist/plugin/evaluator.d.ts +38 -2
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +1127 -544
- package/dist/plugin/index.js.map +3 -3
- package/dist/plugin/ir-eval.d.ts +21 -0
- package/dist/plugin/ir-eval.d.ts.map +1 -0
- package/dist/plugin/reducer-resolver.d.ts +6 -0
- package/dist/plugin/reducer-resolver.d.ts.map +1 -1
- package/dist/spec/index.js +555 -6086
- package/dist/spec/index.js.map +3 -3
- package/dist/spec/railroad-lib.d.ts +7 -2
- package/dist/spec/railroad-lib.d.ts.map +1 -1
- package/dist/spec/railroad.d.ts.map +1 -1
- package/dist/table/assemble.d.ts.map +1 -1
- package/dist/table/compile-rule-map.d.ts +11 -4
- package/dist/table/compile-rule-map.d.ts.map +1 -1
- package/dist/table/compile.d.ts +16 -0
- package/dist/table/compile.d.ts.map +1 -1
- package/dist/table/emit-assembly.d.ts.map +1 -1
- package/dist/table/encode-baseline.d.ts.map +1 -1
- package/dist/table/exec.d.ts.map +1 -1
- package/dist/table/index.js +272 -102
- package/dist/table/index.js.map +2 -2
- package/dist/table/ops.d.ts +7 -5
- package/dist/table/ops.d.ts.map +1 -1
- package/dist/table/site-labels.d.ts.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/analysis/commitment.ts +3 -1
- package/src/analysis/rebuild.ts +1 -1
- package/src/combinators/attempt.ts +26 -3
- package/src/combinators/first-set.ts +5 -1
- package/src/combinators/map.ts +5 -1
- package/src/combinators/node.ts +12 -3
- package/src/combinators/parser.ts +133 -67
- package/src/combinators/ref.ts +10 -1
- package/src/compiler/borrowed-rules.ts +88 -0
- package/src/compiler/compile-linkable-table.ts +1 -1
- package/src/compiler/grammar-coverage-ids.ts +35 -6
- package/src/compiler/ir-serialize.ts +13 -119
- package/src/compiler/linker.ts +190 -666
- package/src/coverage.ts +7 -5
- package/src/cst/reflection.ts +6 -1
- package/src/cst/trivia-kinds.ts +6 -0
- package/src/index.ts +1 -0
- package/src/plugin/evaluator.ts +114 -14
- package/src/plugin/index.ts +588 -110
- package/src/plugin/ir-eval.ts +165 -0
- package/src/plugin/reducer-resolver.ts +20 -3
- package/src/spec/railroad-lib.ts +18 -8
- package/src/spec/railroad.ts +3 -4
- package/src/table/assemble.ts +22 -8
- package/src/table/compile-rule-map.ts +18 -8
- package/src/table/compile.ts +61 -0
- package/src/table/emit-assembly.ts +8 -3
- package/src/table/encode-baseline.ts +5 -1
- package/src/table/encode.ts +13 -13
- package/src/table/exec.ts +6 -2
- package/src/table/ops.ts +7 -5
- package/src/table/site-labels.ts +3 -1
- package/src/types.ts +8 -1
- package/src/version.ts +1 -1
package/src/table/exec.ts
CHANGED
|
@@ -1535,7 +1535,8 @@ function makeDriver(
|
|
|
1535
1535
|
// `attempt()` verbatim: mark, run, and on failure restore every capture
|
|
1536
1536
|
// sink and re-anchor the report at the transaction's entry. A COMMITTED
|
|
1537
1537
|
// failure is still rolled back and then propagated untouched — the
|
|
1538
|
-
// interpreter returns `result` itself on that branch
|
|
1538
|
+
// interpreter returns `result` itself on that branch — unless the row
|
|
1539
|
+
// contains commitment (`k`), where it is reported like any other failure.
|
|
1539
1540
|
const need = rollbackNeeded(ctx)
|
|
1540
1541
|
const mRaw = need ? cstRawLen(ctx) : 0
|
|
1541
1542
|
const mTl = need ? cstTlLen(ctx) : 0
|
|
@@ -1547,7 +1548,10 @@ function makeDriver(
|
|
|
1547
1548
|
const v = exec(code[ip + 1]!, input, pos, ctx)
|
|
1548
1549
|
if (v !== FAIL) return v
|
|
1549
1550
|
if (need) rollbackTriviaAt(ctx, mRaw, mTl, mLv, mFl, mEr, mLog, mRoot)
|
|
1550
|
-
if (ctx._fc === true)
|
|
1551
|
+
if (ctx._fc === true) {
|
|
1552
|
+
if (code[ip + 2] !== 1) return FAIL
|
|
1553
|
+
ctx._fc = false
|
|
1554
|
+
}
|
|
1551
1555
|
ctx._fe = pos
|
|
1552
1556
|
return FAIL
|
|
1553
1557
|
}
|
package/src/table/ops.ts
CHANGED
|
@@ -378,7 +378,9 @@ export const OP_ARMGATE = 36
|
|
|
378
378
|
*/
|
|
379
379
|
export const OP_LIVE = 37
|
|
380
380
|
/**
|
|
381
|
-
* `ATTEMPT c` — `attempt()`, the transactional ordered-choice arm.
|
|
381
|
+
* `ATTEMPT c k` — `attempt()`, the transactional ordered-choice arm. `k` is 1
|
|
382
|
+
* for `attempt(p, { contain: true })`: a committed inner failure is reported
|
|
383
|
+
* uncommitted — `_fc` cleared and `_fe` re-anchored, like any other failure.
|
|
382
384
|
*
|
|
383
385
|
* WAS A TRANSPARENT WRAPPER (`case 'attempt': return this.node(d.parser).ip`),
|
|
384
386
|
* which is correct for exactly one placement — an arm of an `OP_CHOICE`, whose
|
|
@@ -389,10 +391,10 @@ export const OP_LIVE = 37
|
|
|
389
391
|
* re-anchored at the transaction's entry. Both are `attempt()`'s whole contract
|
|
390
392
|
* (`combinators/attempt.ts`), not a choice-arm detail.
|
|
391
393
|
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
* `
|
|
395
|
-
*
|
|
394
|
+
* No expected-set operand: on a non-committed inner failure the row keeps the
|
|
395
|
+
* inner's `_fx` VERBATIM and only re-anchors `_fe` to `pos`, exactly as
|
|
396
|
+
* `attempt.ts` returns `{ expected: result.expected, span: { start: pos, end:
|
|
397
|
+
* pos } }`. A committed failure propagates untouched when `k` is 0 — the
|
|
396
398
|
* rollback still happens, the re-anchor does not.
|
|
397
399
|
*
|
|
398
400
|
* The interpreter's first-set fail-fast guard is NOT lowered. It is an
|
package/src/table/site-labels.ts
CHANGED
|
@@ -159,8 +159,10 @@ function transfer(code: Int32Array, ip: number, at: SiteLabel, hostCst: boolean)
|
|
|
159
159
|
}
|
|
160
160
|
if (op === OP_NODE || op === OP_NODE_TRACK) {
|
|
161
161
|
const flags = code[ip + 3]!
|
|
162
|
+
// The same selection `emit-assembly.ts` makes: the trailing-trivia bit (128)
|
|
163
|
+
// keeps the children-only shape.
|
|
162
164
|
const directChildren = !hostCst && op === OP_NODE && code[ip + 1]! >= 0 && code[ip + 4]! < 0
|
|
163
|
-
&& (flags === 2 || flags === 18 || flags === 34)
|
|
165
|
+
&& ((flags & ~128) === 2 || flags === 18 || flags === 34)
|
|
164
166
|
if (directChildren) {
|
|
165
167
|
// The confirmed low-arity builder projection installs split child/leaf
|
|
166
168
|
// arrays instead of a CstCaptureBuf. Descendants still capture, but they
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { LabeledTriviaSpec } from './cst/trivia-kinds.ts'
|
|
2
|
+
|
|
1
3
|
export type Span = {
|
|
2
4
|
start: number
|
|
3
5
|
end: number
|
|
@@ -56,7 +58,7 @@ export type ParserDef =
|
|
|
56
58
|
// closures live in `gates`.
|
|
57
59
|
| { tag: 'choice'; parsers: Combinator<unknown>[]; gates: (((state: unknown) => boolean) | null)[]; gateSrcs?: (string | null)[]; disjoint: boolean; strategy: ChoiceStrategy; autoNot: (AutoNotCheck[] | null)[] }
|
|
58
60
|
| { tag: 'dispatch'; selector: Combinator<string>; cases: readonly DispatchCase[]; matchers?: readonly DispatchMatcherCase[] | undefined; otherwise?: Combinator<unknown> | undefined; otherwiseUsesRouted?: boolean | undefined }
|
|
59
|
-
| { tag: 'attempt'; parser: Combinator<unknown
|
|
61
|
+
| { tag: 'attempt'; parser: Combinator<unknown>; /** `attempt(p, { contain: true })`: a committed failure inside is reported uncommitted. */ contain?: true }
|
|
60
62
|
// The TAG carries NULLABILITY (what every downstream switch keys on): `many` is
|
|
61
63
|
// the nullable min-0 repeat, `oneOrMore` the non-nullable min>=1 one. `min`/`max`
|
|
62
64
|
// carry the actual ITEM bounds (`many(x, { min: 3, max: 8 })` is a `oneOrMore`
|
|
@@ -433,6 +435,11 @@ export type ParserMeta = {
|
|
|
433
435
|
isTrivia: boolean
|
|
434
436
|
/** User-defined labels for labeled trivia arms (`label(name, parser)`). */
|
|
435
437
|
triviaKindLabels?: readonly string[]
|
|
438
|
+
/**
|
|
439
|
+
* Set only by `trivia()`: the labeled-arm spec of this trivia (`null` when it is
|
|
440
|
+
* not labeled), built once so a labeled scan never re-derives it.
|
|
441
|
+
*/
|
|
442
|
+
labeledTriviaSpec?: LabeledTriviaSpec | null
|
|
436
443
|
/** Preclassified lightweight trivia scanner for the ordinary skip path. */
|
|
437
444
|
triviaScanner?: ((input: string, cur: number) => number) | null
|
|
438
445
|
/** Set only by `classifiedTrivia()`: each root-visible category is a separate
|
package/src/version.ts
CHANGED