import { Parser, ParserResult } from "tarsec"; import { AgencyConfig } from "./config.js"; import { AgencyNode, AgencyProgram } from "./types.js"; export declare const agencyNode: Parser; export declare const agencyParser: Parser; export declare const normalizeCode: (code: string) => string; export { replaceBlankLines } from "./parsers/parsers.js"; /** Failure result enriched with the tarsec rightmost-failure position so * the LSP can surface a real squiggle range instead of falling back to * line 0, col 0. `pos` is a byte offset into the normalized input. */ export type ParserFailureWithPos = { success: false; message: string; rest: string; rightmostPos?: number; }; /** * Raw parse entry point. Normalizes the source, primes tarsec's * input-string / memo state, runs the top-level `agencyParser`, and * returns the result with an optional `rightmostPos` so callers can * recover an editor-coordinate location for recoverable failures. * * Difference vs `parseAgency`: * - `_parseAgency` is the **raw** parse. It does NOT wrap the source * in the CLI template prelude, does NOT run the pattern-lowering * pass, and does NOT catch `TarsecError` / `PatternLoweringError` * — those exceptions propagate to the caller as-is. * - `parseAgency` is the **user-facing** layer. It optionally renders * the template (which prepends stdlib imports the CLI auto-injects), * runs the lowering pass on success, and converts thrown errors * into a structured `ParseAgencyResult` with `errorData` populated * so the LSP / CLI can render a useful diagnostic. * * Exported because `scripts/agency.ts diagnostics` calls it directly * to get raw tarsec error data without the higher-level wrapping. */ export declare function _parseAgency(input: string, config?: AgencyConfig): ParserResult | ParserFailureWithPos; export type ParseAgencyErrorData = { line: number; column: number; length: number; message: string; prettyMessage: string; }; export type ParseAgencyResult = { success: true; result: AgencyProgram; rest: string; } | { success: false; message?: string; rest: string; errorData?: ParseAgencyErrorData; }; export declare function parseAgency(input: string, config?: AgencyConfig, applyTemplate?: boolean, lower?: boolean): ParseAgencyResult;