parseman 0.40.0 → 0.42.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 +7 -6
- package/dist/combinators/expect.d.ts.map +1 -1
- package/dist/combinators/grammar.d.ts.map +1 -1
- package/dist/combinators/literal.d.ts.map +1 -1
- package/dist/combinators/node.d.ts.map +1 -1
- package/dist/combinators/regex.d.ts.map +1 -1
- package/dist/combinators/scanTo.d.ts.map +1 -1
- package/dist/combinators/trivia-skip.d.ts.map +1 -1
- package/dist/compiler/codegen.d.ts +3 -0
- package/dist/compiler/codegen.d.ts.map +1 -1
- package/dist/compiler/inline-build.d.ts +1 -1
- package/dist/compiler/inline-build.d.ts.map +1 -1
- package/dist/compiler/inline-callback.d.ts +9 -0
- package/dist/compiler/inline-callback.d.ts.map +1 -1
- package/dist/compiler/line-index.d.ts +1 -15
- package/dist/compiler/line-index.d.ts.map +1 -1
- package/dist/compiler/value-usage.d.ts.map +1 -1
- package/dist/cst/capture-buffer.d.ts.map +1 -1
- package/dist/cst/trivia-entries.d.ts +52 -0
- package/dist/cst/trivia-entries.d.ts.map +1 -1
- package/dist/functional/run.d.ts +11 -2
- package/dist/functional/run.d.ts.map +1 -1
- package/dist/index.cjs +634 -169
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +634 -169
- package/dist/index.js.map +4 -4
- package/dist/language-service/index.cjs +203 -4
- package/dist/language-service/index.cjs.map +4 -4
- package/dist/language-service/index.js +203 -4
- package/dist/language-service/index.js.map +4 -4
- package/dist/line-index.d.ts +41 -0
- package/dist/line-index.d.ts.map +1 -0
- package/dist/plugin/index.cjs +454 -126
- package/dist/plugin/index.cjs.map +4 -4
- package/dist/plugin/index.js +454 -126
- package/dist/plugin/index.js.map +4 -4
- package/dist/recovery/scan.d.ts.map +1 -1
- package/dist/regex/first-set.d.ts.map +1 -1
- package/dist/run/index.cjs +202 -2
- package/dist/run/index.cjs.map +4 -4
- package/dist/run/index.d.ts +8 -4
- package/dist/run/index.d.ts.map +1 -1
- package/dist/run/index.js +202 -2
- package/dist/run/index.js.map +4 -4
- package/dist/spec/index.cjs +174 -52
- package/dist/spec/index.cjs.map +4 -4
- package/dist/spec/index.js +174 -52
- package/dist/spec/index.js.map +4 -4
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Span } from './types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Precomputed index of newline positions for O(log n) offset->line/col lookup.
|
|
4
|
+
* lineStarts[i] is the byte offset of the first character on line i+1.
|
|
5
|
+
*/
|
|
6
|
+
export type LineIndex = {
|
|
7
|
+
lineStarts: number[];
|
|
8
|
+
};
|
|
9
|
+
type LineTrackingContext = {
|
|
10
|
+
trackLines?: boolean | undefined;
|
|
11
|
+
_lineIndex?: LineIndex | undefined;
|
|
12
|
+
_lineStarts?: number[] | undefined;
|
|
13
|
+
_lineScannedTo?: number | undefined;
|
|
14
|
+
};
|
|
15
|
+
export declare function createLineIndex(): LineIndex;
|
|
16
|
+
export declare function buildLineIndex(input: string): LineIndex;
|
|
17
|
+
/**
|
|
18
|
+
* Record newline offsets for a matched range. Intended for optional parsers that
|
|
19
|
+
* collect line starts while they consume terminals. The collector is deliberately
|
|
20
|
+
* append-only: speculative parses never roll it back. Normalize once at the
|
|
21
|
+
* driver boundary before doing offset->line/column lookup.
|
|
22
|
+
*/
|
|
23
|
+
export declare function recordLineRange(index: LineIndex, input: string, start: number, end: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* Records newlines from the context high-water mark through `end`. The start
|
|
26
|
+
* argument is only a caller hint: append-only tracking uses `_lineScannedTo` so
|
|
27
|
+
* overlapping calls can backfill gaps without double-scanning committed ranges.
|
|
28
|
+
*/
|
|
29
|
+
export declare function recordLineRangeFromContext(ctx: LineTrackingContext, input: string, _startHint: number, end: number): void;
|
|
30
|
+
export declare function normalizeLineIndex(index: LineIndex): LineIndex;
|
|
31
|
+
export declare function offsetToLineCol(index: LineIndex, offset: number): {
|
|
32
|
+
line: number;
|
|
33
|
+
col: number;
|
|
34
|
+
};
|
|
35
|
+
/** Fills startLine/startColumn/endLine/endColumn on a span in-place. */
|
|
36
|
+
export declare function annotateSpan(span: Span, index: LineIndex): Span;
|
|
37
|
+
export declare function annotateSpanFromLineContext(span: Span, ctx: LineTrackingContext): Span;
|
|
38
|
+
/** Annotate every span-shaped object reachable from a parse result value. */
|
|
39
|
+
export declare function annotateTreeSpans<T>(value: T, index: LineIndex, seen?: WeakSet<object>): T;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=line-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-index.d.ts","sourceRoot":"","sources":["../src/line-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG;IAAE,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAAA;AAChD,KAAK,mBAAmB,GAAG;IACzB,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAChC,UAAU,CAAC,EAAE,SAAS,GAAG,SAAS,CAAA;IAClC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;IAClC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACpC,CAAA;AAED,wBAAgB,eAAe,IAAI,SAAS,CAE3C;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAMvD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAKjG;AAED;;;;GAI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