use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Expr {
Identifier(String),
String(String),
Number(f64),
Boolean(bool),
Null,
Object(Vec<(String, Expr)>),
Array(Vec<Expr>),
Call(Box<Expr>, Vec<Expr>),
ArrayAccess(Box<Expr>, Box<Expr>),
FieldAccess(Box<Expr>, String),
Local(Vec<(String, Expr)>, Box<Expr>),
Function(Vec<String>, Box<Expr>),
StringInterpolation(Vec<StringPart>),
ArrayComprehension {
expr: Box<Expr>,
var_name: String,
array_expr: Box<Expr>,
condition: Option<Box<Expr>>,
},
Conditional(Box<Expr>, Box<Expr>, Box<Expr>),
BinaryOp(BinaryOp, Box<Expr>, Box<Expr>),
UnaryOp(UnaryOp, Box<Expr>),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Stmt {
Expr(Expr),
Local(String, Expr),
Assign(String, Expr),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum BinaryOp {
Add,
Sub,
Mul,
Div,
Mod,
Eq,
Ne,
Lt,
Le,
Gt,
Ge,
And,
Or,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum UnaryOp {
Neg,
Not,
Plus,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum StringPart {
Literal(String),
Interpolation(Expr),
}