parseman 0.47.1 → 0.48.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -21
- package/dist/analysis/diagnostics.js +2964 -347
- package/dist/analysis/diagnostics.js.map +3 -3
- package/dist/cli/index.js +2960 -343
- package/dist/cli/index.js.map +3 -3
- package/dist/combinators/choice.d.ts.map +1 -1
- package/dist/combinators/expect.d.ts +1 -0
- package/dist/combinators/expect.d.ts.map +1 -1
- package/dist/combinators/expected.d.ts +8 -0
- package/dist/combinators/expected.d.ts.map +1 -0
- package/dist/combinators/first-set.d.ts +8 -0
- package/dist/combinators/first-set.d.ts.map +1 -1
- package/dist/combinators/grammar.d.ts.map +1 -1
- package/dist/combinators/keywords.d.ts +4 -0
- package/dist/combinators/keywords.d.ts.map +1 -1
- package/dist/combinators/literal.d.ts.map +1 -1
- package/dist/combinators/not.d.ts.map +1 -1
- package/dist/combinators/peek.d.ts.map +1 -1
- package/dist/combinators/regex.d.ts.map +1 -1
- package/dist/combinators/repeat.d.ts.map +1 -1
- package/dist/combinators/sequence.d.ts.map +1 -1
- package/dist/combinators/trivia-skip.d.ts +16 -3
- package/dist/combinators/trivia-skip.d.ts.map +1 -1
- package/dist/compiler/direct-projection.d.ts +12 -0
- package/dist/compiler/direct-projection.d.ts.map +1 -0
- package/dist/compiler/token-alphabet.d.ts +845 -5
- package/dist/compiler/token-alphabet.d.ts.map +1 -1
- package/dist/compiler/token-capability.d.ts +3 -0
- package/dist/compiler/token-capability.d.ts.map +1 -0
- package/dist/compiler/token-capability.js +3192 -0
- package/dist/compiler/token-capability.js.map +6 -0
- package/dist/cst/trivia-charscan.d.ts +3 -0
- package/dist/cst/trivia-charscan.d.ts.map +1 -1
- package/dist/cst/trivia-css-scanner.d.ts +5 -0
- package/dist/cst/trivia-css-scanner.d.ts.map +1 -0
- package/dist/cst/trivia-kinds.d.ts.map +1 -1
- package/dist/index.js +2973 -343
- package/dist/index.js.map +3 -3
- package/dist/language-service/index.js +5 -1
- package/dist/language-service/index.js.map +1 -1
- package/dist/plugin/index.js +2982 -352
- package/dist/plugin/index.js.map +3 -3
- package/dist/spec/index.js +325 -47
- package/dist/spec/index.js.map +3 -3
- package/dist/table/assemble.d.ts.map +1 -1
- package/dist/table/child-slots.d.ts.map +1 -1
- package/dist/table/compile-rule-map.d.ts +3 -1
- package/dist/table/compile-rule-map.d.ts.map +1 -1
- package/dist/table/emit-assembly.d.ts +12 -13
- package/dist/table/emit-assembly.d.ts.map +1 -1
- package/dist/table/emit.d.ts.map +1 -1
- package/dist/table/encode.d.ts.map +1 -1
- package/dist/table/exec-baseline.d.ts.map +1 -1
- package/dist/table/exec.d.ts.map +1 -1
- package/dist/table/index.js +2937 -311
- package/dist/table/index.js.map +3 -3
- package/dist/table/lex-body.d.ts +9 -0
- package/dist/table/lex-body.d.ts.map +1 -0
- package/dist/table/lex-program.d.ts +25 -0
- package/dist/table/lex-program.d.ts.map +1 -0
- package/dist/table/ops.d.ts +47 -11
- package/dist/table/ops.d.ts.map +1 -1
- package/dist/table/program.d.ts +50 -2
- package/dist/table/program.d.ts.map +1 -1
- package/dist/table/scalar-terminal.d.ts +13 -0
- package/dist/table/scalar-terminal.d.ts.map +1 -0
- package/dist/table/site-labels.d.ts.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +11 -11
- package/src/combinators/choice.ts +10 -1
- package/src/combinators/expect.ts +1 -0
- package/src/combinators/expected.ts +17 -0
- package/src/combinators/first-set.ts +58 -5
- package/src/combinators/grammar.ts +8 -3
- package/src/combinators/keywords.ts +22 -6
- package/src/combinators/literal.ts +2 -1
- package/src/combinators/not.ts +5 -1
- package/src/combinators/peek.ts +5 -1
- package/src/combinators/regex.ts +5 -3
- package/src/combinators/repeat.ts +4 -10
- package/src/combinators/sequence.ts +17 -14
- package/src/combinators/trivia-skip.ts +46 -13
- package/src/compiler/direct-projection.ts +43 -0
- package/src/compiler/token-alphabet.ts +4316 -12
- package/src/compiler/token-capability.ts +6 -0
- package/src/cst/trivia-charscan.ts +34 -0
- package/src/cst/trivia-css-scanner.ts +142 -0
- package/src/cst/trivia-kinds.ts +3 -1
- package/src/plugin/index.ts +4 -4
- package/src/table/assemble.ts +1253 -240
- package/src/table/child-slots.ts +2 -1
- package/src/table/compile-rule-map.ts +21 -3
- package/src/table/emit-assembly.ts +335 -87
- package/src/table/emit.ts +16 -2
- package/src/table/encode.ts +248 -60
- package/src/table/exec-baseline.ts +3 -7
- package/src/table/exec.ts +134 -25
- package/src/table/lex-body.ts +30 -0
- package/src/table/lex-program.ts +431 -0
- package/src/table/ops.ts +49 -11
- package/src/table/program.ts +46 -2
- package/src/table/scalar-terminal.ts +51 -0
- package/src/table/site-labels.ts +11 -1
- package/src/table/stamp.ts +1 -1
- package/src/types.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/analysis/diagnostics.cjs +0 -13824
- package/dist/analysis/diagnostics.cjs.map +0 -6
- package/dist/cli/index.cjs +0 -14925
- package/dist/cli/index.cjs.map +0 -6
- package/dist/index.cjs +0 -16391
- package/dist/index.cjs.map +0 -6
- package/dist/language-service/index.cjs +0 -1304
- package/dist/language-service/index.cjs.map +0 -6
- package/dist/oracle/index.cjs +0 -254
- package/dist/oracle/index.cjs.map +0 -6
- package/dist/plugin/index.cjs +0 -16097
- package/dist/plugin/index.cjs.map +0 -6
- package/dist/run/index.cjs +0 -577
- package/dist/run/index.cjs.map +0 -6
- package/dist/spec/index.cjs +0 -6236
- package/dist/spec/index.cjs.map +0 -6
- package/dist/table/index.cjs +0 -11463
- package/dist/table/index.cjs.map +0 -6
package/src/table/child-slots.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
OP_LIT_CI_TRACK, OP_LIT_TRACK, OP_LIVE, OP_NODE, OP_NODE_TRACK, OP_NOT, OP_OPT,
|
|
5
5
|
OP_PEEK, OP_REJECT, OP_REP, OP_REPV, OP_ROUTED, OP_RULE, OP_RX, OP_RX_TRACK, OP_SCAN,
|
|
6
6
|
OP_SCOPE, OP_SCOPE_CAP, OP_SCOPE_PLAIN, OP_SEQ, OP_SEQV, OP_SEQX, OP_TOKEN, OP_WITHCTX, OP_XFORM,
|
|
7
|
+
OP_LEX_BODY, OP_LEX_PROGRAM,
|
|
7
8
|
} from './ops.ts'
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -41,7 +42,7 @@ export function childSlots(code: ArrayLike<number>, ip: number, out: number[]):
|
|
|
41
42
|
// structure is a closure, so there is no successor row to reach.
|
|
42
43
|
case OP_LIT: case OP_RX: case OP_LIT_TRACK: case OP_RX_TRACK: case OP_EMPTY:
|
|
43
44
|
case OP_SCAN: case OP_LIT_CI: case OP_LIT_CI_TRACK:
|
|
44
|
-
case OP_GUARD: case OP_ADJ: case OP_LIVE:
|
|
45
|
+
case OP_GUARD: case OP_ADJ: case OP_LIVE: case OP_LEX_BODY: case OP_LEX_PROGRAM:
|
|
45
46
|
return true
|
|
46
47
|
|
|
47
48
|
// Single child at `ip + 1`. `OP_COV` is a wrapper on the same footing as the
|
|
@@ -3,13 +3,21 @@ import { hasDirectBuildDef } from '../analysis/commitment.ts'
|
|
|
3
3
|
import type { HostMode } from '../cst/host-mode.ts'
|
|
4
4
|
import { collectGrammarReflection, type GrammarReflection } from '../cst/reflection.ts'
|
|
5
5
|
import { encodeTableProgram, type TableSettings } from './encode.ts'
|
|
6
|
-
import { emitTableExpression } from './emit.ts'
|
|
6
|
+
import { defaultAssemblyCfgs, emitTableExpression } from './emit.ts'
|
|
7
7
|
import { tableRules } from './assemble.ts'
|
|
8
8
|
import { closureArtifact } from './program.ts'
|
|
9
9
|
import type { TableProgram, TableRule } from './program.ts'
|
|
10
10
|
import { buildGrammarPlan, type GrammarCoverageDefinition } from '../compiler/grammar-coverage-ids.ts'
|
|
11
11
|
import { runDuplicationDiagnosticRules, type DuplicationOption } from './duplication-hook.ts'
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Static assembly has a fixed source cost that tiny grammars cannot amortize.
|
|
15
|
+
* The canonical size probe's composeLeaf is 62 words and grows by ~12 kB with
|
|
16
|
+
* a factory; the shipping Jess leaves are 6,365/10,892 words. Keep the policy
|
|
17
|
+
* between those measured populations so small artifacts retain table density.
|
|
18
|
+
*/
|
|
19
|
+
const DEFAULT_PRECOMPILE_MIN_WORDS = 1_024
|
|
20
|
+
|
|
13
21
|
/**
|
|
14
22
|
* `compileRuleMap()` FOR THE TABLE LOWERING — the counterpart that did not exist.
|
|
15
23
|
*
|
|
@@ -100,7 +108,10 @@ export type CompiledRuleMapTable = {
|
|
|
100
108
|
/** The expression that replaces the whole `rules(factory)` call. */
|
|
101
109
|
replacement: string
|
|
102
110
|
/** Re-emit the same table call with construction-time artifact metadata. */
|
|
103
|
-
replacementWithMetadata(
|
|
111
|
+
replacementWithMetadata(
|
|
112
|
+
metadataSource: string,
|
|
113
|
+
options?: { readonly precompileDefault?: boolean },
|
|
114
|
+
): string
|
|
104
115
|
hostMode: HostMode
|
|
105
116
|
hostBranchElided: boolean
|
|
106
117
|
reflection: GrammarReflection
|
|
@@ -307,10 +318,17 @@ export function compileRuleMap(
|
|
|
307
318
|
)
|
|
308
319
|
}
|
|
309
320
|
|
|
310
|
-
const replacementWithMetadata = (
|
|
321
|
+
const replacementWithMetadata = (
|
|
322
|
+
metadataSource?: string,
|
|
323
|
+
options: { readonly precompileDefault?: boolean } = {},
|
|
324
|
+
): string => emitTableExpression(artifact, {
|
|
311
325
|
entry: null,
|
|
312
326
|
runtimeRef: opts.runtimeRef ?? 'tableRules',
|
|
313
327
|
fnSources: sources as string[],
|
|
328
|
+
...(options.precompileDefault === true && hostMode === 'ast' && prog.lines !== 1
|
|
329
|
+
&& prog.code.length >= DEFAULT_PRECOMPILE_MIN_WORDS
|
|
330
|
+
? { assemblies: defaultAssemblyCfgs(artifact).slice(0, 1) }
|
|
331
|
+
: {}),
|
|
314
332
|
...(metadataSource === undefined ? {} : { metadataSource }),
|
|
315
333
|
})
|
|
316
334
|
const replacement = replacementWithMetadata()
|