parseman 0.59.2 → 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/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 +14 -14
- 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 +14 -14
- 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/dist/table/ops.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
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
|
/** `LIT k fx` — `k` indexes a string in the const pool; `fx` the expected set on failure. */
|
|
21
21
|
export declare const OP_LIT = 1;
|
|
@@ -256,7 +256,7 @@ export declare const OP_GUARD = 32;
|
|
|
256
256
|
* would become a no-op and `notAdjacent()` a guaranteed failure. So the SEQ
|
|
257
257
|
* pieces read this row at assembly and run the test themselves, exactly as
|
|
258
258
|
* `sequence()` forks `parseAdjacent` (combinators/sequence.ts:118) and as
|
|
259
|
-
*
|
|
259
|
+
* the source lowering lowered it at the boundary.
|
|
260
260
|
*
|
|
261
261
|
* Reached as a row in its own right only where there IS no boundary — a bare
|
|
262
262
|
* choice arm, a `node()` body, a repeat item. The interpreter throws there
|
|
@@ -366,7 +366,7 @@ export declare const OP_ARMGATE = 36;
|
|
|
366
366
|
* library never sees.
|
|
367
367
|
*
|
|
368
368
|
* It exists because codegen accepts exactly this and delegates at run time
|
|
369
|
-
* (
|
|
369
|
+
* (the source lowering's `emitRuntimeFallback`). The
|
|
370
370
|
* encoder used to throw `UnsupportedConstruct`, so the table lowering REJECTED
|
|
371
371
|
* grammars the source lowering compiles, and the two lowerings must accept the
|
|
372
372
|
* same language.
|
|
@@ -435,7 +435,7 @@ export declare const OP_LABEL = 39;
|
|
|
435
435
|
* `on` is 0 for ENTRY and 1 for SUCCESS, and it is read at ASSEMBLY TIME, never
|
|
436
436
|
* per parse: `assemble.ts` picks one of two closures from it, exactly as it picks
|
|
437
437
|
* pieces from `RunCfg`. The two phases are not decoration — the source lowering
|
|
438
|
-
*
|
|
438
|
+
* credited a RULE on entry and a choice arm, dispatch arm or
|
|
439
439
|
* label only once it has SUCCEEDED, and a table that credited all four alike
|
|
440
440
|
* would report a different denominator's worth of hits than the engine it is a
|
|
441
441
|
* drop-in for.
|
package/dist/table/program.d.ts
CHANGED
|
@@ -22,10 +22,10 @@ export type PrecompiledAssembly = {
|
|
|
22
22
|
/**
|
|
23
23
|
* The emitted form of a grammar under the table lowering.
|
|
24
24
|
*
|
|
25
|
-
* This object is ALL a grammar contributes to a bundle
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* function.
|
|
25
|
+
* This object is ALL a grammar contributes to a bundle, apart from any
|
|
26
|
+
* build-time assemblies in `asm`. The recognition logic is the shared driver
|
|
27
|
+
* (`tableRules`, `assemble.ts`), which ships once in the runtime for every
|
|
28
|
+
* grammar and every variant. A rule costs its row, not a function.
|
|
29
29
|
*
|
|
30
30
|
* Serialized shape is deliberately JSON-ish (numbers, strings, and a pool of
|
|
31
31
|
* author callbacks) so the emitter can print it as a literal.
|
|
@@ -138,9 +138,9 @@ export type TableProgram = {
|
|
|
138
138
|
*/
|
|
139
139
|
readonly triviaSpecs?: readonly TriviaSpec[];
|
|
140
140
|
/**
|
|
141
|
-
* 1
|
|
142
|
-
*
|
|
143
|
-
*
|
|
141
|
+
* Always 1: every table carries recovery operands — the sequences their inferred
|
|
142
|
+
* follow-set classes, the repetitions their item expected set and separator
|
|
143
|
+
* sentinel class. (`TableSettings.recovery` is a deprecated no-op.)
|
|
144
144
|
*
|
|
145
145
|
* TABLE DATA, read once when the driver/assembly is built. It selects the
|
|
146
146
|
* recovery pieces; it is not a per-parse option, and a recovery table still
|
package/dist/types.d.ts
CHANGED
|
@@ -670,7 +670,7 @@ export type GatedArm<T = unknown> = {
|
|
|
670
670
|
* This lives with the rest of the library's types rather than inside a lowering
|
|
671
671
|
* because it is the shape BOTH lowerings answer to: `table/compile.ts` returns it
|
|
672
672
|
* today and is what `src/index.ts` exports as `compile`. It started in
|
|
673
|
-
*
|
|
673
|
+
* the source lowering, which made the table import its own public contract from
|
|
674
674
|
* the engine the table replaced — backwards, and a reason the engine could not be
|
|
675
675
|
* deleted.
|
|
676
676
|
*/
|
package/dist/version.d.ts
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
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 declare const PARSEMAN_VERSION = "0.59.
|
|
16
|
+
export declare const PARSEMAN_VERSION = "0.59.3";
|
|
17
17
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -404,7 +404,7 @@ export function hasNodeDef(p: Combinator<unknown>, seen: Set<Combinator<unknown>
|
|
|
404
404
|
*
|
|
405
405
|
* It belongs in THIS module for the reason stated at the top of it: both lowerings
|
|
406
406
|
* must reach the same answer, and a stamp they disagree about is a driver that
|
|
407
|
-
* accepts a host it should refuse. It previously lived in
|
|
407
|
+
* accepts a host it should refuse. It previously lived in the source lowering,
|
|
408
408
|
* which forced `table/compile-rule-map.ts` to import the engine the table replaced.
|
|
409
409
|
*
|
|
410
410
|
* The descent mirrors the source lowering's own `childrenOf` exactly — including a
|
package/src/analysis/terminal.ts
CHANGED
|
@@ -252,7 +252,7 @@ export function render(lines: readonly Line[], target: RenderTarget = {}): strin
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
// linecraft's own escapes, for the one component whose plain form is not otherwise
|
|
255
|
-
// reachable.
|
|
255
|
+
// reachable. Built from a char code
|
|
256
256
|
// so the ESC byte cannot be lost in transit the way the old constant table's was.
|
|
257
257
|
const ESC = String.fromCharCode(27)
|
|
258
258
|
const OSC8 = new RegExp(`${ESC}\\]8;;.*?${ESC}\\\\`, 'g')
|
|
@@ -314,7 +314,7 @@ function bareLeadingTermKey(term: Combinator<unknown>): string | null {
|
|
|
314
314
|
//
|
|
315
315
|
// A `lazy` ref lead — excluded for correctness, not for want of a key. The
|
|
316
316
|
// once-only prescan runs with `ctx.capturing = false`, which suppresses capture
|
|
317
|
-
// only for code emitted HERE (emitLeafCapture
|
|
317
|
+
// only for code emitted HERE (the source lowering's emitLeafCapture). A ref compiles to a
|
|
318
318
|
// call into a function body generated under its OWN ctx (emitLazy), so its
|
|
319
319
|
// captures and trivia writes would happen during the prescan and then AGAIN in
|
|
320
320
|
// each arm. Replaying a ref needs recorded-and-spliced capture state, not the
|
|
@@ -3,8 +3,8 @@ import { REC } from '../recovery/scan.ts'
|
|
|
3
3
|
import { createParseContext } from '../parse-context.ts'
|
|
4
4
|
|
|
5
5
|
/** Anything `completionsAt` can probe: an interpreter combinator OR a `compile()`d
|
|
6
|
-
* grammar
|
|
7
|
-
*
|
|
6
|
+
* grammar, which records the probe on its fast path. A macro-built rule function has
|
|
7
|
+
* neither `parse` nor `parseWithContext`, so it is not accepted. */
|
|
8
8
|
type CompletionsTarget =
|
|
9
9
|
| Combinator<unknown>
|
|
10
10
|
| { parseWithContext(input: string, ctx: ParseContext, pos?: number): ParseResult<unknown> }
|
|
@@ -17,7 +17,7 @@ type CompletionsTarget =
|
|
|
17
17
|
* highest-position failure seen, even when sepBy/many backtrack past the cursor.
|
|
18
18
|
* Returns the expected tokens from that deepest failure.
|
|
19
19
|
*
|
|
20
|
-
* Works on the interpreter combinator OR a `compile(
|
|
20
|
+
* Works on the interpreter combinator OR a `compile()`d grammar
|
|
21
21
|
* (the probe is recorded on the compiled fast path). Returns an empty array when the
|
|
22
22
|
* input up to `offset` parses completely with no failures at or before the cursor.
|
|
23
23
|
*
|
package/src/combinators/gate.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type { Combinator, ParseContext, ParseResult, ParserMeta } from '../types
|
|
|
15
15
|
* Naming: this matches the `gate:` field on a gated CHOICE arm
|
|
16
16
|
* (`choice({ gate, combinator }, other)`). Use the arm FIELD to SELECT a branch by
|
|
17
17
|
* a cheap state predicate; use this COMBINATOR to ASSERT a state predicate
|
|
18
|
-
* mid-sequence. Formerly named `guard()
|
|
18
|
+
* mid-sequence. Formerly named `guard()`; that alias was removed in 0.45.0.
|
|
19
19
|
*
|
|
20
20
|
* Note: like all state predicates its first-set is `any`, so a `gate(...)` as the
|
|
21
21
|
* LEADING term of a choice arm poisons that choice's first-char dispatch. Keep it
|
|
@@ -29,9 +29,8 @@ import { PARSEMAN_VERSION } from '../version.ts'
|
|
|
29
29
|
* artifact is a table, not a bag of compiled functions.
|
|
30
30
|
* `ir` — the piece's combinator graph, serialized. This is the
|
|
31
31
|
* composable half, and it is NOT new machinery: the plugin
|
|
32
|
-
* already carries pieces as IR (`plugin/index.ts
|
|
33
|
-
*
|
|
34
|
-
* `compileLinkable(evalRuleMapIR(p.ir), …)` at build time).
|
|
32
|
+
* already carries pieces as IR (`plugin/index.ts`) and the
|
|
33
|
+
* macro re-lowers them from it at build time.
|
|
35
34
|
*
|
|
36
35
|
* ── WHY THAT MAKES COMPOSITION THE EASY KIND ─────────────────────────────────
|
|
37
36
|
* The open question was whether table-to-table composition has to merge two
|
|
@@ -93,8 +93,8 @@ export function formatDegradations(list: readonly Degradation[]): string[] {
|
|
|
93
93
|
//
|
|
94
94
|
// Compilation is single-module and synchronous, so a module-level sink (opened per
|
|
95
95
|
// transform, drained after) records findings without threading a field through every
|
|
96
|
-
// Ctx and every compile*() return — the same shape as the regex-lowering
|
|
97
|
-
//
|
|
96
|
+
// Ctx and every compile*() return — the same shape as the source lowering's regex-lowering
|
|
97
|
+
// sink, for the same reason.
|
|
98
98
|
// ---------------------------------------------------------------------------
|
|
99
99
|
//
|
|
100
100
|
// A STACK, not a single slot. `transformMacro` re-enters itself when it lowers a private
|
package/src/compiler/linker.ts
CHANGED
|
@@ -25,9 +25,11 @@ import { copySpan } from '../line-index.ts'
|
|
|
25
25
|
/**
|
|
26
26
|
* Compile a `rules()` map to a **linkable artifact** — the composable, shippable
|
|
27
27
|
* form (RULE_ABI_PLAN §4). A package exports `linkable(rules(g => …))`; consumers
|
|
28
|
-
* import that artifact and `
|
|
29
|
-
* ever read**. Under the macro this is precompiled to static pieces
|
|
30
|
-
* interpreter it compiles here at load
|
|
28
|
+
* import that artifact and `compose([...])` it — **no source of the base grammar is
|
|
29
|
+
* ever read**. Under the macro this is precompiled to static pieces, and only a
|
|
30
|
+
* build-time `compose()` can link it. In the interpreter it compiles here at load
|
|
31
|
+
* (like `compile()`) and keeps the map's `RULES_RECIPE`, which is what a runtime
|
|
32
|
+
* `compose()` links; an artifact without one is refused there (`recipesOf`).
|
|
31
33
|
*
|
|
32
34
|
* `ns` is a per-artifact namespace; omit it to auto-assign a process-unique one
|
|
33
35
|
* (fine at runtime — the macro supplies a stable module-derived ns instead).
|
|
@@ -270,8 +270,8 @@ export function rollbackCstCaptureAt(
|
|
|
270
270
|
// speculative branch leaves no ghost error (see saveCstMark). Guarded on a
|
|
271
271
|
// present sink + a defined mark (rollbackTrivia forwards the same field).
|
|
272
272
|
//
|
|
273
|
-
// Each truncation is guarded on `length !== mark`,
|
|
274
|
-
//
|
|
273
|
+
// Each truncation is guarded on `length !== mark`, as the source lowering's
|
|
274
|
+
// `captureRestoreBody` did. Assigning `array.length` runs V8's
|
|
275
275
|
// length setter — a backing-store trim decision — and costs the same when the
|
|
276
276
|
// value is unchanged, which is the overwhelmingly common case here: a
|
|
277
277
|
// speculative branch that captured nothing still pays for every store. The
|
package/src/cst/host-mode.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The compiled-artifact ↔ host contract, in ONE place.
|
|
3
3
|
*
|
|
4
|
-
* This lives on its own — rather than in
|
|
4
|
+
* This lives on its own — rather than in the source lowering where it started —
|
|
5
5
|
* because the DRIVER has to enforce it too. `functional/run.ts` is the `parseman/run`
|
|
6
6
|
* entry, whose whole purpose is to stay small (see `test/unit/run-entry-closure.test.ts`),
|
|
7
7
|
* so it cannot import the compiler to reach an assertion. Neither can it carry its own
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The ROOT-CAPTURE POLICY of one local trivia scope, in one place.
|
|
3
3
|
*
|
|
4
4
|
* Three engines install a `parser({ trivia })` scope — the interpreter
|
|
5
|
-
* (`combinators/grammar.ts`), source lowering (
|
|
5
|
+
* (`combinators/grammar.ts`), the source lowering (removed in 0.47.0) and the
|
|
6
6
|
* table (`table/assemble.ts`, `table/exec.ts`) — and each of them has to answer
|
|
7
7
|
* the same two questions about selected root trivia. The refusal below was a
|
|
8
8
|
* string literal in two of them and ABSENT from the third, which is how a table
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* name = node type, without ever modifying the grammar:
|
|
7
7
|
*
|
|
8
8
|
* - `parse(src, { tolerant })` → CST + `ParseError[]` (recovers on the compiled
|
|
9
|
-
* fast path when `grammar` is a `compile(
|
|
9
|
+
* fast path when `grammar` is a `compile()`d grammar).
|
|
10
10
|
* - `diagnostics(src)` → structural parse errors + your per-node-type lint rules.
|
|
11
11
|
* - `completionsAt(src, offset)` → the grammar's expected-token set at the cursor,
|
|
12
12
|
* mapped through your per-rule semantic completion handlers.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Build-time Entry/SCC supercompiler for the selective assemblies a macro build
|
|
3
|
+
* emits (it runs on every macro build that selects sites).
|
|
3
4
|
*
|
|
4
5
|
* The table emitter remains the sole semantic backend. This pass parses that
|
|
5
6
|
* backend's ordinary JavaScript and joins uniquely-owned piece functions with
|
package/src/plugin/index.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* For each such import, walks the file's AST, finds variable declarations
|
|
7
7
|
* whose RHS is a pure parseman combinator call, evaluates them at build time,
|
|
8
|
-
* compiles the result to
|
|
9
|
-
*
|
|
8
|
+
* compiles the result to a table program (plus generated code for its hottest
|
|
9
|
+
* sites, within `assemblyBudget`), and replaces the declaration. The macro import
|
|
10
|
+
* is removed; the module imports the shared driver from `parseman/table` instead.
|
|
10
11
|
*
|
|
11
12
|
* Usage:
|
|
12
13
|
* // vite.config.ts
|
|
@@ -61,7 +62,7 @@ import type {
|
|
|
61
62
|
* The PUBLIC subpath, not a deep path into `src/`: this string is written into a
|
|
62
63
|
* consumer's build output, so it has to be a specifier their resolver can see.
|
|
63
64
|
* `parseman/table` is declared in package.json `exports` and re-exports
|
|
64
|
-
* `tableRules`
|
|
65
|
+
* `tableRules` unrenamed (`src/table/index.ts`).
|
|
65
66
|
*/
|
|
66
67
|
const TABLE_RUNTIME_SPECIFIER = 'parseman/table'
|
|
67
68
|
|
|
@@ -119,13 +120,9 @@ export type ParsecraftPluginOptions = {
|
|
|
119
120
|
*/
|
|
120
121
|
warnUnloweredRegex?: boolean
|
|
121
122
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
* parse is unaffected and allocates nothing). The output stays macro-inlinable
|
|
126
|
-
* (sentinels build via `_ctx._rec`, not `_rp`). Turn it on for grammars you drive
|
|
127
|
-
* from an editor/language service so `run(g, src, { tolerant: true })` recovers on
|
|
128
|
-
* the fast compiled path; leave it off for build-only grammars.
|
|
123
|
+
* @deprecated Has no effect: every compiled table carries recovery, and
|
|
124
|
+
* `run(g, src, { tolerant: true })` recovers on the compiled path whatever this is
|
|
125
|
+
* set to. Removed in the next minor release.
|
|
129
126
|
*/
|
|
130
127
|
recovery?: boolean
|
|
131
128
|
/** Emit grammar-coverage hooks in macro output. Off by default, so ordinary
|
|
@@ -1456,9 +1453,8 @@ function transformMacroImpl(
|
|
|
1456
1453
|
|
|
1457
1454
|
/**
|
|
1458
1455
|
* Compile a `rules(factory)` call into ONE shared replacement expression
|
|
1459
|
-
* for the whole call
|
|
1460
|
-
*
|
|
1461
|
-
* factory's entries commonly share large reachable sub-rule graphs; a
|
|
1456
|
+
* for the whole call: one shared `compileRuleMap()` pass instead of one
|
|
1457
|
+
* `compile()` per entry (a `rules()` factory's entries commonly share large reachable sub-rule graphs; a
|
|
1462
1458
|
* shared pass compiles each shared sub-rule once instead of once per entry
|
|
1463
1459
|
* that reaches it).
|
|
1464
1460
|
*/
|
|
@@ -1977,9 +1973,8 @@ function transformMacroImpl(
|
|
|
1977
1973
|
* shadows the base piece which actually defines `Pair` — the encoder then finds a
|
|
1978
1974
|
* hole where the winner should be and refuses the whole grammar with "ref() used
|
|
1979
1975
|
* before .define()". The same filter guards `compileLinkableTable`'s `isLocal`
|
|
1980
|
-
* (`compile-linkable-table.ts
|
|
1981
|
-
*
|
|
1982
|
-
* reason, and skipping it is why cross-piece composition looked blocked.
|
|
1976
|
+
* (`compile-linkable-table.ts`) and `recoverComposedRules`; this site needs it
|
|
1977
|
+
* for the same reason, and skipping it is why cross-piece composition looked blocked.
|
|
1983
1978
|
*
|
|
1984
1979
|
* The reference itself is not lost: it stays inside the delta's own rule bodies and
|
|
1985
1980
|
* `enc.winners` binds it BY NAME to whichever piece supplies the definition.
|
package/src/table/assemble.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This is ledger row G5 as stated: *"build the grammar reference at run start,
|
|
5
5
|
* making the swaps on rules / sub-rules (leaves) at that point, then run with NO
|
|
6
6
|
* logic branching for that option input"*. `exec.ts` builds the same table and
|
|
7
|
-
* then interprets it: one `switch (code[ip])` over 29
|
|
7
|
+
* then interprets it: one `switch (code[ip])` over every opcode (29 then), executed ONCE PER
|
|
8
8
|
* ROW — 497,360 rows for `benchmark.less` (`bench/jess/g5-rows.ts`) — each
|
|
9
9
|
* re-reading its opcode and re-decoding its operands from the `Int32Array`, and
|
|
10
10
|
* re-testing the same per-parse options. That is the per-node branching the
|
|
@@ -114,9 +114,8 @@ import { failCleanAnalysis } from './fail-clean.ts'
|
|
|
114
114
|
/**
|
|
115
115
|
* THE COMPLETIONS PROBE, at the terminal fail sites and nowhere else.
|
|
116
116
|
*
|
|
117
|
-
* `failAt` (combinators/probe.ts) is called
|
|
118
|
-
*
|
|
119
|
-
* mirror (`probeUpdate`) at the same leaf-fail sites. The table recorded
|
|
117
|
+
* `failAt` (combinators/probe.ts) is called at the interpreter's terminal fail
|
|
118
|
+
* sites — `literal.ts`, `regex.ts`, `keywords.ts`, `lines.ts`. The table recorded
|
|
120
119
|
* NOTHING, so `completionsAt` on a table artifact saw only the top-level
|
|
121
120
|
* failure: a swallowed item failure inside a `sepBy` (`'{'` at offset 1 in a
|
|
122
121
|
* `{ decl; }` grammar) never reached the probe and the item's opener vanished
|
|
@@ -438,7 +437,7 @@ export function assemble(t: ResolvedTable, prog: TableProgram, cfg: RunCfg): Ass
|
|
|
438
437
|
* graph with no recovery in it anywhere.
|
|
439
438
|
*
|
|
440
439
|
* Dormancy is unchanged for the OTHER two engines: the source lowering
|
|
441
|
-
* (
|
|
440
|
+
* (removed in 0.47.0) and the interpreter (`repeat.ts:163`) still gate on
|
|
442
441
|
* `ctx._tolerant` at runtime, and the recovery pieces below keep their own
|
|
443
442
|
* `_tolerant === true` failure-path gates so `exec.ts` stays the identity
|
|
444
443
|
* reference.
|
|
@@ -1914,8 +1913,8 @@ export function assemble(t: ResolvedTable, prog: TableProgram, cfg: RunCfg): Ass
|
|
|
1914
1913
|
const expectSpan = (ctx: ParseContext, pos: number) =>
|
|
1915
1914
|
prog.lines === 1 ? spanLines(ctx, pos, pos) : new PlainSpan(pos, pos)
|
|
1916
1915
|
// TOLERANT `expect()` EMBEDS ITS ERROR IN THE TREE, not only in the flat
|
|
1917
|
-
// `_errors` side-channel (`combinators/expect.ts:150`, and
|
|
1918
|
-
// `_ctx._rec.capture`
|
|
1916
|
+
// `_errors` side-channel (`combinators/expect.ts:150`, and the source
|
|
1917
|
+
// lowering's `_ctx._rec.capture`) — so a tree walk finds every
|
|
1919
1918
|
// diagnostic and the node survives incremental subtree reuse. The table
|
|
1920
1919
|
// pushed to `_errors` and stopped, so a tolerant CST parse was missing the
|
|
1921
1920
|
// `parseError` child the other two engines both produce.
|
|
@@ -2536,7 +2535,7 @@ export function assemble(t: ResolvedTable, prog: TableProgram, cfg: RunCfg): Ass
|
|
|
2536
2535
|
*
|
|
2537
2536
|
* The restore is `sequence()`'s `finally` (combinators/sequence.ts:105).
|
|
2538
2537
|
* Codegen does not restore and compensates by having every list capture
|
|
2539
|
-
* `_sync` at ENTRY
|
|
2538
|
+
* `_sync` at ENTRY; the table captures at entry too, so
|
|
2540
2539
|
* this is unobservable either way — it is here because leaving a stale
|
|
2541
2540
|
* sentinel published is the kind of state a later reader will trust.
|
|
2542
2541
|
*/
|
|
@@ -3479,7 +3478,7 @@ export function assemble(t: ResolvedTable, prog: TableProgram, cfg: RunCfg): Ass
|
|
|
3479
3478
|
* delimiter (`orSentinel`, repeat.ts:454).
|
|
3480
3479
|
* - `mySync` is captured at ENTRY. An element's own sequence publishes
|
|
3481
3480
|
* over `_sync` while it runs; the interpreter restores in a `finally`
|
|
3482
|
-
* and
|
|
3481
|
+
* and the source lowering saved at entry — same value, both ways.
|
|
3483
3482
|
* - the separator-less path rolls the leading trivia back BEFORE
|
|
3484
3483
|
* recovering (repeat.ts's `repItem`), and the separated path does NOT:
|
|
3485
3484
|
* a consumed separator and the error after it both belong to the list
|
|
@@ -3903,7 +3902,7 @@ export function assemble(t: ResolvedTable, prog: TableProgram, cfg: RunCfg): Ass
|
|
|
3903
3902
|
ctx._fields = wantFields ? [] : undefined
|
|
3904
3903
|
// PER-NODE-TYPE TRIVIA-KIND MASK, scoped to the body and restored —
|
|
3905
3904
|
// `node.ts:259-273`, and codegen's `_triviaCaptureMask` save/install/
|
|
3906
|
-
// restore around the same scope
|
|
3905
|
+
// restore around the same scope. The table
|
|
3907
3906
|
// installed nothing, so a host that asked `Outer` for comments only got
|
|
3908
3907
|
// every kind the scanner saw.
|
|
3909
3908
|
const savedMask = structural ? ctx._triviaCaptureMask : undefined
|
|
@@ -19,7 +19,7 @@ import { runDuplicationDiagnosticRules, type DuplicationOption } from './duplica
|
|
|
19
19
|
* `compileRuleMap()` FOR THE TABLE LOWERING — the counterpart that did not exist.
|
|
20
20
|
*
|
|
21
21
|
* `compile` covered `compile()`, the SINGLE-ROOT entry point, which the
|
|
22
|
-
* plugin uses only for standalone combinators
|
|
22
|
+
* plugin uses only for standalone combinators.
|
|
23
23
|
* The main path — every `rules()` grammar — goes through `compileRuleMap`, and
|
|
24
24
|
* with no table counterpart there was nothing for the macro build to point at.
|
|
25
25
|
* This is that function, and it is the EASY direction: `encodeTable` takes a
|
|
@@ -29,7 +29,7 @@ import { runDuplicationDiagnosticRules, type DuplicationOption } from './duplica
|
|
|
29
29
|
* ── THE CONTRACT IT MATCHES ──────────────────────────────────────────────────
|
|
30
30
|
* `compileRuleMap` returns ONE `replacement` string: a self-contained expression
|
|
31
31
|
* that the plugin splices over the whole `rules(factory)` call-expression
|
|
32
|
-
* (`plugin/index.ts
|
|
32
|
+
* (`evaluateRulesFactory` in `plugin/index.ts`), evaluating ONCE to
|
|
33
33
|
* the `{ name: fn, … }` map. `keys` is the entry list, for the caller to check
|
|
34
34
|
* against the source's own keys. `hostMode` / `hostBranchElided` are what the
|
|
35
35
|
* macro stamps the emitted map with. `reflection` is per-grammar CST node
|
|
@@ -59,6 +59,7 @@ export type TableRuleMapOptions = {
|
|
|
59
59
|
readonly specialise?: boolean
|
|
60
60
|
/** Grammar-level ambient scan-skip, as `rules({ scanSkip }, …)` declares it. */
|
|
61
61
|
readonly scanSkip?: Combinator<unknown>[]
|
|
62
|
+
/** @deprecated Has no effect (see `TableSettings.recovery`). Removed in the next minor release. */
|
|
62
63
|
readonly recovery?: boolean
|
|
63
64
|
readonly hostMode?: HostMode
|
|
64
65
|
readonly trackLines?: boolean
|
|
@@ -264,7 +265,7 @@ function encodeForRun(
|
|
|
264
265
|
): { prog: TableProgram; fnSrcs: (string | null)[]; hostMode: HostMode; plan: ReturnType<typeof buildGrammarPlan> | undefined } | null {
|
|
265
266
|
runDuplicationDiagnosticRules(ruleMap, opts.duplication)
|
|
266
267
|
const encodeMap = withAmbient(ruleMap, opts)
|
|
267
|
-
// WINNERS ARE THE NON-`lazy` ENTRIES, exactly as
|
|
268
|
+
// WINNERS ARE THE NON-`lazy` ENTRIES, exactly as the source lowering picked them.
|
|
268
269
|
// A `rules()` map stores named lazy proxies beside resolved bodies, and the plan
|
|
269
270
|
// uses the winner map to give a shared subtree ONE owner; filtering differently
|
|
270
271
|
// here would mint `rule:` ids the source lowering does not, so a consumer
|
package/src/table/compile.ts
CHANGED
|
@@ -79,8 +79,8 @@ export type TableCompileOptions = {
|
|
|
79
79
|
readonly hostMode?: HostMode
|
|
80
80
|
readonly trackLines?: boolean
|
|
81
81
|
/**
|
|
82
|
-
* ACCEPTED AND IGNORED — recovery is ALWAYS lowered (see
|
|
83
|
-
*
|
|
82
|
+
* @deprecated ACCEPTED AND IGNORED — recovery is ALWAYS lowered (see
|
|
83
|
+
* `TableSettings.recovery`). Removed in the next minor release.
|
|
84
84
|
*/
|
|
85
85
|
readonly recovery?: boolean
|
|
86
86
|
/**
|
|
@@ -178,7 +178,7 @@ function compileRoot<T>(
|
|
|
178
178
|
): CompiledParser<T> {
|
|
179
179
|
// Argument order mirrors `compile(combinator, mapFnSources?, opts?)` so this is
|
|
180
180
|
// a drop-in, not a second API with a different shape.
|
|
181
|
-
// THE SAME WALK
|
|
181
|
+
// THE SAME WALK THE SOURCE LOWERING USED FOR A SINGLE ROOT: no winner
|
|
182
182
|
// map, so the paths are rooted at `entry` and the ids are the ones a caller
|
|
183
183
|
// switching lowerings already has. Building it differently here would produce a
|
|
184
184
|
// set that is internally consistent and lines up with nothing.
|
|
@@ -807,7 +807,7 @@ export function emitAssemblySource(
|
|
|
807
807
|
const armExpectedPlan: number[][] = []
|
|
808
808
|
const maskPlan: number[] = []
|
|
809
809
|
|
|
810
|
-
/**
|
|
810
|
+
/** Hoisted pools, in the source lowering's spelling: `_k<N>` / `_fx<N>` / `_fn<N>`. */
|
|
811
811
|
function hoist(kind: string, expr: string): string {
|
|
812
812
|
const hit = pool.get(expr)
|
|
813
813
|
if (hit !== undefined) return hit
|
|
@@ -1489,8 +1489,8 @@ return v
|
|
|
1489
1489
|
const xf = fxRef(code[ip + 2]!)
|
|
1490
1490
|
// TWO ARMS, mirroring `assemble.ts:1050`. A TOLERANT `expect()` EMBEDS
|
|
1491
1491
|
// ITS ERROR IN THE TREE and not only in the flat `_errors` side-channel
|
|
1492
|
-
// (`combinators/expect.ts:150`,
|
|
1493
|
-
//
|
|
1492
|
+
// (`combinators/expect.ts:150`, the source lowering's
|
|
1493
|
+
// `_ctx._rec.capture`) — so a tree walk finds every diagnostic and the node
|
|
1494
1494
|
// survives incremental subtree reuse. `captureError` is the shared
|
|
1495
1495
|
// function, called; the embedding is not restated here.
|
|
1496
1496
|
//
|
|
@@ -2734,7 +2734,7 @@ return nd
|
|
|
2734
2734
|
const ruleEntries: string[] = []
|
|
2735
2735
|
for (const [rname, entryIp] of Object.entries(prog.rules)) {
|
|
2736
2736
|
if (!served(entryIp)) continue
|
|
2737
|
-
// `_r_<Name>` — the composition surface, in
|
|
2737
|
+
// `_r_<Name>` — the composition surface, in the source lowering's spelling and
|
|
2738
2738
|
// deliberately NOT namespaced, so a sibling calls it by name.
|
|
2739
2739
|
const target = link(entryIp)
|
|
2740
2740
|
const rn = `_r_${rname.replace(/[^A-Za-z0-9_$]/g, '_')}`
|
package/src/table/emit.ts
CHANGED
|
@@ -15,9 +15,10 @@ export const FACTORY_ARITY_GUARD = `if(arguments.length<${EMITTED_PARAMS.length}
|
|
|
15
15
|
/**
|
|
16
16
|
* Print a program as the module a build emits.
|
|
17
17
|
*
|
|
18
|
-
* Everything here is DATA plus the author's own reducers
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* Everything here is DATA plus the author's own reducers, and any assemblies
|
|
19
|
+
* the build pre-compiled (`a:`). The recognizer is not in this string: it is
|
|
20
|
+
* `tableRules` from `parseman/table`, shared by every grammar in the bundle and
|
|
21
|
+
* by every variant of each.
|
|
21
22
|
*/
|
|
22
23
|
|
|
23
24
|
function jsString(s: string): string {
|
|
@@ -170,11 +171,10 @@ export function defaultAssemblyCfgs(prog: TableProgram): RunCfg[] {
|
|
|
170
171
|
* Print the assemblies a build pre-compiled, as the `a:` field of the program
|
|
171
172
|
* literal — see `TableProgram.asm`.
|
|
172
173
|
*
|
|
173
|
-
* THE FACTORY IS A REAL FUNCTION LITERAL.
|
|
174
|
-
*
|
|
175
|
-
* `
|
|
176
|
-
*
|
|
177
|
-
* artifact contract rather than recreate the old runtime/macro split.
|
|
174
|
+
* THE FACTORY IS A REAL FUNCTION LITERAL. A macro build emits one here for the
|
|
175
|
+
* AST, no-line-tracking option set, holding only the sites it selected within its
|
|
176
|
+
* budget (`compile-rule-map.ts`, `selectAssembly`); every other option set gets
|
|
177
|
+
* no entry and runs the closure assembler.
|
|
178
178
|
*
|
|
179
179
|
* A refusal is not an error. `Unemittable` names a construct the emitter does
|
|
180
180
|
* not lower; that option set simply gets no entry, and `assemble.ts` runs the
|
|
@@ -186,7 +186,7 @@ function emitAssemblies(prog: TableProgram, cfgs: readonly AssemblyCfg[]): strin
|
|
|
186
186
|
*
|
|
187
187
|
* The field's PRESENCE is the compiler artifact contract. That is what switches
|
|
188
188
|
* the runtime `Function` constructor off (`assemble.ts`), and it costs four
|
|
189
|
-
* bytes. Its CONTENTS are
|
|
189
|
+
* bytes. Its CONTENTS are the build's selected factories; with none, the
|
|
190
190
|
* artifact runs the closure engine — no eval, no
|
|
191
191
|
* size growth, and the refusal readable on `Assembly.emitRefusal`.
|
|
192
192
|
*
|
|
@@ -248,12 +248,11 @@ export type EmitOptions = {
|
|
|
248
248
|
/** Name of the exported binding. */
|
|
249
249
|
readonly name?: string
|
|
250
250
|
/**
|
|
251
|
-
*
|
|
251
|
+
* Emitted factories to pre-compile — see `defaultAssemblyCfgs`.
|
|
252
252
|
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
* second normal compilation path; it is not used by the macro plugin.
|
|
253
|
+
* Without them the artifact prints `a:[]`, the compact closure artifact, which
|
|
254
|
+
* never reaches the `Function` constructor. The macro plugin passes one
|
|
255
|
+
* selective assembly here (`compile-rule-map.ts`, `replacementWithMetadata`).
|
|
257
256
|
*/
|
|
258
257
|
readonly assemblies?: readonly AssemblyCfg[]
|
|
259
258
|
/**
|