import type { Schema } from '@idfkit/schemas'; import { IdfDocument } from '../document.js'; import type { AnyTypeMap, UntypedMap } from '../typemap.js'; import { type LexDiagnostic } from './lexer.js'; export interface ParseDiagnostic extends LexDiagnostic { /** * Object name the problem occurred in, when known. * * Python spells this `obj_name`, and `typeName` against its `obj_type` is the same idiomatic * casing difference the naming register already records. Not a gap, and not renamed: spending a * rename to make the register harder to read is the wrong trade. */ objectName?: string; } export interface ParseOptions { /** * Throw on the first diagnostic instead of collecting them. * @defaultValue true */ strict?: boolean; /** Collects diagnostics when `strict` is false. */ onDiagnostic?: (diagnostic: ParseDiagnostic) => void; /** * Retain the source text and the anchoring, so a later `writeIdf` can reproduce it. * * Off by default, and the option gates every piece of the new work: a caller who does not ask * pays neither the scan nor the retention, and reading costs exactly what it costs today. * * When it is on, the read makes ONE pass and builds both the objects and the syntax layer from * it, so the cost is the layer's own budget rather than a second read of the text. * * The retained material hangs off the document, reachable as `IdfDocument.rawText`. It is not * returned beside the document: `ParseResult` carries exactly two keys and a test pins that it * does. * * @defaultValue false */ preserveFormatting?: boolean; } export interface ParseResult { document: IdfDocument; diagnostics: ParseDiagnostic[]; } /** * Parse IDF text into a document. * * Synchronous and pure: text in, document out, no I/O. Everything that touches * the filesystem or network lives at the edges (`@idfkit/core/node`), so this * function behaves identically in Node, a browser, and a worker. The schema * must already be loaded, which is the one genuinely async step. */ export declare function parseIdf(text: string, schema: Schema, options?: ParseOptions): ParseResult; export declare class IdfParseError extends Error { readonly line: number; readonly typeName: string | undefined; /** * Every finding that stopped the parse. * * This error carried `line` and `typeName` from a single diagnostic, flattened into fields, and * a caller who wanted the rest had nowhere to look. Python's `IDFParseError` has always carried * the collection; this is the half of the difference that was real. * * `line` and `typeName` still resolve to the first finding's values, so no existing caller * breaks (FR-013, FR-014). They are a convenience over `diagnostics[0]` rather than a second * source of truth. */ readonly diagnostics: readonly ParseDiagnostic[]; constructor(diagnostic: ParseDiagnostic | readonly ParseDiagnostic[]); } /** * Read the version identifier from IDF text without a schema. * * Chicken-and-egg: choosing the schema requires knowing the version, and the * version lives inside the file. This does the minimum scan needed to break * the cycle, and does not validate anything else. */ export declare function getIdfVersion(text: string): string | undefined; //# sourceMappingURL=idf.d.ts.map