import type { Span } from './types.ts'; /** * Precomputed index of newline positions for O(log n) offset->line/col lookup. * lineStarts[i] is the byte offset of the first character on line i+1. */ export type LineIndex = { lineStarts: number[]; }; type LineTrackingContext = { trackLines?: boolean | undefined; _lineIndex?: LineIndex | undefined; _lineStarts?: number[] | undefined; _lineScannedTo?: number | undefined; }; export declare function createLineIndex(): LineIndex; export declare function buildLineIndex(input: string): LineIndex; /** * Record newline offsets for a matched range. Intended for optional parsers that * collect line starts while they consume terminals. The collector is deliberately * append-only: speculative parses never roll it back. Normalize once at the * driver boundary before doing offset->line/column lookup. */ export declare function recordLineRange(index: LineIndex, input: string, start: number, end: number): void; /** * Records newlines from the context high-water mark through `end`. The start * argument is only a caller hint: append-only tracking uses `_lineScannedTo` so * overlapping calls can backfill gaps without double-scanning committed ranges. */ export declare function recordLineRangeFromContext(ctx: LineTrackingContext, input: string, _startHint: number, end: number): void; export declare function normalizeLineIndex(index: LineIndex): LineIndex; export declare function offsetToLineCol(index: LineIndex, offset: number): { line: number; col: number; }; /** Fills startLine/startColumn/endLine/endColumn on a span in-place. */ export declare function annotateSpan(span: Span, index: LineIndex): Span; export declare function annotateSpanFromLineContext(span: Span, ctx: LineTrackingContext): Span; /** Annotate every span-shaped object reachable from a parse result value. */ export declare function annotateTreeSpans(value: T, index: LineIndex, seen?: WeakSet): T; export {}; //# sourceMappingURL=line-index.d.ts.map