export interface FilePosition { offset: number; line: number; column: number; } export interface FileRange { start: FilePosition; end: FilePosition; source: string; } export interface LiteralExpectation { type: "literal"; text: string; ignoreCase: boolean; } export interface ClassParts extends Array { } export interface ClassExpectation { type: "class"; parts: ClassParts; inverted: boolean; ignoreCase: boolean; } export interface AnyExpectation { type: "any"; } export interface EndExpectation { type: "end"; } export interface OtherExpectation { type: "other"; description: string; } export type Expectation = LiteralExpectation | ClassExpectation | AnyExpectation | EndExpectation | OtherExpectation; declare class _PeggySyntaxError extends Error { static buildMessage(expected: Expectation[], found: string | null): string; message: string; expected: Expectation[]; found: string | null; location: FileRange; name: string; constructor(message: string, expected: Expectation[], found: string | null, location: FileRange); format(sources: { source?: any; text: string; }[]): string; } export interface TraceEvent { type: string; rule: string; result?: any; location: FileRange; } export interface ParseOptions { filename?: string; startRule?: "start"; tracer?: any; [key: string]: any; } export type ParseFunction = (input: string, options?: Options) => Options extends { startRule: infer StartRule; } ? StartRule extends "start" ? Start : Start : Start; export declare const parse: ParseFunction; export declare const PeggySyntaxError: typeof _PeggySyntaxError; export type PeggySyntaxError = _PeggySyntaxError; export type Start = MultipleStmt | InitConfig; export type MultipleStmt = CrudStmt; export type CrudStmt = UnionStmt | UpdateStmt | ReplaceInsertStmt | InsertIntoSet | DeleteStmt | DropStmt | CreateStmt | RenameStmt | AlterTableStmt; export type __ = (Whitespace | Comment)[]; export type Whitespace = string; export type Comment = BlockComment | LineComment | PoundSignComment; export type BlockComment = ["/*", [undefined, Char][], "*/"]; export type Char = string; export type LineComment = ["--", [undefined, Char][]]; export type PoundSignComment = ["#", [undefined, Char][]]; export type EOL = EOF | string[]; export type EOF = undefined; export type SEMICOLON = ";"; export type InitConfig = "success!!"; export type UnionStmt = SelectStmt; export type OrderByClause = OrderByList; export type KWORDER = [string, undefined]; export type IdentStart = string; export type KWBY = [string, undefined]; export type OrderByList = NonNullable[]; export type COMMA = ","; export type OrderByElement = { field: Column; sequence: string | NonNullable<(KWDESC | KWASC) | null>; }; export type Column = ColumnName | QuotedIdent; export type ColumnName = string; export type ColumnPart = string; export type QuotedIdent = DoubleQuotedIdent | SingleQuotedIdent | BackticksQuotedIdent; export type DoubleQuotedIdent = string; export type SingleQuotedIdent = string; export type BackticksQuotedIdent = string; export type KWDESC = "DESC"; export type KWASC = "ASC"; export type LimitClause = string | LiteralNumeric; export type KWLIMIT = [string, undefined]; export type LiteralNumeric = Digits; export type Digits = string; export type Digit = string; export type KWOFFSET = "OFFSET"; export type SelectStmt = SelectStmtNake | any; export type SelectStmtNake = { from: any; fields: ColumnClause; join: any; where: WhereClause | null; groupBy: GroupByClause | null; having: HavingClause | null; order: OrderByClause | null; limit: LimitClause | null; }; export type KWSELECT = [string, undefined]; export type ___ = (Whitespace | Comment)[]; export type KWDISTINCT = "DISTINCT"; export type ColumnClause = [{ name: "*"; }] | NonNullable[]; export type KWALL = "ALL"; export type STAR = "*"; export type ColumnListItem = { name: "*"; } | { name: string; as: AliasClause | null; } | { name: Ident; as: AliasClause | null; }; export type Ident = IdentName | QuotedIdent; export type IdentName = string; export type IdentPart = string; export type DOT = "."; export type AliasClause = AliasIdent | Ident; export type KWAS = [string, undefined]; export type AliasIdent = IdentName | QuotedIdent; export type FromClause = TableRefList; export type KWFROM = [string, undefined]; export type TableRefList = { froms: any[]; joins: any[]; }; export type TableBase = { name: TableName; as: "" | NonNullable; }; export type TableName = string | Ident; export type TableRef = TableBase | TableJoin; export type TableJoin = { name: any; as: any; type: JoinOp; on: never[] | NonNullable; }; export type JoinOp = "LEFT JOIN" | "RIGHT JOIN" | "INNER JOIN"; export type KWLEFT = [string, undefined]; export type KWOUTER = [string, undefined]; export type KWJOIN = [string, undefined]; export type KWRIGHT = [string, undefined]; export type KWINNER = [string, undefined]; export type OnClause = OrAndWhereExpr; export type KWON = [string, undefined]; export type OrAndWhereExpr = any[]; export type OrExpr = any[]; export type KWOR = "OR"; export type AndExpr = {}; export type KWAND = "AND"; export type ComparisonExpr = { [x: number]: ComparisonOpRight | null; }; export type AdditiveExpr = TableName; export type ComparisonOpRight = ArithmeticOpRight | InOpRight | BetweenOpRight | IsOpRight | LikeOpRight; export type LikeOpRight = { attr: "like"; value: Literal; }; export type Literal = LiteralNumeric | LiteralBool | LiteralNull; export type LiteralBool = boolean; export type LiteralNull = "null"; export type KWTRUE = [string, undefined]; export type KWFALSE = [string, undefined]; export type KWNULL = [string, undefined]; export type LikeOp = string | KWLIKE; export type KWNOT = "NOT"; export type KWLIKE = "LIKE"; export type ArithmeticOpRight = { attr: ArithmeticComparisonOperator; value: TableValue; }; export type ArithmeticComparisonOperator = ">=" | ">" | "<=" | "<>" | "<" | "==" | "=" | "!="; export type TableValue = string | IdentEffective; export type IdentEffective = any; export type InOpRight = { attr: "in"; value: ConditionValue[]; }; export type KWIN = "IN"; export type LPAREN = "("; export type RPAREN = ")"; export type BetweenOpRight = { attr: "between"; value: [ConditionValue, ConditionValue]; }; export type KWBETWEEN = "BETWEEN"; export type IsOpRight = { attr: "!=" | "="; value: IsValue; }; export type KWIS = "IS"; export type ConditionValue = Literal | QuotedIdentType | TableValue; export type QuotedIdentType = DoubleQuotedIdent | SingleQuotedIdent | BackticksQuotedIdent; export type IsValue = NullValue | ConditionValue; export type NullValue = null; export type WhereClause = OrAndWhereExpr; export type KWWHERE = [string, undefined]; export type GroupByClause = string; export type KWGROUP = [string, undefined]; export type ColumnRef = string | Column; export type HavingClause = string; export type KWHAVING = [string, undefined]; export type HavingClauseStop = [__, KWORDER, __, KWBY] | [__, KWLIMIT] | [__, RPAREN]; export type DeleteStmt = { from: any; where: WhereClause | null; order: OrderByClause | null; limit: LimitClause | null; }; export type KWDELETE = [string, undefined]; export type ReplaceInsertStmt = { into: TableName; values: ValueClause; }; export type KWINTO = [string, undefined]; export type ReplaceInsert = "insert" | "replace"; export type KWINSERT = [string, undefined]; export type KWREPLACE = [string, undefined]; export type ValueClause = ValueList; export type KWVALUES = [string, undefined]; export type ValueList = ValueItem[]; export type ValueItem = ExprList; export type ExprList = any[]; export type InsertIntoSet = { into: TableName; values: SetList; }; export type KWSET = "SET"; export type SetList = NonNullable[]; export type SetItem = { key: { name: ColumnWithoutKw; table: string; }; value: AdditiveExpr; } | { column: ColumnWithoutKw; value: ColumnRef; table: any; keyword: "values"; }; export type ColumnWithoutKw = ColumnName | QuotedIdent; export type UpdateStmt = { from: any; set: never[] | NonNullable; where: WhereClause | null; order: OrderByClause | null; limit: LimitClause | null; }; export type KWUPDATE = [string, undefined]; export type DropStmt = DropTableStmt | DropDbStmt; export type DropTableStmt = { type: "drop"; table: any; }; export type KWDROP = "DROP"; export type KWTABLE = "TABLE"; export type DropDbStmt = { type: "drop"; database: any; }; export type KWDATABASE = "DATABASE"; export type CreateStmt = CreateTableStmt | CreateDbStmt; export type CreateTableStmt = { name: TableName; fields: never[]; primaryKey: string; auto: boolean; }; export type KWCREATE = [string, undefined]; export type CreateDbStmt = { type: "createDatabase"; name: ProcFuncName; definition: CreateDbDefinition | null; }; export type CreateTableDefinition = any[]; export type ProcFuncName = IdentName | BackticksQuotedIdent; export type CreateDbDefinition = any[]; export type CreateOptionCharacterSet = { keyword: any; op: KWASSIGNEQUAL | null; value: IdentWithoutKwType; defaultKeyword: boolean; }; export type KWDEFAULT = [string, undefined]; export type CreateOptionCharacterSetKw = "CHARACTER SET"; export type KWASSIGNEQUAL = "="; export type CreateColumnDefinition = { name: ColumnWithoutKw; type: DataType | null; autoIncrement: boolean; unique: boolean; primaryKey: boolean; notNull: boolean; }; export type IdentWithoutKwType = IdentNameType | QuotedIdentType; export type IdentNameType = IdentName; export type DataType = PrimaryType | string | BlobType; export type ColumnDefinitionOptList = {}; export type PrimaryType = string; export type BlobType = "blob"; export type ColumnDefinitionOpt = (LiteralNotNull | LiteralNull) | DefaultExpr | string; export type LiteralNotNull = "not null"; export type KWNOTNULL = [string, undefined]; export type DefaultExpr = OrExpr; export type AlterTableStmt = { name: TableName; actions: never[] | NonNullable; }; export type KWALTER = [string, undefined]; export type AlterActionList = any[]; export type AlterAction = ALTERADDCOLUMN | ALTERDROPCOLUMN | ALTERMODIFYCOLUMN | ALTERCHANGECOLUMN; export type ALTERADDCOLUMN = { action: "add"; field: CreateColumnDefinition; }; export type KWADD = "ADD"; export type KWCOLUMN = "COLUMN"; export type ALTERDROPCOLUMN = { action: "drop"; field: { name: ColumnRef; }; }; export type ALTERMODIFYCOLUMN = { action: "modify"; field: CreateColumnDefinition; }; export type KWMODIFY = "MODIFY"; export type ALTERCHANGECOLUMN = { action: "change"; field: CreateColumnDefinition; }; export type AlterColumnSuffix = { keyword: string; expr: ColumnRef; }; export type RenameStmt = TableToList; export type KWRENAME = [string, undefined]; export type TableToList = any[]; export type TableToItem = { oldName: TableName; name: TableName; }; export type KWTO = [string, undefined]; export {};