parseman 0.55.4 → 0.56.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/choice-cost.d.ts.map +1 -1
- package/dist/analysis/commitment.d.ts.map +1 -1
- package/dist/analysis/diagnostics.js +3353 -3095
- package/dist/analysis/diagnostics.js.map +3 -3
- package/dist/analysis/duplication.d.ts.map +1 -1
- package/dist/analysis/gating.d.ts.map +1 -1
- package/dist/cli/index.js +1813 -1555
- package/dist/cli/index.js.map +3 -3
- package/dist/combinators/attempt.d.ts.map +1 -1
- package/dist/combinators/choice.d.ts.map +1 -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/lines.d.ts +79 -0
- package/dist/combinators/lines.d.ts.map +1 -0
- package/dist/combinators/trivia-skip.d.ts +1 -0
- package/dist/combinators/trivia-skip.d.ts.map +1 -1
- package/dist/compiler/fields.d.ts.map +1 -1
- package/dist/compiler/grammar-coverage-ids.d.ts.map +1 -1
- package/dist/compiler/ir-serialize.d.ts.map +1 -1
- package/dist/compiler/token-alphabet.d.ts.map +1 -1
- package/dist/compiler/token-capability.js +25 -0
- package/dist/compiler/token-capability.js.map +1 -1
- package/dist/coverage.d.ts.map +1 -1
- package/dist/cst/reflection.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1905 -1625
- package/dist/index.js.map +3 -3
- package/dist/language-service/index.js +2 -0
- package/dist/language-service/index.js.map +1 -1
- package/dist/parse-context.d.ts.map +1 -1
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/index.js +1318 -1045
- package/dist/plugin/index.js.map +3 -3
- package/dist/plugin/ir-eval.d.ts +0 -4
- package/dist/plugin/ir-eval.d.ts.map +1 -1
- package/dist/run/index.js +2 -0
- package/dist/run/index.js.map +1 -1
- package/dist/spec/index.js +15 -0
- package/dist/spec/index.js.map +1 -1
- package/dist/spec/model.d.ts.map +1 -1
- package/dist/table/assemble.d.ts +0 -65
- package/dist/table/assemble.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 +3442 -3192
- package/dist/table/index.js.map +3 -3
- package/dist/table/line-scan.d.ts +9 -0
- package/dist/table/line-scan.d.ts.map +1 -0
- package/dist/table/program.d.ts +11 -2
- package/dist/table/program.d.ts.map +1 -1
- package/dist/types.d.ts +21 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/analysis/choice-cost.ts +1 -0
- package/src/analysis/commitment.ts +13 -0
- package/src/analysis/duplication.ts +3 -0
- package/src/analysis/gating.ts +5 -0
- package/src/analysis/rebuild.ts +2 -2
- package/src/combinators/attempt.ts +2 -0
- package/src/combinators/choice.ts +3 -0
- package/src/combinators/dispatch.ts +3 -0
- package/src/combinators/expect.ts +5 -0
- package/src/combinators/first-set.ts +9 -1
- package/src/combinators/lines.ts +244 -0
- package/src/combinators/trivia-skip.ts +4 -2
- package/src/compiler/fields.ts +3 -0
- package/src/compiler/grammar-coverage-ids.ts +1 -0
- package/src/compiler/ir-serialize.ts +10 -0
- package/src/compiler/token-alphabet.ts +3 -1
- package/src/coverage.ts +6 -0
- package/src/cst/reflection.ts +3 -0
- package/src/index.ts +2 -0
- package/src/parse-context.ts +2 -0
- package/src/plugin/evaluator.ts +4 -0
- package/src/plugin/ir-eval.ts +3 -0
- package/src/spec/model.ts +15 -0
- package/src/table/assemble.ts +6 -12
- package/src/table/emit.ts +7 -6
- package/src/table/encode.ts +18 -6
- package/src/table/exec.ts +3 -0
- package/src/table/line-scan.ts +19 -0
- package/src/table/program.ts +17 -2
- package/src/types.ts +14 -0
- package/src/version.ts +1 -1
package/src/table/program.ts
CHANGED
|
@@ -241,13 +241,13 @@ export type SubtreeRef = readonly [ip: number, cls: number]
|
|
|
241
241
|
/**
|
|
242
242
|
* A scanning construct as its CONSTRUCTOR ARGUMENTS.
|
|
243
243
|
*
|
|
244
|
-
* `kind` 0 is `scanTo`, 1 is `balanced`. `flags` bit 0 = `raw`, bit 1 = `orEOF`
|
|
244
|
+
* `kind` 0 is `scanTo`, 1 is `balanced`, 2 is `lines`, 3 is `columns`. `flags` bit 0 = `raw`, bit 1 = `orEOF`
|
|
245
245
|
* (scanTo), bit 2 = `strict` (balanced). `sent` is the sentinel's literal text
|
|
246
246
|
* when it is a `literal()`, so the rebuilt scan reports the same expected set as
|
|
247
247
|
* the interpreter, and `null` otherwise (which reports `"sentinel"`).
|
|
248
248
|
*/
|
|
249
249
|
export type ScanSpec = {
|
|
250
|
-
readonly kind: 0 | 1
|
|
250
|
+
readonly kind: 0 | 1 | 2 | 3
|
|
251
251
|
readonly flags: number
|
|
252
252
|
readonly skip: readonly SubtreeRef[]
|
|
253
253
|
readonly sentinel?: SubtreeRef
|
|
@@ -256,6 +256,21 @@ export type ScanSpec = {
|
|
|
256
256
|
readonly sent?: string | null
|
|
257
257
|
readonly open?: string
|
|
258
258
|
readonly close?: string
|
|
259
|
+
/** `lines()` (kind 2): the continuation prefix, the body, and the optional first-line prefix and lazy check. */
|
|
260
|
+
readonly prefix?: SubtreeRef
|
|
261
|
+
readonly body?: SubtreeRef
|
|
262
|
+
readonly first?: SubtreeRef
|
|
263
|
+
readonly lazy?: SubtreeRef
|
|
264
|
+
/** `columns()` (kind 3): the column count. */
|
|
265
|
+
readonly n?: number
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** Every subtree a scan spec references, which the table links as roots. */
|
|
269
|
+
export function scanRefs(s: ScanSpec): SubtreeRef[] {
|
|
270
|
+
const refs: SubtreeRef[] = []
|
|
271
|
+
for (const r of [s.sentinel, s.recoverAt, s.stopAt, s.prefix, s.body, s.first, s.lazy]) if (r !== undefined) refs.push(r)
|
|
272
|
+
refs.push(...s.skip)
|
|
273
|
+
return refs
|
|
259
274
|
}
|
|
260
275
|
|
|
261
276
|
/** A trivia combinator as data. `arms` empty means a plain `trivia(regex)`. */
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LineView } from './combinators/lines.ts'
|
|
1
2
|
import type { LabeledTriviaSpec } from './cst/trivia-kinds.ts'
|
|
2
3
|
|
|
3
4
|
export type Span = {
|
|
@@ -113,6 +114,11 @@ export type ParserDef =
|
|
|
113
114
|
// pre-ambient raw byte-walk.
|
|
114
115
|
| { tag: 'scanTo'; sentinel: Combinator<unknown>; skip: Combinator<unknown>[]; raw: boolean; orEOF: boolean; recoverAt?: Combinator<unknown>; stopAt?: Combinator<unknown> }
|
|
115
116
|
| { tag: 'keywords'; words: readonly string[]; caseInsensitive: boolean; boundary: string | undefined }
|
|
117
|
+
// `lines()`: `body` parses a run of lines with `prefix` (`first` on the first
|
|
118
|
+
// line) removed from each; `lazy` admits a line the prefix does not match.
|
|
119
|
+
| { tag: 'lines'; prefix: Combinator<unknown>; body: Combinator<unknown>; first?: Combinator<unknown>; lazy?: Combinator<unknown> }
|
|
120
|
+
// `columns(n)`: n columns of indentation, a tab reaching the next stop of four.
|
|
121
|
+
| { tag: 'columns'; n: number }
|
|
116
122
|
| { tag: 'unknown' }
|
|
117
123
|
|
|
118
124
|
export type Combinator<T> = {
|
|
@@ -280,6 +286,14 @@ export type ParseContext = {
|
|
|
280
286
|
trackLines: boolean
|
|
281
287
|
/** Grammar-author-provided state, scoped with withCtx() and read in guard(). */
|
|
282
288
|
state?: unknown
|
|
289
|
+
/**
|
|
290
|
+
* Inside a `lines()` body, the run's lines: where each line's content sits in
|
|
291
|
+
* the body's input and in the run's own input, and the column it starts at.
|
|
292
|
+
* Undefined outside any run.
|
|
293
|
+
*/
|
|
294
|
+
lineView?: LineView | undefined
|
|
295
|
+
/** Framework-internal: where `columns()` last stopped inside a tab, for `lines()`. */
|
|
296
|
+
_columnsSplit?: { at: number; split: number } | undefined
|
|
283
297
|
/**
|
|
284
298
|
* Mode host (RULE_ABI_PLAN §7): when set, a linkable/fused grammar's `node()`
|
|
285
299
|
* rules build via `build(type, children, fields, span, rawChildren, triviaLog, state)`
|
package/src/version.ts
CHANGED