UNPKG

rawsql-ts

Version:

[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.

28 lines (27 loc) 1.26 kB
import { SourceComponent } from "../models/Clause"; import { Lexeme } from "../models/Lexeme"; export declare class SourceParser { static parse(query: string): SourceComponent; /** * Parses only a TableSource from the given lexemes, regardless of the presence of parentheses after the identifier. * This method is specifically used for cases like INSERT queries (e.g., "insert into table_name (col1, col2)") * where a parenthesis immediately following the table name could otherwise be misinterpreted as a function call. * By using this method, the parser forcibly treats the source as a TableSource. * * @param lexemes The array of lexemes to parse. * @param index The starting index in the lexeme array. * @returns An object containing the parsed TableSource and the new index. */ static parseTableSourceFromLexemes(lexemes: Lexeme[], index: number): { value: SourceComponent; newIndex: number; }; static parseFromLexeme(lexemes: Lexeme[], index: number): { value: SourceComponent; newIndex: number; }; private static parseTableSource; private static parseFunctionSource; private static parseParenSource; private static parseSubQuerySource; }