import * as SqlType from "./SqlType"; import { ColName, TableName } from "./Types"; export type SomeCol = SomeCol.Some | SomeCol.Named; export namespace SomeCol { export interface Some { readonly type: "Some"; readonly exp: Exp; readonly parser: (val: string) => any; } export interface Named { readonly type: "Named"; readonly colName: ColName; readonly exp: Exp; readonly parser: (val: string) => any; readonly propName: string; } } export type Exp = Exp.ECol | Exp.ELit | Exp.EBinOp | Exp.ECustomBinOp | Exp.EUnOp | Exp.EFun2 | Exp.EFun3 | Exp.EFunN | Exp.ECast | Exp.ERaw | Exp.EIfThenElse | Exp.EAggrEx | Exp.EInList | Exp.EInQuery | Exp.EExists; export namespace Exp { export interface ECol { readonly type: "ECol"; readonly correlation: TableName | null; readonly colName: ColName; readonly parser: (val: string) => any; } export interface ELit { readonly type: "ELit"; readonly lit: SqlType.Lit; readonly parser: (val: string) => any; } export interface EBinOp { readonly type: "EBinOp"; readonly op: BinOp; readonly lhs: Exp; readonly rhs: Exp; readonly parser: (val: string) => any; } export interface ECustomBinOp { readonly type: "ECustomBinOp"; readonly op: string; readonly lhs: Exp; readonly rhs: Exp; readonly parser: (val: string) => any; } export interface EUnOp { readonly type: "EUnOp"; readonly op: UnOp; readonly exp: Exp; readonly parser: (val: string) => any; } export interface EFun2 { readonly type: "EFun2"; readonly name: string; readonly lhs: Exp; readonly rhs: Exp; readonly parser: (val: string) => any; } export interface EFun3 { readonly type: "EFun3"; readonly name: string; readonly col1: Exp; readonly col2: Exp; readonly col3: Exp; readonly parser: (val: string) => any; } export interface EFunN { readonly type: "EFunN"; readonly name: string; readonly cols: Exp[]; readonly parser: (val: string) => any; } export interface ECast { readonly type: "ECast"; readonly exp: Exp; readonly sqlType: string; readonly parser: (val: string) => any; } export interface ERaw { readonly type: "ERaw"; readonly fragments: (Exp | string)[]; readonly parser: (val: string) => any; } export interface EIfThenElse { readonly type: "EIfThenElse"; readonly expIf: Exp; readonly expThen: Exp; readonly expElse: Exp; readonly parser: (val: string) => any; } export interface EAggrEx { readonly type: "EAggrEx"; readonly name: string; readonly exp: Exp; readonly parser: (val: string) => any; } export interface EInList { readonly type: "EInList"; readonly exp: Exp; readonly exps: Exp[]; readonly parser: (val: string) => any; } export interface EInQuery { readonly type: "EInQuery"; readonly exp: Exp; readonly sql: sql; readonly parser: (val: string) => any; } export interface EExists { readonly type: "EExists"; readonly sql: sql2; readonly parser: (val: string) => any; } } export type UnOp = UnOp.UAbs | UnOp.UNot | UnOp.UNeg | UnOp.USgn | UnOp.UIsNull | UnOp.UFun; export namespace UnOp { export interface UAbs { type: "UAbs"; } export interface UNot { type: "UNot"; } export interface UNeg { type: "UNeg"; } export interface USgn { type: "USgn"; } export interface UIsNull { type: "UIsNull"; } export interface UFun { type: "UFun"; name: string; } } export const enum BinOp { Gt, Lt, Gte, Lte, Eq, Neq, And, Or, Add, Sub, Mul, Div, Concat, Like, ILike }