simple_expressions/types/
expression.rs1use crate::types::primitive::Primitive;
2
3#[derive(Debug, Clone, PartialEq)]
4pub enum Expr {
5 Literal(Primitive),
6 Var(String),
7 ListLiteral(Vec<Expr>),
8 DictLiteral(Vec<(Expr, Expr)>),
9 Member { object: Box<Expr>, field: String },
10 Index { object: Box<Expr>, index: Box<Expr> },
11 Call { callee: Box<Expr>, args: Vec<Expr> },
12 Unary { op: UnaryOp, expr: Box<Expr> },
13 Binary { op: BinaryOp, left: Box<Expr>, right: Box<Expr> },
14}
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum UnaryOp {
18 Not,
19 Neg,
20}
21
22#[derive(Debug, Clone, Copy, PartialEq, Eq)]
23pub enum BinaryOp {
24 Or,
25 And,
26 Eq,
27 Ne,
28 Lt,
29 Le,
30 Gt,
31 Ge,
32 Add,
33 Sub,
34 Mul,
35 Div,
36 Mod,
37 Pow,
38}