import type { ParserDefs } from "./lempar.ts"; import type { KeywordDefs, Span, Token } from "./tokenize.ts"; export interface DiagnosticHint { /** Hint message */ readonly message: string; /** Optional: the source location the hint is referring to */ readonly span?: Span; } export interface Diagnostic { /** Error message */ readonly message: string; /** Location of the error */ readonly span: Span; /** Optional: the token that caused the error */ readonly token?: Token; /** Optional: additional hints about the error (eg, solutions) */ readonly hints?: readonly DiagnosticHint[]; } export interface ParseDiagnostic extends Diagnostic { /** Optional: the filename used in error messages, if provided at parse time */ readonly filename?: string; /** Format the diagnostic as a string with source code citations rendered as code blocks */ format(): string; /** Alias of {@link format} */ toString(): string; } export interface ParseErrorContext { readonly source: string; readonly filename?: string; } export declare function formatDiagnostic(ctx: ParseErrorContext, diagnostic: Diagnostic): string; export declare function createParseDiagnostic(ctx: ParseErrorContext, diagnostic: Diagnostic): ParseDiagnostic; export declare function createParseDiagnosticArray(context: ParseErrorContext, diagnostics: readonly Diagnostic[]): readonly ParseDiagnostic[]; export declare function lineColAt(sql: string, offset: number, startAt?: Span): { line: number; col: number; }; export interface RenderCodeBlockOptions { readonly contextBefore?: number; readonly contextAfter?: number; readonly indent?: string; } export declare function renderCodeBlock(ctx: ParseErrorContext, span: Span, options?: RenderCodeBlockOptions): string; /** * Build a Diagnostic for an ILLEGAL token that the tokenizer could not * classify. No grammar state is consulted. */ export declare function buildIllegalTokenDiagnostic(token: Token): Diagnostic; interface UnexpectedSyntaxErrorOptions { readonly token: Token; readonly state: number; readonly previousToken: Token | undefined; readonly sawOverSinceLastFilterOrSemi: boolean; /** * Stack of currently unmatched opener tokens (LP / CASE), maintained * by `parse()` in lockstep with the dispatch loop. The innermost * open delimiter is the last element. */ readonly openers: readonly Token[]; } type SyntaxParserDefs = Pick, "constants" | "tables" | "symbols">; export declare function bindSyntaxDiagnostics(defs: SyntaxParserDefs, keywordDefs: KeywordDefs): (opts: UnexpectedSyntaxErrorOptions) => Diagnostic; export {}; //# sourceMappingURL=diagnostics.d.ts.map