parseman 0.46.0 → 0.47.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/README.md +8 -3
- package/dist/analysis/choice-cost-render.d.ts +12 -4
- package/dist/analysis/choice-cost-render.d.ts.map +1 -1
- package/dist/analysis/choice-cost.d.ts +2 -2
- package/dist/analysis/choice-cost.d.ts.map +1 -1
- package/dist/analysis/commitment.d.ts +131 -0
- package/dist/analysis/commitment.d.ts.map +1 -0
- package/dist/analysis/diagnostics.cjs +9929 -7465
- package/dist/analysis/diagnostics.cjs.map +3 -4
- package/dist/analysis/diagnostics.d.ts +2 -2
- package/dist/analysis/diagnostics.js +9929 -7465
- package/dist/analysis/diagnostics.js.map +3 -4
- package/dist/analysis/duplication.d.ts.map +1 -1
- package/dist/analysis/fix.d.ts +3 -3
- package/dist/analysis/fix.d.ts.map +1 -1
- package/dist/analysis/format-number.d.ts +23 -0
- package/dist/analysis/format-number.d.ts.map +1 -0
- package/dist/analysis/gating.d.ts +39 -2
- package/dist/analysis/gating.d.ts.map +1 -1
- package/dist/analysis/rebuild.d.ts.map +1 -1
- package/dist/analysis/terminal.d.ts +5 -2
- package/dist/analysis/terminal.d.ts.map +1 -1
- package/dist/cli/index.cjs +10865 -8535
- package/dist/cli/index.cjs.map +3 -4
- package/dist/cli/index.js +10865 -8535
- package/dist/cli/index.js.map +3 -4
- package/dist/combinators/adjacency.d.ts +100 -0
- package/dist/combinators/adjacency.d.ts.map +1 -0
- package/dist/combinators/choice.d.ts.map +1 -1
- package/dist/combinators/completions.d.ts.map +1 -1
- package/dist/combinators/dispatch.d.ts +8 -1
- package/dist/combinators/dispatch.d.ts.map +1 -1
- package/dist/combinators/expect.d.ts.map +1 -1
- package/dist/combinators/first-set.d.ts.map +1 -1
- package/dist/combinators/gate.d.ts.map +1 -1
- package/dist/combinators/grammar.d.ts +22 -0
- package/dist/combinators/grammar.d.ts.map +1 -1
- package/dist/combinators/literal.d.ts +8 -0
- package/dist/combinators/literal.d.ts.map +1 -1
- package/dist/combinators/map.d.ts +0 -1
- package/dist/combinators/map.d.ts.map +1 -1
- package/dist/combinators/node.d.ts +13 -3
- package/dist/combinators/node.d.ts.map +1 -1
- package/dist/combinators/parser.d.ts +1 -1
- package/dist/combinators/parser.d.ts.map +1 -1
- package/dist/combinators/ref.d.ts.map +1 -1
- package/dist/combinators/regex.d.ts +1 -16
- package/dist/combinators/regex.d.ts.map +1 -1
- package/dist/combinators/repeat.d.ts +30 -2
- package/dist/combinators/repeat.d.ts.map +1 -1
- package/dist/combinators/scanTo.d.ts +71 -1
- package/dist/combinators/scanTo.d.ts.map +1 -1
- package/dist/combinators/sequence.d.ts.map +1 -1
- package/dist/combinators/token.d.ts.map +1 -1
- package/dist/combinators/trivia-boundary.d.ts +26 -0
- package/dist/combinators/trivia-boundary.d.ts.map +1 -0
- package/dist/combinators/trivia-skip.d.ts +40 -1
- package/dist/combinators/trivia-skip.d.ts.map +1 -1
- package/dist/combinators/withCtx.d.ts.map +1 -1
- package/dist/compiler/compile-linkable-table.d.ts +104 -0
- package/dist/compiler/compile-linkable-table.d.ts.map +1 -0
- package/dist/compiler/degradation.d.ts +0 -2
- package/dist/compiler/degradation.d.ts.map +1 -1
- package/dist/compiler/fields.d.ts +13 -0
- package/dist/compiler/fields.d.ts.map +1 -1
- package/dist/compiler/grammar-coverage-ids.d.ts +5 -5
- package/dist/compiler/grammar-coverage-ids.d.ts.map +1 -1
- package/dist/compiler/ir-serialize.d.ts.map +1 -1
- package/dist/compiler/linker.d.ts +47 -53
- package/dist/compiler/linker.d.ts.map +1 -1
- package/dist/compiler/token-alphabet.d.ts +81 -0
- package/dist/compiler/token-alphabet.d.ts.map +1 -0
- package/dist/compiler/token-dispatch.d.ts +95 -0
- package/dist/compiler/token-dispatch.d.ts.map +1 -0
- package/dist/compiler/token-scanner.d.ts +53 -0
- package/dist/compiler/token-scanner.d.ts.map +1 -0
- package/dist/compiler/value-usage.d.ts.map +1 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.d.ts.map +1 -1
- package/dist/cst/capture-buffer.d.ts +35 -0
- package/dist/cst/capture-buffer.d.ts.map +1 -1
- package/dist/cst/reflection-attach.d.ts +8 -0
- package/dist/cst/reflection-attach.d.ts.map +1 -0
- package/dist/cst/reflection-symbols.d.ts +10 -0
- package/dist/cst/reflection-symbols.d.ts.map +1 -0
- package/dist/cst/reflection.d.ts +2 -4
- package/dist/cst/reflection.d.ts.map +1 -1
- package/dist/cst/root-trivia-scope.d.ts +26 -0
- package/dist/cst/root-trivia-scope.d.ts.map +1 -0
- package/dist/cst/trivia-charscan.d.ts +18 -0
- package/dist/cst/trivia-charscan.d.ts.map +1 -0
- package/dist/cst/trivia-kinds.d.ts +19 -0
- package/dist/cst/trivia-kinds.d.ts.map +1 -1
- package/dist/functional/doc.d.ts.map +1 -1
- package/dist/functional/run-tabled.d.ts +12 -0
- package/dist/functional/run-tabled.d.ts.map +1 -0
- package/dist/functional/run.d.ts +25 -42
- package/dist/functional/run.d.ts.map +1 -1
- package/dist/grammar-metadata.d.ts +3 -0
- package/dist/grammar-metadata.d.ts.map +1 -0
- package/dist/index.cjs +9224 -7203
- package/dist/index.cjs.map +3 -4
- package/dist/index.d.ts +18 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9219 -7198
- package/dist/index.js.map +3 -4
- package/dist/language-service/index.cjs +311 -121
- package/dist/language-service/index.cjs.map +3 -4
- package/dist/language-service/index.js +311 -121
- package/dist/language-service/index.js.map +3 -4
- package/dist/oracle/index.cjs.map +0 -1
- package/dist/oracle/index.js.map +0 -1
- package/dist/parse-context.d.ts +49 -0
- package/dist/parse-context.d.ts.map +1 -0
- package/dist/plugin/evaluator.d.ts +40 -1
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/index.cjs +11146 -9593
- package/dist/plugin/index.cjs.map +3 -4
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +11146 -9593
- package/dist/plugin/index.js.map +3 -4
- package/dist/regex/classes.d.ts +28 -0
- package/dist/regex/classes.d.ts.map +1 -1
- package/dist/regex/first-set.d.ts +14 -0
- package/dist/regex/first-set.d.ts.map +1 -1
- package/dist/run/index.cjs +136 -51
- package/dist/run/index.cjs.map +2 -3
- package/dist/run/index.js +136 -51
- package/dist/run/index.js.map +2 -3
- package/dist/spec/index.cjs +2898 -1623
- package/dist/spec/index.cjs.map +3 -4
- package/dist/spec/index.js +2898 -1623
- package/dist/spec/index.js.map +3 -4
- package/dist/spec/model.d.ts +8 -0
- package/dist/spec/model.d.ts.map +1 -1
- package/dist/table/assemble.d.ts +307 -0
- package/dist/table/assemble.d.ts.map +1 -0
- package/dist/table/cell.d.ts +42 -0
- package/dist/table/cell.d.ts.map +1 -0
- package/dist/table/child-slots.d.ts +30 -0
- package/dist/table/child-slots.d.ts.map +1 -0
- package/dist/table/compile-rule-map.d.ts +136 -0
- package/dist/table/compile-rule-map.d.ts.map +1 -0
- package/dist/table/compile.d.ts +56 -0
- package/dist/table/compile.d.ts.map +1 -0
- package/dist/table/duplication-hook.d.ts +32 -0
- package/dist/table/duplication-hook.d.ts.map +1 -0
- package/dist/table/emit-assembly.d.ts +139 -0
- package/dist/table/emit-assembly.d.ts.map +1 -0
- package/dist/table/emit.d.ts +113 -0
- package/dist/table/emit.d.ts.map +1 -0
- package/dist/table/encode-baseline.d.ts +16 -0
- package/dist/table/encode-baseline.d.ts.map +1 -0
- package/dist/table/encode.d.ts +71 -0
- package/dist/table/encode.d.ts.map +1 -0
- package/dist/table/exec-baseline.d.ts +9 -0
- package/dist/table/exec-baseline.d.ts.map +1 -0
- package/dist/table/exec.d.ts +72 -0
- package/dist/table/exec.d.ts.map +1 -0
- package/dist/table/fold.d.ts +25 -0
- package/dist/table/fold.d.ts.map +1 -0
- package/dist/table/index.cjs +11375 -0
- package/dist/table/index.cjs.map +6 -0
- package/dist/table/index.d.ts +100 -0
- package/dist/table/index.d.ts.map +1 -0
- package/dist/table/index.js +11352 -0
- package/dist/table/index.js.map +6 -0
- package/dist/table/inspect.d.ts +17 -0
- package/dist/table/inspect.d.ts.map +1 -0
- package/dist/table/ops.d.ts +446 -0
- package/dist/table/ops.d.ts.map +1 -0
- package/dist/table/program.d.ts +493 -0
- package/dist/table/program.d.ts.map +1 -0
- package/dist/table/run-support.d.ts +38 -0
- package/dist/table/run-support.d.ts.map +1 -0
- package/dist/{compiler/scannable-run.d.ts → table/scan-shapes.d.ts} +14 -13
- package/dist/table/scan-shapes.d.ts.map +1 -0
- package/dist/table/site-labels.d.ts +58 -0
- package/dist/table/site-labels.d.ts.map +1 -0
- package/dist/table/stamp.d.ts +70 -0
- package/dist/table/stamp.d.ts.map +1 -0
- package/dist/types.d.ts +80 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +25 -2
- package/src/analysis/choice-cost-gate.ts +359 -0
- package/src/analysis/choice-cost-render.ts +293 -0
- package/src/analysis/choice-cost.ts +1008 -0
- package/src/analysis/commitment.ts +557 -0
- package/src/analysis/corpus.ts +130 -0
- package/src/analysis/diagnose-render.ts +625 -0
- package/src/analysis/diagnose.ts +317 -0
- package/src/analysis/diagnostics.ts +33 -0
- package/src/analysis/duplication.ts +1955 -0
- package/src/analysis/fix-render.ts +217 -0
- package/src/analysis/fix.ts +669 -0
- package/src/analysis/format-number.ts +31 -0
- package/src/analysis/gating.ts +792 -0
- package/src/analysis/grammar.ts +72 -0
- package/src/analysis/rebuild.ts +287 -0
- package/src/analysis/terminal.ts +336 -0
- package/src/cli/index.ts +413 -0
- package/src/combinators/adjacency.ts +171 -0
- package/src/combinators/attempt.ts +41 -0
- package/src/combinators/case-fold.ts +90 -0
- package/src/combinators/choice.ts +466 -0
- package/src/combinators/completions.ts +64 -0
- package/src/combinators/dispatch.ts +358 -0
- package/src/combinators/expect.ts +159 -0
- package/src/combinators/first-set.ts +322 -0
- package/src/combinators/gate.ts +50 -0
- package/src/combinators/grammar.ts +272 -0
- package/src/combinators/keywords.ts +145 -0
- package/src/combinators/literal.ts +102 -0
- package/src/combinators/map.ts +106 -0
- package/src/combinators/node.ts +345 -0
- package/src/combinators/not.ts +55 -0
- package/src/combinators/parser.ts +266 -0
- package/src/combinators/peek.ts +63 -0
- package/src/combinators/probe.ts +25 -0
- package/src/combinators/ref.ts +109 -0
- package/src/combinators/regex.ts +170 -0
- package/src/combinators/repeat.ts +561 -0
- package/src/combinators/scanTo.ts +393 -0
- package/src/combinators/sequence.ts +221 -0
- package/src/combinators/token.ts +120 -0
- package/src/combinators/trivia-boundary.ts +48 -0
- package/src/combinators/trivia-skip.ts +821 -0
- package/src/combinators/withCtx.ts +45 -0
- package/src/compiler/build-arity.ts +330 -0
- package/src/compiler/compile-linkable-table.ts +209 -0
- package/src/compiler/degradation.ts +266 -0
- package/src/compiler/fields.ts +191 -0
- package/src/compiler/grammar-coverage-ids.ts +129 -0
- package/src/compiler/ir-serialize.ts +615 -0
- package/src/compiler/linker.ts +954 -0
- package/src/compiler/token-alphabet.ts +209 -0
- package/src/compiler/token-dispatch.ts +353 -0
- package/src/compiler/token-scanner.ts +318 -0
- package/src/compiler/value-usage.ts +147 -0
- package/src/coverage.ts +383 -0
- package/src/cst/capture-buffer.ts +297 -0
- package/src/cst/host-mode.ts +69 -0
- package/src/cst/reflection-attach.ts +11 -0
- package/src/cst/reflection-symbols.ts +9 -0
- package/src/cst/reflection.ts +149 -0
- package/src/cst/relative-spans.ts +207 -0
- package/src/cst/root-trivia-scope.ts +30 -0
- package/src/cst/trivia-charscan.ts +312 -0
- package/src/cst/trivia-entries.ts +285 -0
- package/src/cst/trivia-index.ts +131 -0
- package/src/cst/trivia-kinds.ts +358 -0
- package/src/cst/types.ts +76 -0
- package/src/cst/walk.ts +101 -0
- package/src/functional/doc.ts +959 -0
- package/src/functional/run-tabled.ts +153 -0
- package/src/functional/run.ts +558 -0
- package/src/grammar-metadata.ts +2 -0
- package/src/index.ts +189 -0
- package/src/language-service/index.ts +221 -0
- package/src/line-index.ts +131 -0
- package/src/oracle/digest.ts +620 -0
- package/src/oracle/index.ts +55 -0
- package/src/parse-context.ts +91 -0
- package/src/plugin/direct-builder-static.ts +102 -0
- package/src/plugin/evaluator.ts +1505 -0
- package/src/plugin/free-identifiers.ts +338 -0
- package/src/plugin/index.ts +2281 -0
- package/src/plugin/reducer-resolver.ts +606 -0
- package/src/recovery/scan.ts +155 -0
- package/src/regex/classes.ts +183 -0
- package/src/regex/first-set.ts +316 -0
- package/src/run/index.ts +31 -0
- package/src/spec/ebnf.ts +128 -0
- package/src/spec/index.ts +54 -0
- package/src/spec/model.ts +636 -0
- package/src/spec/railroad-lib.ts +559 -0
- package/src/spec/railroad.ts +256 -0
- package/src/table/assemble.ts +2994 -0
- package/src/table/cell.ts +42 -0
- package/src/table/child-slots.ts +113 -0
- package/src/table/compile-rule-map.ts +336 -0
- package/src/table/compile.ts +244 -0
- package/src/table/duplication-hook.ts +89 -0
- package/src/table/emit-assembly.ts +1766 -0
- package/src/table/emit.ts +418 -0
- package/src/table/encode-baseline.ts +340 -0
- package/src/table/encode.ts +1569 -0
- package/src/table/exec-baseline.ts +537 -0
- package/src/table/exec.ts +1672 -0
- package/src/table/fold.ts +38 -0
- package/src/table/index.ts +108 -0
- package/src/table/inspect.ts +52 -0
- package/src/table/ops.ts +459 -0
- package/src/table/program.ts +855 -0
- package/src/table/run-support.ts +66 -0
- package/src/table/scan-shapes.ts +1578 -0
- package/src/table/site-labels.ts +228 -0
- package/src/table/stamp.ts +229 -0
- package/src/types.ts +563 -0
- package/src/version.ts +16 -0
- package/dist/compiler/codegen.d.ts +0 -334
- package/dist/compiler/codegen.d.ts.map +0 -1
- package/dist/compiler/inline-build.d.ts +0 -11
- package/dist/compiler/inline-build.d.ts.map +0 -1
- package/dist/compiler/inline-callback.d.ts +0 -21
- package/dist/compiler/inline-callback.d.ts.map +0 -1
- package/dist/compiler/line-index.d.ts +0 -2
- package/dist/compiler/line-index.d.ts.map +0 -1
- package/dist/compiler/module-hoist.d.ts +0 -106
- package/dist/compiler/module-hoist.d.ts.map +0 -1
- package/dist/compiler/scannable-run.d.ts.map +0 -1
- package/dist/compiler/scannable-terminal.d.ts +0 -23
- package/dist/compiler/scannable-terminal.d.ts.map +0 -1
- package/dist/compiler/trivia-fast-path.d.ts +0 -38
- package/dist/compiler/trivia-fast-path.d.ts.map +0 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived tokenization, part 3: token-KEYED dispatch.
|
|
3
|
+
*
|
|
4
|
+
* A `dispatch()` used to emit, per case, a chained condition that re-derived the
|
|
5
|
+
* key from the selector's STRING one character at a time:
|
|
6
|
+
*
|
|
7
|
+
* if (_dkey.length === 6 && _dkey.charCodeAt(0) === 64 && (_dkey.charCodeAt(1) | 32) === 108 && ...)
|
|
8
|
+
* else if (_dkey.length === 15 && ...)
|
|
9
|
+
*
|
|
10
|
+
* Measured on the built css artifact: 40,269 B of 3,336,650 B was exactly these
|
|
11
|
+
* chains, 10,499 B of it inside `_r_StylesheetAtRule` alone.
|
|
12
|
+
*
|
|
13
|
+
* Instead the selector's matched span is walked to a small integer case id, and
|
|
14
|
+
* the cases select on the integer. Every id strategy below is BUILT, not
|
|
15
|
+
* reasoned about — `PARSEMAN_DISPATCH=<id>:<sel>` picks one so they can be
|
|
16
|
+
* measured on the shipped artifact rather than in a microbenchmark, which
|
|
17
|
+
* already misled us once: a standalone "table" looked slow because that
|
|
18
|
+
* implementation sliced and lowercased and hashed, not because table dispatch
|
|
19
|
+
* is slow.
|
|
20
|
+
*
|
|
21
|
+
* Every strategy is "compute a candidate case cheaply, then VERIFY against the
|
|
22
|
+
* packed key text", except `trie`, whose walk is already exact.
|
|
23
|
+
*/
|
|
24
|
+
/** One dispatch case's keys, in emission order. Case ids are 1-based; 0 = no match. */
|
|
25
|
+
export type DispatchKeySet = {
|
|
26
|
+
keys: readonly string[];
|
|
27
|
+
caseInsensitive: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type IdStrategy = 'trie' | 'lenswitch' | 'firstchar' | 'phash';
|
|
30
|
+
export type ArmSelection = 'ifchain' | 'switch';
|
|
31
|
+
export type DispatchConfig = {
|
|
32
|
+
id: IdStrategy | 'auto';
|
|
33
|
+
sel: ArmSelection;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* `PARSEMAN_DISPATCH=<id>:<sel>`. The default is the MEASURED winner on the
|
|
37
|
+
* shipped css artifact, not a preference. All five configurations were built
|
|
38
|
+
* into this emitter and compared on the real artifact with the trees diffed for
|
|
39
|
+
* equality, interleaved in one process (medians of 31 rounds):
|
|
40
|
+
*
|
|
41
|
+
* config ms/parse rel raw B gzip B
|
|
42
|
+
* chain 6.092 1.000 3,336,650 426,247
|
|
43
|
+
* trie:ifchain 5.967 0.979 3,311,657 424,465 <- default
|
|
44
|
+
* trie:switch 5.945 0.976 3,333,421 424,895
|
|
45
|
+
* phash:switch 6.011 0.987 3,331,361 424,637
|
|
46
|
+
*
|
|
47
|
+
* `firstchar` and `lenswitch` BUILD but are inapplicable to css's at-keyword
|
|
48
|
+
* sets — every key starts with `@`, and the lengths collide — so they fall back
|
|
49
|
+
* and emit the chain. `phash` finds an injective hash (the search works) but
|
|
50
|
+
* costs more table bytes than the trie saves. `switch` arm selection is within
|
|
51
|
+
* noise of the chain of integer compares at 3 sites x 8 cases; its larger raw
|
|
52
|
+
* size is the downstream formatter indenting case bodies, which is why gzip is
|
|
53
|
+
* the metric that decides here.
|
|
54
|
+
*
|
|
55
|
+
* The speed spread across ALL configurations is 2.4% — dispatch keying is not
|
|
56
|
+
* where css parse time goes.
|
|
57
|
+
*/
|
|
58
|
+
export declare function dispatchConfigFromEnv(env: Record<string, string | undefined>): DispatchConfig;
|
|
59
|
+
/**
|
|
60
|
+
* ASCII letter-only case fold. Used IDENTICALLY when building the tables and
|
|
61
|
+
* when reading input — the two must never disagree. The cheaper `c | 32` is
|
|
62
|
+
* wrong here: it maps '@'(64) to '`'(96), which silently stops every '@'-led
|
|
63
|
+
* key from ever matching, and maps '_'(95) to DEL(127), which would accept a
|
|
64
|
+
* character the key does not contain.
|
|
65
|
+
*/
|
|
66
|
+
export declare const foldExpr: (c: string) => string;
|
|
67
|
+
export declare function foldCode(c: number): number;
|
|
68
|
+
/**
|
|
69
|
+
* Pack a non-negative int array into a two-chars-per-value string literal.
|
|
70
|
+
*
|
|
71
|
+
* Two chars at six bits each is TWELVE BITS: the representable range is 0..4095.
|
|
72
|
+
* The mask made anything larger wrap SILENTLY, and `unpack` then decoded a wrong
|
|
73
|
+
* index — a table that looks fine and routes to the wrong arm. Bounded here, and
|
|
74
|
+
* this is the ONLY implementation: a second copy in token-scanner.ts had the same
|
|
75
|
+
* encoding and the same missing check, which is how one defect became two.
|
|
76
|
+
*/
|
|
77
|
+
export declare const PACK_MAX = 4095;
|
|
78
|
+
export declare function packInts(values: readonly number[]): string;
|
|
79
|
+
export type SharedHelper = 'unpack' | 'verify' | 'trie' | 'lenswitch' | 'firstchar' | 'phash';
|
|
80
|
+
export declare function sharedHelperDecl(kind: SharedHelper, n: (h: SharedHelper) => string): string;
|
|
81
|
+
/** Per-site emission: declarations to hoist plus the call expression. */
|
|
82
|
+
export type SiteEmission = {
|
|
83
|
+
strategy: IdStrategy;
|
|
84
|
+
decls: string[];
|
|
85
|
+
callExpr: string;
|
|
86
|
+
helpers: SharedHelper[];
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Emit the id computation for one site. `auto` picks by KEY-SET SHAPE measured
|
|
90
|
+
* at macro time rather than applying one strategy everywhere: separation on
|
|
91
|
+
* char 0 is the cheapest test there is, a searched perfect hash next, then
|
|
92
|
+
* length, with the trie as the always-applicable fallback.
|
|
93
|
+
*/
|
|
94
|
+
export declare function emitDispatchId(cases: ReadonlyArray<DispatchKeySet>, cfg: DispatchConfig, prefix: string, helperName: (h: SharedHelper) => string, pos: string, end: string): SiteEmission | null;
|
|
95
|
+
//# sourceMappingURL=token-dispatch.d.ts.map
|
|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,EAAE,UAAU,CAAA;IACpB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,YAAY,EAAE,CAAA;CACxB,CAAA;AA+HD;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,EACpC,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,MAAM,EACvC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,YAAY,GAAG,IAAI,CAcrB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derived tokenization, part 2: emit the SCANNER for an alphabet.
|
|
3
|
+
*
|
|
4
|
+
* Shape, and why each piece is what it is (all measured on the css grammar):
|
|
5
|
+
*
|
|
6
|
+
* - Literal and keyword terminals become a DATA TRIE walked by a fixed-size
|
|
7
|
+
* driver. The trie walk is also the macro-time SEARCH for a distinguishing
|
|
8
|
+
* position set: it walks until the node is uniquely accepting, so it does not
|
|
9
|
+
* depend on a fixed discriminator. A fixed one does not work — `(len,c1,c2)`
|
|
10
|
+
* collides on `@counter-style`/`@color-profile` and
|
|
11
|
+
* `@font-feature-values`/`@font-palette-values`, and widening to the last
|
|
12
|
+
* char still leaves 11 buckets for 13 keys.
|
|
13
|
+
* Emitting the trie as CODE (nested switches) was measured at 25,223 B for 13
|
|
14
|
+
* css at-keywords; as DATA it is 2,057 B for the same set and 1.4x the speed
|
|
15
|
+
* of today's slice-plus-char-chain rather than 2.5x. Data also means the
|
|
16
|
+
* driver's size is independent of how many keys the grammar has.
|
|
17
|
+
*
|
|
18
|
+
* - Regex terminals stay sticky regexes, consulted ONLY when the position's
|
|
19
|
+
* first char is in their first set. Ungated, a 42-regex core alphabet scans
|
|
20
|
+
* benchmark.css at 14.5 MB/s; first-char gated, 30.4 MB/s.
|
|
21
|
+
*
|
|
22
|
+
* - The candidate set consulted is LOCAL to the decision point (a packed table
|
|
23
|
+
* of id lists). The id space is global. Global maximal munch over the whole
|
|
24
|
+
* alphabet produces seven tokens for a 123 KB stylesheet.
|
|
25
|
+
*
|
|
26
|
+
* - `tight` is set AT SCAN TIME: 1 when no trivia preceded the token. This is
|
|
27
|
+
* what carries `noTrivia` adjacency (262 sites across the four dialects, 50 in
|
|
28
|
+
* css) rather than the hand-spelled `boundary` classes, which are not even
|
|
29
|
+
* self-consistent today: the 26 css `keywords(boundary:)` sites use THREE
|
|
30
|
+
* different spellings and 16 of them omit `-` and/or `\\`.
|
|
31
|
+
*
|
|
32
|
+
* - Whitespace is a token in `MODE_SELECTOR` (the descendant combinator is
|
|
33
|
+
* significant there) and skipped otherwise. Mode is part of the memo key.
|
|
34
|
+
*/
|
|
35
|
+
import type { Alphabet } from './token-alphabet.ts';
|
|
36
|
+
export type ScannerEmission = {
|
|
37
|
+
/** Module-scope declarations for the artifact prelude. */
|
|
38
|
+
decls: string[];
|
|
39
|
+
/** Name of the cursor entry point. */
|
|
40
|
+
nextFn: string;
|
|
41
|
+
/** Register a candidate set, returning its table index. */
|
|
42
|
+
candidateIndexOf: (ids: readonly number[]) => number;
|
|
43
|
+
/** True when the alphabet produced a usable scanner at all. */
|
|
44
|
+
usable: boolean;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Emit the scanner for `alphabet`. `ns` namespaces every hoisted name exactly
|
|
48
|
+
* like `_re`/`_fx`/`_pf` so two fused pieces never collide.
|
|
49
|
+
*/
|
|
50
|
+
export declare function emitScanner(alphabet: Alphabet, ns: string): ScannerEmission;
|
|
51
|
+
/** Patch the candidate table placeholders once every decision point registered. */
|
|
52
|
+
export declare function finalizeScanner(emission: ScannerEmission): string[];
|
|
53
|
+
//# sourceMappingURL=token-scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-scanner.d.ts","sourceRoot":"","sources":["../../src/compiler/token-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAyFnD,MAAM,MAAM,eAAe,GAAG;IAC5B,0DAA0D;IAC1D,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,2DAA2D;IAC3D,gBAAgB,EAAE,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,KAAK,MAAM,CAAA;IACpD,+DAA+D;IAC/D,MAAM,EAAE,OAAO,CAAA;CAChB,CAAA;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,GAAG,eAAe,CAuK3E;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,EAAE,CASnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value-usage.d.ts","sourceRoot":"","sources":["../../src/compiler/value-usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"value-usage.d.ts","sourceRoot":"","sources":["../../src/compiler/value-usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,IAAI,CA2HhE"}
|
package/dist/coverage.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type RunOptions, type RunResult, type Runnable } from './functional/run.ts';
|
|
2
|
+
export { GRAMMAR_COVERAGE_DEFINITIONS } from './grammar-metadata.ts';
|
|
2
3
|
import type { Combinator, ParseContext } from './types.ts';
|
|
3
4
|
import { type GrammarCoverageDefinition } from './compiler/grammar-coverage-ids.ts';
|
|
4
5
|
export type { GrammarCoverageDefinition } from './compiler/grammar-coverage-ids.ts';
|
|
@@ -29,7 +30,6 @@ export type GrammarCoverageCollector = {
|
|
|
29
30
|
/** Metadata emitted only by a coverage-enabled macro grammar. It is attached to
|
|
30
31
|
* the grammar map, rather than each rule function, so a caller chooses the
|
|
31
32
|
* explicit public start rule before collecting results. */
|
|
32
|
-
export declare const GRAMMAR_COVERAGE_DEFINITIONS: symbol;
|
|
33
33
|
export declare function compiledGrammarCoverageDefinitions(grammar: Record<string, unknown>): readonly GrammarCoverageDefinition[];
|
|
34
34
|
export type GrammarTracePhase = 'enter' | 'attempt' | 'selected' | 'success' | 'failure' | 'backtrack' | 'rollback';
|
|
35
35
|
export type GrammarTraceEvent = {
|
package/dist/coverage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../src/coverage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"coverage.d.ts","sourceRoot":"","sources":["../src/coverage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEzF,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,KAAK,EAAE,UAAU,EAAqC,YAAY,EAAe,MAAM,YAAY,CAAA;AAmB1G,OAAO,EAAoB,KAAK,yBAAyB,EAA4B,MAAM,oCAAoC,CAAA;AAE/H,YAAY,EAAE,yBAAyB,EAAE,MAAM,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|
import type { ParseContext } from '../types.ts';
|
|
2
2
|
/** Lazy per-node capture state — arrays materialized on first push. */
|
|
3
3
|
export type CstCaptureBuf = {
|
|
4
|
+
/** Table-host specialisation: collect source-order raw entries without the
|
|
5
|
+
* duplicate semantic children view. Selected once for the enclosing node. */
|
|
6
|
+
rawOnly?: true | undefined;
|
|
4
7
|
single?: unknown | undefined;
|
|
5
8
|
ch?: unknown[] | undefined;
|
|
6
9
|
rawSingle?: unknown | undefined;
|
|
@@ -41,7 +44,39 @@ export type CstRollbackMark = {
|
|
|
41
44
|
errors: number;
|
|
42
45
|
};
|
|
43
46
|
export declare function saveCstMark(ctx: ParseContext): CstRollbackMark;
|
|
47
|
+
/**
|
|
48
|
+
* Demote everything captured since `childrenLen` from the STRUCTURAL `children`
|
|
49
|
+
* array to `rawChildren` only — it stays in the tree, it stops being a child.
|
|
50
|
+
*
|
|
51
|
+
* This is the one mechanism behind the rule that a list-producing combinator
|
|
52
|
+
* contributes the items of the list and NOTHING ELSE. `sepBy`'s separator is
|
|
53
|
+
* matched by a real combinator, so it pushes through the same nine push sites
|
|
54
|
+
* every terminal does; there is no separate channel to route it into at match
|
|
55
|
+
* time. Demoting after the fact is the cheapest correct answer: it reuses the
|
|
56
|
+
* mark the loop already took for rollback, truncates one array, and leaves
|
|
57
|
+
* `rawChildren` — the source-order record — untouched, so the separator is
|
|
58
|
+
* still recoverable WITHOUT re-reading source bytes.
|
|
59
|
+
*
|
|
60
|
+
* `raw` is deliberately NOT truncated. That asymmetry is the whole point, and it
|
|
61
|
+
* is the same asymmetry trivia already has: consumed, absent from `children`,
|
|
62
|
+
* still reachable.
|
|
63
|
+
*/
|
|
64
|
+
export declare function demoteCapturedToRaw(ctx: ParseContext, childrenLen: number): void;
|
|
44
65
|
export declare function rollbackCstCapture(ctx: ParseContext, mark: CstRollbackMark): void;
|
|
66
|
+
/**
|
|
67
|
+
* The same rollback, taking the five marks as SCALARS.
|
|
68
|
+
*
|
|
69
|
+
* `saveCstMark` allocates a five-field object, and the table driver took one per
|
|
70
|
+
* choice attempt and per repetition item — on `benchmark.less` that is 5.0%
|
|
71
|
+
* (`saveCstMark`) plus 2.1% (`saveTriviaMark`, which allocates this one AND a
|
|
72
|
+
* seven-field wrapper) of the whole parse. The compiled engine holds the same
|
|
73
|
+
* five numbers in scalar locals and allocates nothing, which is the only
|
|
74
|
+
* difference; a caller that keeps them in locals can now do the same.
|
|
75
|
+
*
|
|
76
|
+
* `rollbackCstCapture` stays as the object-taking entry point because the
|
|
77
|
+
* interpreter's call sites genuinely carry a mark around.
|
|
78
|
+
*/
|
|
79
|
+
export declare function rollbackCstCaptureAt(ctx: ParseContext, raw: number, tlog: number, leaves: number, fields: number, errors: number): void;
|
|
45
80
|
export declare function pushCstTriviaEntry(ctx: ParseContext, start: number, end: number, kindIndex?: number): void;
|
|
46
81
|
export declare function pushTriviaLogEntry(ctx: ParseContext, start: number, end: number, kindIndex?: number): void;
|
|
47
82
|
export declare function cstDeferredTriviaActive(ctx: ParseContext): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture-buffer.d.ts","sourceRoot":"","sources":["../../src/cst/capture-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAQ,MAAM,aAAa,CAAA;AAGrD,uEAAuE;AACvE,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC5B,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,SAAS,CAAA;IAC1B,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC/B,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,SAAS,CAAA;IAC3B,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;CAC1B,CAAA;AAKD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAE3D;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EA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,GAAG,EAAE,YAAY,GAAG,OAAO,CAElE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type GrammarReflection } from './reflection.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Legacy interpreted-rule-map attachment. It is deliberately outside the shared
|
|
4
|
+
* table runtime graph: macro/table artifacts construct reflection in their
|
|
5
|
+
* metadata prototype instead of mutating an already-built map.
|
|
6
|
+
*/
|
|
7
|
+
export declare function attachGrammarReflection<T extends object>(grammar: T, reflection: GrammarReflection): T;
|
|
8
|
+
//# sourceMappingURL=reflection-attach.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflection-attach.d.ts","sourceRoot":"","sources":["../../src/cst/reflection-attach.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAE5E;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,iBAAiB,GAAG,CAAC,CAGtG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-level CST identity lives on the hot table-runtime import graph. Keep the
|
|
3
|
+
* symbols separate from reflection collection/attachment: the latter is a
|
|
4
|
+
* grammar-construction concern and must not make every emitted parser load its
|
|
5
|
+
* descriptor-based legacy helper.
|
|
6
|
+
*/
|
|
7
|
+
export declare const GRAMMAR_REFLECTION: unique symbol;
|
|
8
|
+
export declare const NODE_TYPE: unique symbol;
|
|
9
|
+
export declare const NODE_TAG: unique symbol;
|
|
10
|
+
//# sourceMappingURL=reflection-symbols.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reflection-symbols.d.ts","sourceRoot":"","sources":["../../src/cst/reflection-symbols.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,MAA0D,CAAA;AAClG,eAAO,MAAM,SAAS,EAAE,OAAO,MAAsD,CAAA;AACrF,eAAO,MAAM,QAAQ,EAAE,OAAO,MAAqD,CAAA"}
|
package/dist/cst/reflection.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Combinator } from '../types.ts';
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export declare const NODE_TAG: unique symbol;
|
|
2
|
+
import { GRAMMAR_REFLECTION, NODE_TAG, NODE_TYPE } from './reflection-symbols.ts';
|
|
3
|
+
export { GRAMMAR_REFLECTION, NODE_TYPE, NODE_TAG } from './reflection-symbols.ts';
|
|
5
4
|
export type GrammarNodeReflection = {
|
|
6
5
|
type: string;
|
|
7
6
|
tags: readonly string[];
|
|
@@ -18,7 +17,6 @@ export declare function collectGrammarReflection(ruleMap: ReadonlyArray<readonly
|
|
|
18
17
|
followLazy?: boolean;
|
|
19
18
|
}): GrammarReflection;
|
|
20
19
|
export declare function mergeGrammarReflections(reflections: readonly GrammarReflection[]): GrammarReflection;
|
|
21
|
-
export declare function attachGrammarReflection<T extends object>(grammar: T, reflection: GrammarReflection): T;
|
|
22
20
|
export declare function grammarReflectionOf(grammar: object): GrammarReflection | undefined;
|
|
23
21
|
export declare function grammarReflectionSource(reflection: GrammarReflection): string;
|
|
24
22
|
//# sourceMappingURL=reflection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflection.d.ts","sourceRoot":"","sources":["../../src/cst/reflection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"reflection.d.ts","sourceRoot":"","sources":["../../src/cst/reflection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAEjF,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEjF,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,SAAS,qBAAqB,EAAE,CAAA;CACxC,CAAA;AAED,MAAM,MAAM,qBAAqB,CAC/B,QAAQ,SAAS,MAAM,GAAG,MAAM,EAChC,OAAO,SAAS,MAAM,GAAG,MAAM,IAC7B;IACF,QAAQ,CAAC,CAAC,kBAAkB,CAAC,CAAC,EAAE,iBAAiB,CAAA;IACjD,QAAQ,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAA;IAC/B,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAA;CAC9B,CAAA;AAqFD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAC9D,IAAI,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9B,iBAAiB,CAcnB;AAED,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,SAAS,iBAAiB,EAAE,GAAG,iBAAiB,CAepG;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAElF;AAED,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,iBAAiB,GAAG,MAAM,CAE7E"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ROOT-CAPTURE POLICY of one local trivia scope, in one place.
|
|
3
|
+
*
|
|
4
|
+
* Three engines install a `parser({ trivia })` scope — the interpreter
|
|
5
|
+
* (`combinators/grammar.ts`), source lowering (`compiler/codegen.ts`) and the
|
|
6
|
+
* table (`table/assemble.ts`, `table/exec.ts`) — and each of them has to answer
|
|
7
|
+
* the same two questions about selected root trivia. The refusal below was a
|
|
8
|
+
* string literal in two of them and ABSENT from the third, which is how a table
|
|
9
|
+
* parse came to accept a grammar the other two reject.
|
|
10
|
+
*
|
|
11
|
+
* Import-free, like the rest of `cst/`, so the drivers can reach it without
|
|
12
|
+
* pulling the combinator set in.
|
|
13
|
+
*/
|
|
14
|
+
/** The message `parser()` raises for an unclassified local scope. Exported so the
|
|
15
|
+
* three engines cannot drift a word apart. */
|
|
16
|
+
export declare const ROOT_TRIVIA_SCOPE_REFUSAL = "parser(): selected root trivia requires classifiedTrivia() for every local trivia scope, or rootCapture: 'opaque'.";
|
|
17
|
+
/**
|
|
18
|
+
* Refuse a local trivia scope that cannot be reported faithfully.
|
|
19
|
+
*
|
|
20
|
+
* With selected root capture active, a scope whose trivia is not classified and
|
|
21
|
+
* is not declared opaque would silently drop the markers inside it. Throwing is
|
|
22
|
+
* the contract (`combinators/grammar.ts:98`); returning a parse that quietly
|
|
23
|
+
* omits them is the failure this exists to prevent.
|
|
24
|
+
*/
|
|
25
|
+
export declare function refuseUnclassifiedRootScope(strict: boolean | undefined): void;
|
|
26
|
+
//# sourceMappingURL=root-trivia-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-trivia-scope.d.ts","sourceRoot":"","sources":["../../src/cst/root-trivia-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;+CAC+C;AAC/C,eAAO,MAAM,yBAAyB,uHACoF,CAAA;AAE1H;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAE7E"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { LabeledTriviaSpec } from './trivia-kinds.ts';
|
|
2
|
+
export type TriviaArmMatcher = (input: string, pos: number) => number;
|
|
3
|
+
/**
|
|
4
|
+
* The character-level matchers for a spec's arms — index-parallel to `spec.arms`,
|
|
5
|
+
* so a matcher's index IS its kind index — or `null` when any arm has no lowering.
|
|
6
|
+
*
|
|
7
|
+
* `spec.minRepeats > 1` is excluded: the loops below report only an END, and a run
|
|
8
|
+
* that fails a minimum of two must report NOTHING. `classifiedTrivia()` never
|
|
9
|
+
* produces one, and the combinator path still handles it if a host writes one.
|
|
10
|
+
*/
|
|
11
|
+
export declare function charArmsFor(spec: LabeledTriviaSpec): readonly TriviaArmMatcher[] | null;
|
|
12
|
+
/** End of the trivia run at `cur`, or `cur` when nothing matched. */
|
|
13
|
+
export declare function charTriviaEnd(input: string, cur: number, arms: readonly TriviaArmMatcher[]): number;
|
|
14
|
+
/** As `charTriviaEnd`, reporting each chunk with the kind index that matched it. */
|
|
15
|
+
export declare function charTriviaVisit(input: string, cur: number, arms: readonly TriviaArmMatcher[], visit: (start: number, end: number, kindIndex: number) => void): number;
|
|
16
|
+
/** The `1 << kindIndex` mask of the categories in the run at `cur`. */
|
|
17
|
+
export declare function charTriviaKindMask(input: string, cur: number, arms: readonly TriviaArmMatcher[]): number;
|
|
18
|
+
//# sourceMappingURL=trivia-charscan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trivia-charscan.d.ts","sourceRoot":"","sources":["../../src/cst/trivia-charscan.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAE1D,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAA;AAyMrE;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAwBvF;AAED,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,gBAAgB,EAAE,GAAG,MAAM,CAWnG;AAED,oFAAoF;AACpF,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,SAAS,gBAAgB,EAAE,EACjC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,GAC7D,MAAM,CAWR;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,gBAAgB,EAAE,GAAG,MAAM,CAYxG"}
|
|
@@ -63,5 +63,24 @@ export declare function recordTriviaChunks(ctx: ParseContext, chunks: readonly T
|
|
|
63
63
|
* unaffected either way). If you expect comments and get an empty per-node log,
|
|
64
64
|
* check the name against the grammar's `triviaKindLabels`.
|
|
65
65
|
*/
|
|
66
|
+
/**
|
|
67
|
+
* Resolve an ADJACENCY kind filter against the ACTIVE trivia table — the strict
|
|
68
|
+
* counterpart of `triviaKindMask` below.
|
|
69
|
+
*
|
|
70
|
+
* Deliberately NOT lenient. `triviaKindMask` is a capture preference, where an
|
|
71
|
+
* unknown name is a legitimate cross-dialect no-op; this is a RECOGNITION
|
|
72
|
+
* constraint, and a silently-dropped name turns `notAdjacent({kinds:['whitespace']})`
|
|
73
|
+
* into a bare `notAdjacent()` — i.e. `calc()` quietly accepting a comment where
|
|
74
|
+
* css-values-4 10.1 demands real whitespace, the exact defect the filter exists to
|
|
75
|
+
* prevent. Both failure modes are hard errors.
|
|
76
|
+
*/
|
|
77
|
+
export declare function resolveAdjacencyKindMask(trivia: Combinator<unknown> | undefined, kinds: readonly string[]): number;
|
|
78
|
+
/**
|
|
79
|
+
* Bitmask of the trivia CATEGORIES occurring in the run starting at `pos`
|
|
80
|
+
* (`1 << kindIndex` per matched chunk); `0` when no trivia is there at all.
|
|
81
|
+
* The single source of truth for the interpreter's adjacency kind test — the
|
|
82
|
+
* compiled probe (`_akN`) mirrors this loop arm for arm.
|
|
83
|
+
*/
|
|
84
|
+
export declare function triviaKindMaskAt(input: string, pos: number, spec: LabeledTriviaSpec, state?: unknown): number;
|
|
66
85
|
export declare function triviaKindMask(labels: readonly string[] | undefined, keep: readonly string[]): number | undefined;
|
|
67
86
|
//# sourceMappingURL=trivia-kinds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trivia-kinds.d.ts","sourceRoot":"","sources":["../../src/cst/trivia-kinds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"trivia-kinds.d.ts","sourceRoot":"","sources":["../../src/cst/trivia-kinds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAM3D,MAAM,MAAM,WAAW,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC,CAAA;IAC/F,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B,CAAA;AA+BD,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,CAAA;CAAE,GAAG,IAAI,CAGvG;AAED;;;GAGG;AACH,wBAAgB,oBA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AG,EAAE,MAAM,EACX,IAAI,EAAE,iBAAiB,EACvB,KAAK,CAAC,EAAE,OAAO,GACd,MAAM,CAoBR;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EACrC,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,MAAM,GAAG,SAAS,CAQpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/functional/doc.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAmB,MAAM,aAAa,CAAA;AACrG,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../src/functional/doc.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAmB,MAAM,aAAa,CAAA;AACrG,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AA4BlE,qFAAqF;AACrF,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,CAAA;AAEzF;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;AA2HnE,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,QAAQ,IAAI;IAChD,wEAAwE;IACxE,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;;;OAIG;IACH,OA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G,IAAI,CAExE;AAqDD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,QAAQ,EACzC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,eAAe,CAAC,CAAC,CAAM,GAC5B,QAAQ,CAAC,CAAC,CAAC,CAqBb"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Runnable, type RunOptions, type RunResult } from './run.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Run a grammar against an input.
|
|
4
|
+
*
|
|
5
|
+
* Identical contract to `parseman/run`'s `run()`, with one difference that is
|
|
6
|
+
* the point of this module: a COMBINATOR entry is lowered to a table and the
|
|
7
|
+
* table is what parses. `options.trivia` is lowered the same way — it is a parse
|
|
8
|
+
* of the same grammar and would otherwise be the one place the interpreter still
|
|
9
|
+
* ran on the product path.
|
|
10
|
+
*/
|
|
11
|
+
export declare function run(entry: Runnable, input: string, options?: RunOptions): RunResult;
|
|
12
|
+
//# sourceMappingURL=run-tabled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-tabled.d.ts","sourceRoot":"","sources":["../../src/functional/run-tabled.ts"],"names":[],"mappings":"AA2CA,OAAO,EAAoB,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAA;AAwF3F;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,GAAG,SAAS,CAYvF"}
|
package/dist/functional/run.d.ts
CHANGED
|
@@ -17,7 +17,10 @@ import { type RootTriviaIndex } from '../cst/trivia-entries.ts';
|
|
|
17
17
|
export type Runnable = ((input: string, pos: number, ctx: ParseContext) => ParseResult<unknown>) | Combinator<unknown>;
|
|
18
18
|
export type RunOptions = {
|
|
19
19
|
/** Optional hooks for a coverage-enabled compiled or macro parser. Ordinary
|
|
20
|
-
* parses omit this completely, so instrumentation has no normal-path cost.
|
|
20
|
+
* parses omit this completely, so instrumentation has no normal-path cost.
|
|
21
|
+
* Table-backed 0.47 artifacts support `_grammarCoverage` but reject
|
|
22
|
+
* `_grammarTrace` explicitly; interpreted/source-lowered entries may support
|
|
23
|
+
* both. */
|
|
21
24
|
instrumentation?: {
|
|
22
25
|
_grammarCoverage?: (id: string) => void;
|
|
23
26
|
_grammarTrace?: {
|
|
@@ -35,14 +38,23 @@ export type RunOptions = {
|
|
|
35
38
|
/** Initial grammar state threaded into `ctx.state`. */
|
|
36
39
|
state?: unknown;
|
|
37
40
|
/**
|
|
38
|
-
* The grammar's trivia rule
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
41
|
+
* The grammar's trivia rule — an OVERRIDE, no longer a requirement.
|
|
42
|
+
*
|
|
43
|
+
* A root rule consumes trivia BETWEEN terms but not after the last one, so
|
|
44
|
+
* trailing whitespace/comments would otherwise look like unparsed input. `run`
|
|
45
|
+
* skips that tail before computing `unconsumedFrom` and before reporting
|
|
46
|
+
* `span`, so only real leftover is reported.
|
|
47
|
+
*
|
|
48
|
+
* The trivia used is the ENTRY's own ambient trivia — whatever
|
|
49
|
+
* `rules({ trivia })` / `parser({ trivia })` declared — resolved automatically
|
|
50
|
+
* (see `ambientTriviaFromRunnable`). Pass this only to use a DIFFERENT trivia
|
|
51
|
+
* for the document tail than the grammar parses with; it wins when given.
|
|
52
|
+
* Passing the grammar's own trivia is now a no-op, and remains supported.
|
|
53
|
+
*
|
|
54
|
+
* Either way it encodes dialect differences for free: CSS trivia leaves a
|
|
55
|
+
* trailing `//` as leftover, Less trivia (which treats `//` as a line comment)
|
|
56
|
+
* does not. An UNTERMINATED comment (which the trivia rule won't match)
|
|
57
|
+
* surfaces at its start.
|
|
46
58
|
*/
|
|
47
59
|
trivia?: Runnable;
|
|
48
60
|
/**
|
|
@@ -73,15 +85,6 @@ export type RunOptions = {
|
|
|
73
85
|
* fails, so none of the machinery runs.
|
|
74
86
|
*/
|
|
75
87
|
tolerant?: boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Run three compiled-parser-only profiling passes: recognizer (no global
|
|
78
|
-
* sinks), structural capture without the host, then the normal host path. This
|
|
79
|
-
* is a measurement boundary, not a parser mode; ordinary `run()` output is
|
|
80
|
-
* unchanged when omitted. The input is parsed THREE times — each pass gets its
|
|
81
|
-
* own shallow copy of `options.state`, so keep per-parse state shallow (only
|
|
82
|
-
* the top level is isolated between passes).
|
|
83
|
-
*/
|
|
84
|
-
profile?: boolean;
|
|
85
88
|
};
|
|
86
89
|
export type RootTriviaCapture = {
|
|
87
90
|
/** Packed `[gapStart, gapEnd, markerStart, markerEnd, selectedKindIndex]` rows. */
|
|
@@ -91,24 +94,6 @@ export type RootTriviaCapture = {
|
|
|
91
94
|
/** Lazy lookup over `rows`; no tokens or strings are materialized. */
|
|
92
95
|
readonly index: RootTriviaIndex;
|
|
93
96
|
};
|
|
94
|
-
export type RunProfilePass = {
|
|
95
|
-
ms: number;
|
|
96
|
-
nodes: number;
|
|
97
|
-
childSlots: number;
|
|
98
|
-
rawSlots: number;
|
|
99
|
-
triviaSlots: number;
|
|
100
|
-
fieldSlots: number;
|
|
101
|
-
hostCalls: number;
|
|
102
|
-
};
|
|
103
|
-
export type RunProfile = {
|
|
104
|
-
/** Existing `voidOf(transform(..., () => undefined))` semantics, generalized
|
|
105
|
-
* to compiled structural nodes: no `ch`/`raw`/`tl` capture or raw entries. */
|
|
106
|
-
recognizer: RunProfilePass;
|
|
107
|
-
/** Captures children/raw/trivia/fields but suppresses node construction. */
|
|
108
|
-
structuralCapture: RunProfilePass;
|
|
109
|
-
/** The ordinary parser path, including its injected build host. */
|
|
110
|
-
hostConstruction: RunProfilePass;
|
|
111
|
-
};
|
|
112
97
|
export type RunResult = {
|
|
113
98
|
ok: boolean;
|
|
114
99
|
/** The entry's value on success; undefined on failure. */
|
|
@@ -128,13 +113,11 @@ export type RunResult = {
|
|
|
128
113
|
*/
|
|
129
114
|
rootTrivia?: RootTriviaCapture;
|
|
130
115
|
/** Offset where unparsed input begins — the first non-trivia character the parse
|
|
131
|
-
* left unconsumed (
|
|
132
|
-
* the whole input was consumed. This is how you
|
|
133
|
-
* there's junk here". Only meaningful on
|
|
134
|
-
* `span`/`expected`. */
|
|
116
|
+
* left unconsumed (the document's trailing trivia is always skipped; see
|
|
117
|
+
* `RunOptions.trivia`), or null if the whole input was consumed. This is how you
|
|
118
|
+
* detect "the grammar stopped short, there's junk here". Only meaningful on
|
|
119
|
+
* success — a failed parse reports its own `span`/`expected`. */
|
|
135
120
|
unconsumedFrom: number | null;
|
|
136
|
-
/** Present only when `RunOptions.profile` is true. */
|
|
137
|
-
profile?: RunProfile;
|
|
138
121
|
};
|
|
139
122
|
export declare function run(entry: Runnable, input: string, options?: RunOptions): RunResult;
|
|
140
123
|
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/functional/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/functional/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAQ,MAAM,aAAa,CAAA;AAG1F,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAMrF;;;;;;;;;;;;GAYG;AAEH,+EAA+E;AAC/E,MAAM,MAAM,QAAQ,GAChB,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,KAAK,WAAW,CAAC,OAAO,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