import { type ATN, CommonTokenStream, type Lexer, type Parser, type ParserRuleContext, type Vocabulary } from "antlr4ng"; import type { Dialect } from "../dialect.js"; /** * A ready-to-walk parser for the completion engine: the lexer, the token stream, the entry * rule's index (for `atn.ruleToStartState[...]`), and a `runEntry()` that drives the parse far * enough to fill the token stream and leave the parser ATN-ready. * * Unlike `src//parse.ts` (two-stage SLL→LL that bails/recovers and produces a CST for * the *valid-parse* pipeline), this is the always-available, error-tolerant front end the * interactive editor features need: it keeps the default recovering error strategy so a broken / * mid-edit statement still yields a usable tree and a complete token stream. */ export interface MadeParser { parser: Parser; lexer: Lexer; tokenStream: CommonTokenStream; /** The RULE_ index of the entry rule (index into `parser.atn.ruleToStartState`). */ entryRuleIndex: number; /** Invoke the entry rule. Recovers on error (never throws on broken input). */ runEntry: () => ParserRuleContext; } /** Build a fresh error-tolerant parser for `dialect`, lexing `sql`. */ export declare function makeParser(sql: string, dialect: Dialect): MadeParser; /** The input-INDEPENDENT parser facts the ATN candidate walk needs: the dialect's parser ATN, the * lexer vocabulary (for keyword literal labels), and the batch entry rule's index. All three are * per-dialect statics (the ATN and vocabulary are shared across every parser/lexer instance), so * they are grabbed once from a throwaway empty-input factory and reused; no source is re-lexed. */ export interface CompletionMeta { atn: ATN; vocabulary: Vocabulary; entryRuleIndex: number; } /** The cached {@link CompletionMeta} for `dialect`, built once. Completion drives the walk over the * document's own token stream plus this meta, instead of re-parsing the source text. */ export declare function completionMeta(dialect: Dialect): CompletionMeta;