53 lines
805 B
Rust
53 lines
805 B
Rust
|
|
use crate::syn::{op::*, span::*};
|
||
|
|
|
||
|
|
pub enum Expr {
|
||
|
|
Base(BaseExpr),
|
||
|
|
Bin(Box<BinExpr>),
|
||
|
|
Un(Box<UnExpr>),
|
||
|
|
}
|
||
|
|
|
||
|
|
impl From<UnExpr> for Expr {
|
||
|
|
fn from(un: UnExpr) -> Self {
|
||
|
|
Expr::Un(Box::new(un))
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
impl From<BinExpr> for Expr {
|
||
|
|
fn from(bin: BinExpr) -> Self {
|
||
|
|
Expr::Bin(Box::new(bin))
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
impl From<BaseExpr> for Expr {
|
||
|
|
fn from(base: BaseExpr) -> Self {
|
||
|
|
Expr::Base(base)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct BinExpr {
|
||
|
|
pub lhs: Expr,
|
||
|
|
pub op: BinOp,
|
||
|
|
pub rhs: Expr,
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct UnExpr {
|
||
|
|
pub op: UnOp,
|
||
|
|
pub expr: Expr,
|
||
|
|
pub span: Span,
|
||
|
|
}
|
||
|
|
|
||
|
|
pub enum BaseExprKind {
|
||
|
|
Ident,
|
||
|
|
Num,
|
||
|
|
Str,
|
||
|
|
Sym,
|
||
|
|
List(Vec<Expr>),
|
||
|
|
Object(Vec<(Expr, Expr)>),
|
||
|
|
Tuple(Vec<Expr>),
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct BaseExpr {
|
||
|
|
pub kind: BaseExprKind,
|
||
|
|
pub span: Span,
|
||
|
|
}
|