/** * Line cursor used by every diagram parser. Parsers pull lines one at a time * and may read nested blocks themselves, which keeps block handling local to * the rule that understands it. * @module syntax/reader */ export type SourceLine = import("../core/source.mjs").SourceLine; /** @typedef {import("../core/source.mjs").SourceLine} SourceLine */ /** @public */ export declare class LineReader { lines: import("../core/source.mjs").SourceLine[]; pos: number; /** @param {SourceLine[]} lines */ constructor(lines: SourceLine[]); /** @returns {boolean} */ get done(): boolean; /** @returns {SourceLine | undefined} */ peek(): SourceLine | undefined; /** @returns {SourceLine} */ next(): SourceLine; /** * Read lines until one matches `end` (consumed, not returned). * @param {RegExp} end * @returns {SourceLine[]} */ until(end: RegExp): SourceLine[]; /** * Read a `{ … }` body after an opening brace, honouring nested braces and * quotes. Returns the body lines without the closing brace line. * @returns {SourceLine[]} */ braceBlock(): SourceLine[]; } /** * Net change of brace depth on a line, ignoring quoted text. * @param {string} text * @returns {number} */ export declare function braceDelta(text: string): number; export type Rule = (line: string, ctx: C, reader: LineReader, src: SourceLine) => boolean | void; /** * Generic rule-driven line parser. Rules are tried in order; the first one * returning `true` consumes the line. Unmatched lines are reported to the * diagnostics collector. * @template C * @typedef {(line: string, ctx: C, reader: LineReader, src: SourceLine) => boolean | void} Rule */ /** * @template C * @param {SourceLine[]} lines * @param {Rule[]} rules * @param {C} ctx * @param {{ unknown: (text: string, line: number) => void }} diagnostics */ export declare function runRules(lines: SourceLine[], rules: Rule[], ctx: C, diagnostics: { unknown: (text: string, line: number) => void; }): void;