/** * KERN Parser — public API surface. * * Implementation is split across sibling modules: * - parser-diagnostics.ts — diagnostic infrastructure * - parser-tokenizer.ts — character-level tokenizer * - parser-token-stream.ts — token cursor * - parser-style.ts — style block parsing * - parser-keywords.ts — keyword-specific handlers * - parser-core.ts — line parsing, tree building, orchestration */ import { type ParseOptions } from './parser-core.js'; import type { ParserHintsConfig } from './runtime.js'; import { type KernRuntime } from './runtime.js'; import type { IRNode, ParseDiagnostic, ParseResult } from './types.js'; export type { Token, TokenKind } from './parser-tokenizer.js'; export { tokenizeLine } from './parser-tokenizer.js'; /** Register parser hints for an evolved node type. */ export declare function registerParserHints(keyword: string, hints: ParserHintsConfig): void; /** Unregister parser hints (for rollback/testing). */ export declare function unregisterParserHints(keyword: string): void; /** Clear all parser hints (for test isolation). */ export declare function clearParserHints(): void; /** * Get diagnostic messages from the last parse() call as plain strings. * * @remarks Returns messages for all severities (error, warning, info). * For structured diagnostics with severity filtering, use {@link getParseDiagnostics}. */ export declare function getParseWarnings(): string[]; /** Get structured diagnostics from the last parse() call. */ export declare function getParseDiagnostics(runtime?: KernRuntime): ParseDiagnostic[]; /** * Parse KERN source into an IR node tree. * * Recovers from errors gracefully — malformed lines produce `DROPPED_LINE` * diagnostics but never throw. Use {@link parseStrict} if you want errors to throw. * * @param source - KERN indentation-based source text * @param runtime - Optional KernRuntime instance for isolation (defaults to shared singleton) * @returns Root IRNode of the parsed tree * * @example * ```ts * const root = parse('page "Home"\n text "Hello"'); * // root.type === 'page', root.children[0].type === 'text' * ``` * * @see {@link parseWithDiagnostics} to also receive parse diagnostics * @see {@link parseStrict} to throw on errors */ export declare function parse(source: string, runtime?: KernRuntime, options?: ParseOptions): IRNode; /** * Parse KERN source into a document-wrapped IR tree. * Unlike parse(), this always returns a `document` root so multiple * top-level nodes (e.g., multiple `rule` definitions) are siblings. */ export declare function parseDocument(source: string, runtime?: KernRuntime, options?: ParseOptions): IRNode; /** * Parse KERN source and return both the IR tree and structured diagnostics. * * Unlike {@link parse}, this returns a {@link ParseResult} containing the full * diagnostics array, useful for editor integrations and lint-style reporting. * * @param source - KERN indentation-based source text * @param runtime - Optional KernRuntime instance for isolation * @returns `{ root: IRNode, diagnostics: ParseDiagnostic[] }` */ export declare function parseWithDiagnostics(source: string, runtime?: KernRuntime, options?: ParseOptions): ParseResult; /** Parse with diagnostics (document mode). * * Slice 7 v2 — `options.resolveImport` enables cross-module Result/Option * recognition for `?`/`!` propagation. The CLI builds the resolver from a * project-wide pre-pass over `.kern` files and passes it per-file; pure * callers (browser playground, tests) omit it and cross-module * recognition stays disabled. */ export declare function parseDocumentWithDiagnostics(source: string, runtime?: KernRuntime, options?: ParseOptions): ParseResult; /** * Strict parse — throws if any diagnostic has severity `'error'` or a schema violation is found. * * @param source - KERN indentation-based source text * @param runtime - Optional KernRuntime instance for isolation * @returns Root IRNode of the parsed tree * @throws {KernParseError} When the source contains errors or schema violations. * The error includes a code frame and the full diagnostics array. */ export declare function parseStrict(source: string, runtime?: KernRuntime, options?: ParseOptions): IRNode; /** Strict document parse — throws KernParseError if any diagnostic has severity=error or schema violation. */ export declare function parseDocumentStrict(source: string, runtime?: KernRuntime, options?: ParseOptions): IRNode;