1use super::span::{Span, Spanned};
2
3#[derive(Debug, Clone)]
4pub struct Expr {
5 pub kind: ExprKind,
6 pub span: Span,
7}
8
9impl Expr {
10 pub fn new(kind: ExprKind, span: Span) -> Self {
11 Self { kind, span }
12 }
13}
14
15impl Spanned for Expr {
16 fn span(&self) -> Span {
17 self.span
18 }
19}
20
21#[derive(Debug, Clone)]
22pub enum ExprKind {
23 Literal(Literal),
24 ColumnRef {
25 table: Option<String>,
26 column: String,
27 },
28 BinaryOp {
29 left: Box<Expr>,
30 op: BinaryOp,
31 right: Box<Expr>,
32 },
33 UnaryOp {
34 op: UnaryOp,
35 operand: Box<Expr>,
36 },
37 FunctionCall {
38 name: String,
39 args: Vec<Expr>,
40 distinct: bool,
41 star: bool,
42 },
43 Between {
44 expr: Box<Expr>,
45 low: Box<Expr>,
46 high: Box<Expr>,
47 negated: bool,
48 },
49 Like {
50 expr: Box<Expr>,
51 pattern: Box<Expr>,
52 escape: Option<Box<Expr>>,
53 negated: bool,
54 },
55 InList {
56 expr: Box<Expr>,
57 list: Vec<Expr>,
58 negated: bool,
59 },
60 IsNull {
61 expr: Box<Expr>,
62 negated: bool,
63 },
64 VectorLiteral(Vec<f64>),
65}
66
67#[derive(Debug, Clone)]
68pub enum Literal {
69 Number(String),
70 String(String),
71 Boolean(bool),
72 Null,
73}
74
75#[derive(Debug, Clone, Copy, PartialEq, Eq)]
76pub enum BinaryOp {
77 Add,
78 Sub,
79 Mul,
80 Div,
81 Mod,
82 Eq,
83 Neq,
84 Lt,
85 Gt,
86 LtEq,
87 GtEq,
88 And,
89 Or,
90 StringConcat,
91}
92
93#[derive(Debug, Clone, Copy, PartialEq, Eq)]
94pub enum UnaryOp {
95 Not,
96 Minus,
97}