parseman 0.59.1 → 0.59.3
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/README.md +5 -4
- package/dist/analysis/commitment.d.ts +1 -1
- package/dist/analysis/diagnostics.js +4 -4
- package/dist/analysis/diagnostics.js.map +1 -1
- package/dist/cli/index.js +4 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/combinators/completions.d.ts +3 -3
- package/dist/combinators/completions.d.ts.map +1 -1
- package/dist/combinators/gate.d.ts +1 -1
- package/dist/compiler/compile-linkable-table.d.ts +2 -3
- package/dist/compiler/compile-linkable-table.d.ts.map +1 -1
- package/dist/compiler/linker.d.ts.map +1 -1
- package/dist/cst/host-mode.d.ts +1 -1
- package/dist/cst/root-trivia-scope.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/language-service/index.d.ts +1 -1
- package/dist/language-service/index.js.map +1 -1
- package/dist/plugin/entry-supercompiler.d.ts.map +1 -1
- package/dist/plugin/index.d.ts +3 -7
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +4 -4
- package/dist/plugin/index.js.map +1 -1
- package/dist/spec/index.js.map +1 -1
- package/dist/table/assemble.d.ts +2 -3
- package/dist/table/assemble.d.ts.map +1 -1
- package/dist/table/compile-rule-map.d.ts +3 -2
- package/dist/table/compile-rule-map.d.ts.map +1 -1
- package/dist/table/compile.d.ts +2 -2
- package/dist/table/emit.d.ts +4 -5
- package/dist/table/emit.d.ts.map +1 -1
- package/dist/table/encode.d.ts +6 -7
- package/dist/table/encode.d.ts.map +1 -1
- package/dist/table/exec.d.ts.map +1 -1
- package/dist/table/index.js +4 -4
- package/dist/table/index.js.map +1 -1
- package/dist/table/ops.d.ts +20 -20
- package/dist/table/ops.d.ts.map +1 -1
- package/dist/table/program.d.ts +7 -7
- package/dist/types.d.ts +1 -1
- package/dist/version.d.ts +6 -6
- package/package.json +1 -1
- package/src/analysis/commitment.ts +1 -1
- package/src/analysis/terminal.ts +1 -1
- package/src/combinators/choice.ts +1 -1
- package/src/combinators/completions.ts +3 -3
- package/src/combinators/gate.ts +1 -1
- package/src/compiler/compile-linkable-table.ts +2 -3
- package/src/compiler/degradation.ts +2 -2
- package/src/compiler/linker.ts +5 -3
- package/src/cst/capture-buffer.ts +2 -2
- package/src/cst/host-mode.ts +1 -1
- package/src/cst/root-trivia-scope.ts +1 -1
- package/src/language-service/index.ts +1 -1
- package/src/plugin/entry-supercompiler.ts +2 -1
- package/src/plugin/index.ts +11 -16
- package/src/table/assemble.ts +9 -10
- package/src/table/compile-rule-map.ts +4 -3
- package/src/table/compile.ts +3 -3
- package/src/table/emit-assembly.ts +4 -4
- package/src/table/emit.ts +13 -14
- package/src/table/encode.ts +14 -15
- package/src/table/exec.ts +4 -5
- package/src/table/ops.ts +20 -20
- package/src/table/program.ts +7 -7
- package/src/table/stamp.ts +1 -1
- package/src/types.ts +1 -1
- package/src/version.ts +6 -6
package/src/table/encode.ts
CHANGED
|
@@ -86,15 +86,14 @@ export type TableSettings = {
|
|
|
86
86
|
* smaller, so the size argument for making it optional no longer holds.
|
|
87
87
|
*
|
|
88
88
|
* LOWERING RECOVERY IS NOT RUNNING IT. Every recovery path stays gated on
|
|
89
|
-
* `ctx._tolerant` — the same dormancy the source lowering
|
|
90
|
-
*
|
|
89
|
+
* `ctx._tolerant` — the same dormancy the source lowering (removed in 0.47.0)
|
|
90
|
+
* had and the interpreter tests (`repeat.ts:163`) — so a strict
|
|
91
91
|
* parse is strict, and `test/parity/table-recovery-always.test.ts` pins that.
|
|
92
92
|
*
|
|
93
|
-
* The field is kept
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* project keeps finding.
|
|
93
|
+
* @deprecated The field is kept only so existing callers still type-check, and
|
|
94
|
+
* is removed in the next minor release. Passing `false` does NOT switch recovery
|
|
95
|
+
* off, and saying so here is the point — a setting that silently means nothing is
|
|
96
|
+
* the defect class this project keeps finding.
|
|
98
97
|
*/
|
|
99
98
|
readonly recovery?: boolean
|
|
100
99
|
/**
|
|
@@ -531,8 +530,8 @@ class Encoder {
|
|
|
531
530
|
/**
|
|
532
531
|
* The class of the follow set of term `i` in a sequence — the sync sentinel a
|
|
533
532
|
* list nested in that term resyncs to, INFERRED from structure exactly as
|
|
534
|
-
* `sequence()` (combinators/sequence.ts:58) and
|
|
535
|
-
*
|
|
533
|
+
* `sequence()` (combinators/sequence.ts:58) and the source
|
|
534
|
+
* lowering's `emitSeqValues` infer it: the union of every LATER term's first
|
|
536
535
|
* set, not merely up to the first non-nullable one, so a mandatory middle term
|
|
537
536
|
* cannot hide a later close. −1 where there is no usable sentinel, which is the
|
|
538
537
|
* same set of cases `firstSetSentinel` answers `null` for.
|
|
@@ -1009,7 +1008,7 @@ class Encoder {
|
|
|
1009
1008
|
}
|
|
1010
1009
|
const patches: number[] = []
|
|
1011
1010
|
this.pending.set(p, patches)
|
|
1012
|
-
// A RULE IS CREDITED ON ENTRY, not on success —
|
|
1011
|
+
// A RULE IS CREDITED ON ENTRY, not on success — the source lowering emitted the
|
|
1013
1012
|
// hook as the first statement of the named function body, so a rule that is
|
|
1014
1013
|
// reached and then fails still counts as exercised. The counter goes on the
|
|
1015
1014
|
// MEMOISED offset, which is the one every reference to this combinator lands
|
|
@@ -1662,7 +1661,7 @@ class Encoder {
|
|
|
1662
1661
|
// A `kinds` LIST IS VALIDATED HERE, at encode time, against the trivia
|
|
1663
1662
|
// table in scope — the same `resolveAdjacencyKindMask` the interpreter
|
|
1664
1663
|
// calls on first reach and codegen calls while emitting the `_akN` probe
|
|
1665
|
-
// (
|
|
1664
|
+
// (in the source lowering). Deferring it to the driver's parse-time resolution
|
|
1666
1665
|
// left `compile()` accepting a grammar whose kind name no active table
|
|
1667
1666
|
// declares: an unlabelled table or a typo'd category compiled clean and
|
|
1668
1667
|
// threw only when an input happened to reach the assertion.
|
|
@@ -1724,7 +1723,7 @@ class Encoder {
|
|
|
1724
1723
|
}
|
|
1725
1724
|
// A LABEL IS A ROW — see `OP_LABEL`. It replaces the child's expected set,
|
|
1726
1725
|
// which is the entire combinator.
|
|
1727
|
-
// A LABEL IS CREDITED ON SUCCESS, as
|
|
1726
|
+
// A LABEL IS CREDITED ON SUCCESS, as the source lowering credited it: its hook
|
|
1728
1727
|
// is emitted AFTER the child's statements, where a failed child has already
|
|
1729
1728
|
// broken out of the labelled block.
|
|
1730
1729
|
case 'label':
|
|
@@ -1782,8 +1781,8 @@ class Encoder {
|
|
|
1782
1781
|
// Bit 1 is the STRICT-SCOPE refusal `grammar.ts:98` raises: with selected
|
|
1783
1782
|
// root trivia active, a local scope whose trivia is not classified and is
|
|
1784
1783
|
// not declared opaque cannot be reported faithfully, so it throws rather
|
|
1785
|
-
// than silently dropping markers.
|
|
1786
|
-
//
|
|
1784
|
+
// than silently dropping markers. The source lowering emitted the
|
|
1785
|
+
// same throw; the table emitted nothing at all.
|
|
1787
1786
|
const flags = (d.rootCapture === 'opaque' ? 1 : 0)
|
|
1788
1787
|
| (d.triviaParser !== undefined
|
|
1789
1788
|
&& d.triviaParser._meta.rootTriviaClassified !== true
|
|
@@ -1938,7 +1937,7 @@ class Encoder {
|
|
|
1938
1937
|
*
|
|
1939
1938
|
* TRACKING IS A WHOLE-TABLE DECISION, as it is a whole-compile decision for the
|
|
1940
1939
|
* source lowering: `ctx.lineTracking` is `opts.trackLines || grammarTrackLines ||
|
|
1941
|
-
* hasLineTrackingDef(combinator)` (
|
|
1940
|
+
* hasLineTrackingDef(combinator)` (the source lowering). The table read the
|
|
1942
1941
|
* SETTING alone and refused any `parser({ trackLines: true }, …)` scope it found
|
|
1943
1942
|
* underneath, so a grammar that carries its own tracking compiled through
|
|
1944
1943
|
* codegen and was rejected by the encoder. Same question, same answer.
|
package/src/table/exec.ts
CHANGED
|
@@ -30,9 +30,8 @@ import { failAt } from '../combinators/probe.ts'
|
|
|
30
30
|
/**
|
|
31
31
|
* THE COMPLETIONS PROBE, at the terminal fail sites and nowhere else.
|
|
32
32
|
*
|
|
33
|
-
* `failAt` (combinators/probe.ts) is called
|
|
34
|
-
*
|
|
35
|
-
* mirror (`probeUpdate`) at the same leaf-fail sites. The table recorded
|
|
33
|
+
* `failAt` (combinators/probe.ts) is called at the interpreter's terminal fail
|
|
34
|
+
* sites — `literal.ts`, `regex.ts`, `keywords.ts`, `lines.ts`. The table recorded
|
|
36
35
|
* NOTHING, so `completionsAt` on a table artifact saw only the top-level
|
|
37
36
|
* failure: a swallowed item failure inside a `sepBy` (`'{'` at offset 1 in a
|
|
38
37
|
* `{ decl; }` grammar) never reached the probe and the item's opener vanished
|
|
@@ -552,7 +551,7 @@ function makeDriver(
|
|
|
552
551
|
const err = { _tag: 'parseError' as const, span, expected: fx[code[ip + 2]!] as string[] }
|
|
553
552
|
ctx._errors?.push(err)
|
|
554
553
|
// A TOLERANT `expect()` also embeds the error in the TREE (expect.ts:150,
|
|
555
|
-
//
|
|
554
|
+
// as the source lowering did), so a tree walk finds every diagnostic and it survives
|
|
556
555
|
// incremental subtree reuse — the flat sink alone is not the contract.
|
|
557
556
|
if (REC && ctx._tolerant === true) captureError(ctx, err)
|
|
558
557
|
// See assemble.ts OP_EXPECT: the recovered failure is a SUCCESS, so the
|
|
@@ -1222,7 +1221,7 @@ function makeDriver(
|
|
|
1222
1221
|
// TOLERANT RECOVERY, dormant unless `ctx._tolerant`. `mySync` is captured
|
|
1223
1222
|
// at ENTRY because an element's own sequence publishes over `_sync` while
|
|
1224
1223
|
// it runs — the interpreter restores in a `finally` (sequence.ts:105) and
|
|
1225
|
-
//
|
|
1224
|
+
// the source lowering saved at entry; either way this is the list's
|
|
1226
1225
|
// own sync. The item's expected set is at ip + 6 and the separator's
|
|
1227
1226
|
// sentinel class at ip + 7, both laid down only for a recovery table.
|
|
1228
1227
|
const mySync = REC ? ctx._sync : undefined
|
package/src/table/ops.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Opcodes for the TABLE lowering (design ledger row G5).
|
|
3
3
|
*
|
|
4
|
-
* The
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* all variants.
|
|
4
|
+
* The source lowering this replaced (removed in 0.47.0) inlined every rule's
|
|
5
|
+
* recognizer into its own emitted function, so an artifact paid for the
|
|
6
|
+
* recognition machinery once PER RULE (measured then: ~4.9 kB for a `node()`
|
|
7
|
+
* rule; ~186 B for each additional call site). As TABLE ROWS run by one shared
|
|
8
|
+
* driver, that machinery lives in the runtime, once for all grammars and all
|
|
9
|
+
* variants.
|
|
11
10
|
*
|
|
12
11
|
* The instruction stream is a flat `number[]`: `code[ip]` is the opcode and the
|
|
13
12
|
* operands follow it inline. Child instructions are referenced by ABSOLUTE code
|
|
14
|
-
* offset, never by nesting
|
|
15
|
-
* objects, no closures, no per-combinator allocation.
|
|
13
|
+
* offset, never by nesting.
|
|
16
14
|
*
|
|
17
|
-
* Operand layouts are documented per opcode below
|
|
18
|
-
* `
|
|
15
|
+
* Operand layouts are documented per opcode below. `encode.ts` writes them; the
|
|
16
|
+
* engines (`assemble.ts`, `emit-assembly.ts`, the reference `exec.ts`) and the
|
|
17
|
+
* table analyses (`child-slots.ts`, `site-labels.ts`, `fail-clean.ts`, …) read
|
|
18
|
+
* them.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
/** `LIT k` — `k` indexes a string in the const pool. */
|
|
21
|
+
/** `LIT k fx` — `k` indexes a string in the const pool; `fx` the expected set on failure. */
|
|
22
22
|
export const OP_LIT = 1
|
|
23
|
-
/** `RX k` — `k` indexes a STICKY `RegExp` in the const pool
|
|
23
|
+
/** `RX k fx` — `k` indexes a STICKY `RegExp` in the const pool; `fx` as `LIT`. */
|
|
24
24
|
export const OP_RX = 2
|
|
25
25
|
/** `SEQ n c1 … cn` — n child offsets; value is the array of their values. */
|
|
26
26
|
export const OP_SEQ = 3
|
|
@@ -80,9 +80,9 @@ export const OP_XFORM = 9
|
|
|
80
80
|
export const OP_NODE = 10
|
|
81
81
|
/** `RULE r` — `r` indexes `prog.rules`. */
|
|
82
82
|
export const OP_RULE = 11
|
|
83
|
-
/** `GATE cc c` — first-char gate: `cc` indexes a char class; then run `c`. */
|
|
83
|
+
/** `GATE cc c fx` — first-char gate: `cc` indexes a char class; then run `c`. `fx` is the set reported when the gate rejects. */
|
|
84
84
|
export const OP_GATE = 12
|
|
85
|
-
/** `NOT c` — zero-width negative lookahead
|
|
85
|
+
/** `NOT c fx` — zero-width negative lookahead; `fx` is the assertion's own set, as `PEEK`. */
|
|
86
86
|
export const OP_NOT = 13
|
|
87
87
|
/**
|
|
88
88
|
* `PEEK c fx` — zero-width positive lookahead. `fx` is the ASSERTION's own set,
|
|
@@ -201,10 +201,10 @@ export const OP_LIT_CI_TRACK = 28
|
|
|
201
201
|
*/
|
|
202
202
|
export const OP_TOKEN = 29
|
|
203
203
|
/**
|
|
204
|
-
* `SCOPE_CAP k c` — a `parser({ trivia, captureTrivia: true })` scope. Identical
|
|
204
|
+
* `SCOPE_CAP k c policy` — a `parser({ trivia, captureTrivia: true })` scope. Identical
|
|
205
205
|
* operands to `SCOPE`; it additionally sets `ctx.captureTrivia` for the child.
|
|
206
206
|
*
|
|
207
|
-
* A SEPARATE OPCODE rather than
|
|
207
|
+
* A SEPARATE OPCODE rather than another operand on `SCOPE`, for two reasons.
|
|
208
208
|
* Widening an instruction means every walker that knows its shape has to learn
|
|
209
209
|
* the new one, and there is no central arity table here to change in one place.
|
|
210
210
|
* And the driver should SELECT this piece, not test a flag inside the scope
|
|
@@ -257,7 +257,7 @@ export const OP_GUARD = 32
|
|
|
257
257
|
* would become a no-op and `notAdjacent()` a guaranteed failure. So the SEQ
|
|
258
258
|
* pieces read this row at assembly and run the test themselves, exactly as
|
|
259
259
|
* `sequence()` forks `parseAdjacent` (combinators/sequence.ts:118) and as
|
|
260
|
-
*
|
|
260
|
+
* the source lowering lowered it at the boundary.
|
|
261
261
|
*
|
|
262
262
|
* Reached as a row in its own right only where there IS no boundary — a bare
|
|
263
263
|
* choice arm, a `node()` body, a repeat item. The interpreter throws there
|
|
@@ -367,7 +367,7 @@ export const OP_ARMGATE = 36
|
|
|
367
367
|
* library never sees.
|
|
368
368
|
*
|
|
369
369
|
* It exists because codegen accepts exactly this and delegates at run time
|
|
370
|
-
* (
|
|
370
|
+
* (the source lowering's `emitRuntimeFallback`). The
|
|
371
371
|
* encoder used to throw `UnsupportedConstruct`, so the table lowering REJECTED
|
|
372
372
|
* grammars the source lowering compiles, and the two lowerings must accept the
|
|
373
373
|
* same language.
|
|
@@ -436,7 +436,7 @@ export const OP_LABEL = 39
|
|
|
436
436
|
* `on` is 0 for ENTRY and 1 for SUCCESS, and it is read at ASSEMBLY TIME, never
|
|
437
437
|
* per parse: `assemble.ts` picks one of two closures from it, exactly as it picks
|
|
438
438
|
* pieces from `RunCfg`. The two phases are not decoration — the source lowering
|
|
439
|
-
*
|
|
439
|
+
* credited a RULE on entry and a choice arm, dispatch arm or
|
|
440
440
|
* label only once it has SUCCEEDED, and a table that credited all four alike
|
|
441
441
|
* would report a different denominator's worth of hits than the engine it is a
|
|
442
442
|
* drop-in for.
|
package/src/table/program.ts
CHANGED
|
@@ -29,10 +29,10 @@ export type PrecompiledAssembly = {
|
|
|
29
29
|
/**
|
|
30
30
|
* The emitted form of a grammar under the table lowering.
|
|
31
31
|
*
|
|
32
|
-
* This object is ALL a grammar contributes to a bundle
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* function.
|
|
32
|
+
* This object is ALL a grammar contributes to a bundle, apart from any
|
|
33
|
+
* build-time assemblies in `asm`. The recognition logic is the shared driver
|
|
34
|
+
* (`tableRules`, `assemble.ts`), which ships once in the runtime for every
|
|
35
|
+
* grammar and every variant. A rule costs its row, not a function.
|
|
36
36
|
*
|
|
37
37
|
* Serialized shape is deliberately JSON-ish (numbers, strings, and a pool of
|
|
38
38
|
* author callbacks) so the emitter can print it as a literal.
|
|
@@ -145,9 +145,9 @@ export type TableProgram = {
|
|
|
145
145
|
*/
|
|
146
146
|
readonly triviaSpecs?: readonly TriviaSpec[]
|
|
147
147
|
/**
|
|
148
|
-
* 1
|
|
149
|
-
*
|
|
150
|
-
*
|
|
148
|
+
* Always 1: every table carries recovery operands — the sequences their inferred
|
|
149
|
+
* follow-set classes, the repetitions their item expected set and separator
|
|
150
|
+
* sentinel class. (`TableSettings.recovery` is a deprecated no-op.)
|
|
151
151
|
*
|
|
152
152
|
* TABLE DATA, read once when the driver/assembly is built. It selects the
|
|
153
153
|
* recovery pieces; it is not a per-parse option, and a recovery table still
|
package/src/table/stamp.ts
CHANGED
|
@@ -173,7 +173,7 @@ export function stampRuleMap(
|
|
|
173
173
|
// `committed` IS PART OF THE FAILURE ENVELOPE, not a diagnostic extra.
|
|
174
174
|
// The interpreter carries it on the result (`{ ok: false, …, committed: true }`)
|
|
175
175
|
// and codegen re-derives it from the same bit this driver uses
|
|
176
|
-
// (
|
|
176
|
+
// (`...(_ctx._fc ? { committed: true } : {})`). The table
|
|
177
177
|
// dropped it, so a table entry embedded as a CHILD of another parser — the
|
|
178
178
|
// one place the field is read rather than merely reported — lost the cut.
|
|
179
179
|
return committed(ctx)
|
package/src/types.ts
CHANGED
|
@@ -569,7 +569,7 @@ export type GatedArm<T = unknown> = {
|
|
|
569
569
|
* This lives with the rest of the library's types rather than inside a lowering
|
|
570
570
|
* because it is the shape BOTH lowerings answer to: `table/compile.ts` returns it
|
|
571
571
|
* today and is what `src/index.ts` exports as `compile`. It started in
|
|
572
|
-
*
|
|
572
|
+
* the source lowering, which made the table import its own public contract from
|
|
573
573
|
* the engine the table replaced — backwards, and a reason the engine could not be
|
|
574
574
|
* deleted.
|
|
575
575
|
*/
|
package/src/version.ts
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*
|
|
5
5
|
* ── ARTIFACTS ARE VERSION-LOCKED ────────────────────────────────────────────────
|
|
6
6
|
* A grammar is compiled AND fused/linked by the SAME parseman version. Parseman does
|
|
7
|
-
* NOT read a compiled artifact produced by a different version. The
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* NOT read a compiled artifact produced by a different version. The artifact formats
|
|
8
|
+
* (the table program, `LinkableTable`, carried IR) may therefore change freely between
|
|
9
|
+
* versions and carry NO back-compat shim and no "legacy format" read path. If you find
|
|
10
|
+
* yourself adding one, STOP — it is dead code. The stamp is written but not yet checked
|
|
11
|
+
* on read (#186).
|
|
12
12
|
*
|
|
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.59.
|
|
16
|
+
export const PARSEMAN_VERSION = '0.59.3'
|