rawsql-ts
Version:
[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
42 lines (41 loc) • 1.55 kB
TypeScript
import { CreateTableQuery } from "../models/CreateTableQuery";
import { Lexeme } from "../models/Lexeme";
/**
* Parses CREATE TABLE statements (DDL or AS SELECT) into CreateTableQuery models.
*/
export declare class CreateTableParser {
private static readonly TABLE_CONSTRAINT_STARTERS;
private static readonly COLUMN_CONSTRAINT_STARTERS;
private static readonly MATCH_KEYWORDS;
private static readonly REFERENTIAL_ACTIONS;
private static readonly DEFERRABILITY_KEYWORDS;
private static readonly INITIALLY_KEYWORDS;
/**
* Parse SQL string to CreateTableQuery AST.
*/
static parse(query: string): CreateTableQuery;
/**
* Parse from lexeme array (for internal use and tests).
*/
static parseFromLexeme(lexemes: Lexeme[], index: number): {
value: CreateTableQuery;
newIndex: number;
};
private static parseQualifiedName;
private static parseDefinitionList;
private static parseColumnDefinition;
private static parseColumnType;
private static parseColumnConstraint;
private static parseTableConstraint;
private static parseIdentifierList;
private static parseReferenceDefinition;
private static parseParenExpression;
private static isColumnConstraintStart;
private static isColumnTerminator;
private static isSelectKeyword;
private static findClauseBoundary;
private static findFirstConstraintIndex;
private static parseWithDataOption;
private static popLexemeComments;
private static toOptionalComments;
}