1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use enum_as_inner::EnumAsInner;
use serde::{Deserialize, Serialize};
use super::super::pl::{BinOp, InterpolateItem, Literal, Range};
use super::CId;
use crate::error::Span;
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct Expr {
pub kind: ExprKind,
pub span: Option<Span>,
}
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, EnumAsInner)]
pub enum ExprKind {
ColumnRef(CId),
Literal(Literal),
Range(Range<Box<Expr>>),
Binary {
left: Box<Expr>,
op: BinOp,
right: Box<Expr>,
},
Unary {
op: UnOp,
expr: Box<Expr>,
},
SString(Vec<InterpolateItem<Expr>>),
FString(Vec<InterpolateItem<Expr>>),
}
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub enum UnOp {
Neg,
Not,
}
impl From<ExprKind> for anyhow::Error {
#[allow(unreachable_code)]
fn from(_kind: ExprKind) -> Self {
panic!("Failed to convert ir:ExprKind")
}
}