parseman 0.60.5 → 0.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analysis/diagnostics.js +77 -40
- package/dist/analysis/diagnostics.js.map +3 -3
- package/dist/cli/index.js +77 -40
- package/dist/cli/index.js.map +3 -3
- package/dist/combinators/choice.d.ts.map +1 -1
- package/dist/combinators/expect.d.ts.map +1 -1
- package/dist/combinators/link-scope.d.ts +7 -0
- package/dist/combinators/link-scope.d.ts.map +1 -0
- package/dist/combinators/node.d.ts.map +1 -1
- package/dist/combinators/parser.d.ts.map +1 -1
- package/dist/combinators/trivia-boundary.d.ts +5 -3
- package/dist/combinators/trivia-boundary.d.ts.map +1 -1
- package/dist/compiler/token-capability.js +7 -0
- package/dist/compiler/token-capability.js.map +1 -1
- package/dist/compiler/value-usage.d.ts.map +1 -1
- package/dist/functional/run.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +121 -70
- package/dist/index.js.map +3 -3
- package/dist/language-service/index.js +1 -1
- package/dist/language-service/index.js.map +1 -1
- package/dist/plugin/index.js +284 -233
- package/dist/plugin/index.js.map +3 -3
- package/dist/run/index.js +1 -1
- package/dist/run/index.js.map +1 -1
- package/dist/spec/index.js.map +1 -1
- package/dist/table/assemble.d.ts.map +1 -1
- 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.d.ts.map +1 -1
- package/dist/table/index.js +41 -10
- package/dist/table/index.js.map +3 -3
- package/dist/table/ops.d.ts +6 -0
- package/dist/table/ops.d.ts.map +1 -1
- package/dist/table/program.d.ts +3 -1
- package/dist/table/program.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/combinators/choice.ts +3 -1
- package/src/combinators/expect.ts +1 -0
- package/src/combinators/grammar.ts +1 -1
- package/src/combinators/link-scope.ts +19 -0
- package/src/combinators/node.ts +11 -2
- package/src/combinators/parser.ts +37 -31
- package/src/combinators/trivia-boundary.ts +11 -3
- package/src/compiler/value-usage.ts +16 -29
- package/src/functional/run.ts +3 -1
- package/src/index.ts +1 -1
- package/src/table/assemble.ts +11 -1
- package/src/table/emit-assembly.ts +10 -1
- package/src/table/emit.ts +5 -1
- package/src/table/encode.ts +16 -9
- package/src/table/exec.ts +11 -9
- package/src/table/ops.ts +6 -0
- package/src/table/program.ts +8 -2
- package/src/table/site-labels.ts +3 -3
- package/src/version.ts +1 -1
package/src/table/program.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { leadRanges } from '../lead-ranges.ts'
|
|
|
6
6
|
import { choice } from '../combinators/choice.ts'
|
|
7
7
|
import { many } from '../combinators/repeat.ts'
|
|
8
8
|
import type { EmittedFactory, PoolPlan } from './emit-assembly.ts'
|
|
9
|
+
import { PARSEMAN_VERSION } from '../version.ts'
|
|
9
10
|
import { buildLexBodyRecognizer, type LexBodyRecognizer } from './lex-body.ts'
|
|
10
11
|
import { buildLexProgramRunner, type LexProgramRunner } from './lex-program.ts'
|
|
11
12
|
|
|
@@ -328,7 +329,9 @@ export type CompactProgram = {
|
|
|
328
329
|
readonly c: readonly number[]
|
|
329
330
|
readonly k: readonly unknown[]
|
|
330
331
|
readonly x: readonly string[]
|
|
331
|
-
|
|
332
|
+
/** Expected sets, as indices into `es`. */
|
|
333
|
+
readonly e: readonly (readonly number[])[]
|
|
334
|
+
readonly es: readonly string[]
|
|
332
335
|
readonly d: readonly (readonly number[])[]
|
|
333
336
|
readonly r: Readonly<Record<string, number>>
|
|
334
337
|
readonly f: readonly unknown[]
|
|
@@ -351,8 +354,11 @@ export type CompactProgram = {
|
|
|
351
354
|
|
|
352
355
|
export function expandCompact(p: TableProgram | CompactProgram): TableProgram {
|
|
353
356
|
if ('code' in p) return p
|
|
357
|
+
// A table from before the token pool has no `es`. Refuse it here, at load, instead of
|
|
358
|
+
// failing on the first expected set read below.
|
|
359
|
+
if (p.es === undefined) throw new Error(`parseman: this parser was printed by an earlier parseman; reprint it with parseman ${PARSEMAN_VERSION}`)
|
|
354
360
|
return ownTableProgram({
|
|
355
|
-
code: p.c, k: p.k, cc: p.x, fx: p.e, disp: p.d, rules: p.r, fns: p.f,
|
|
361
|
+
code: p.c, k: p.k, cc: p.x, fx: p.e.map(set => set.map(i => p.es[i]!)), disp: p.d, rules: p.r, fns: p.f,
|
|
356
362
|
lines: p.l ?? 0, dsp: p.p ?? [],
|
|
357
363
|
...(p.lx === undefined ? {} : { lex: p.lx }),
|
|
358
364
|
...(p.lp === undefined ? {} : { lexPrograms: p.lp }),
|
package/src/table/site-labels.ts
CHANGED
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
import {
|
|
63
63
|
OP_ATTEMPT, OP_CHOICE, OP_DISPATCH, OP_EXPECT, OP_FIELD, OP_GATE, OP_LABEL, OP_LEAF, OP_LIT, OP_SOURCE_LEAF,
|
|
64
64
|
OP_NODE, OP_NODE_TRACK, OP_NOT, OP_OPT, OP_PEEK, OP_REP, OP_REPV, OP_ROUTED, OP_RULE,
|
|
65
|
-
OP_SCAN, OP_SCOPE, OP_SCOPE_CAP, OP_SCOPE_PLAIN, OP_SEQ, OP_SEQV, OP_SEQX, OP_TOKEN, OP_XFORM,
|
|
65
|
+
OP_SCAN, OP_SCOPE, OP_SCOPE_CAP, OP_SCOPE_PLAIN, SCOPE_INHERIT, OP_SEQ, OP_SEQV, OP_SEQX, OP_TOKEN, OP_XFORM,
|
|
66
66
|
} from './ops.ts'
|
|
67
67
|
import { childSlots } from './child-slots.ts'
|
|
68
68
|
import { leadRanges } from '../lead-ranges.ts'
|
|
@@ -206,7 +206,7 @@ function transfer(code: Int32Array, ip: number, at: SiteLabel, hostCst: boolean)
|
|
|
206
206
|
const op = code[ip]
|
|
207
207
|
if (op === OP_SCOPE || op === OP_SCOPE_CAP || op === OP_SCOPE_PLAIN) {
|
|
208
208
|
const ki = code[ip + 1]!
|
|
209
|
-
const tri = ki < 0 ? TRI_NONE : ki
|
|
209
|
+
const tri = ki === SCOPE_INHERIT ? at.tri : ki < 0 ? TRI_NONE : ki
|
|
210
210
|
// `OP_SCOPE_CAP` is an OR with the inherited context, never a switch-off
|
|
211
211
|
// (`encode.ts:1153-1158`), so it can only ever raise `cap` to `CAP_ON`.
|
|
212
212
|
const cap = op === OP_SCOPE_CAP ? CAP_ON : at.cap
|
|
@@ -358,7 +358,7 @@ export function scanHandoffNeeded(code: Int32Array, ip: number, labels: SiteLabe
|
|
|
358
358
|
const op = code[at]
|
|
359
359
|
// A scan runs interpreted combinators that reach pieces through `prog.scans`.
|
|
360
360
|
if (op === OP_SCAN) return true
|
|
361
|
-
if (op === OP_TOKEN || op === OP_SCOPE_CAP) continue
|
|
361
|
+
if (op === OP_TOKEN || (op === OP_SCOPE_CAP && code[at + 1] !== SCOPE_INHERIT)) continue
|
|
362
362
|
if ((op === OP_SCOPE_PLAIN || op === OP_SCOPE) && !(code[at + 1]! >= 0 && l.tri === code[at + 1]!
|
|
363
363
|
&& (op === OP_SCOPE_PLAIN || code[at + 3]! === 0))) continue
|
|
364
364
|
kids.length = 0
|
package/src/version.ts
CHANGED