import type { Span } from '../span/index.js'; /** A place in the source, one-based on both axes. See the span module on columns. */ export interface SourcePosition { readonly line: number; readonly column: number; } /** * A file the compiler is working on: its normalised text, and the index that * turns an offset into a line and a column. * * Every stage needs the same two answers, and computing them by scanning from * the top of the file each time is how a compiler becomes quadratic on the one * input that has many diagnostics. The line starts are built once. */ export interface SourceFile { /** What the file is called, for the first line of a rendered diagnostic. */ readonly name: string; /** The text after normalisation. Offsets and spans index this, not the bytes on disk. */ readonly text: string; readonly lineCount: number; /** The line's text, without its newline. An out of range line is empty. */ lineText(line: number): string; /** The offset the line starts at. */ lineStart(line: number): number; positionAt(offset: number): SourcePosition; offsetAt(position: SourcePosition): number; /** The span covering length code units from offset, with its line and column worked out. */ spanAt(offset: number, length: number): Span; } /** * Drops a leading byte order mark and turns CRLF into LF, which language.md 3.1 * requires to happen before anything else reads the file, so that a script * written on one operating system compiles identically on another. * * A lone carriage return is deliberately left alone. It is not a line ending * the language accepts, so it belongs to the lexer as OS1001 on the character * rather than being silently repaired here. */ export declare function normaliseSource(raw: string): string; export declare function sourceFile(name: string, raw: string): SourceFile; //# sourceMappingURL=source.d.ts.map