use super::{Expr, Span, TypeExpr};
#[derive(Debug, Clone)]
pub enum Stmt {
Let {
name: String,
ty: TypeExpr,
init: Expr,
span: Span,
},
Assign {
lhs: Expr,
rhs: Expr,
span: Span,
},
If {
cond: Expr,
then_block: Block,
else_block: Option<ElseBranch>,
span: Span,
},
IfLet {
name: String,
expr: Expr,
then_block: Block,
else_block: Option<Block>,
span: Span,
},
While {
cond: Expr,
body: Block,
span: Span,
},
For {
init: Option<ForInit>,
cond: Option<Expr>,
step: Option<ForStep>,
body: Block,
span: Span,
},
Switch {
expr: Expr,
cases: Vec<Case>,
default: Option<Vec<Stmt>>,
span: Span,
},
Return {
value: Option<Expr>,
span: Span,
},
Break { span: Span },
Continue { span: Span },
Defer {
body: Block,
span: Span,
},
Expr {
expr: Expr,
span: Span,
},
Discard {
expr: Expr,
span: Span,
},
Unsafe {
body: Block,
span: Span,
},
Block(Block),
}
#[derive(Debug, Clone)]
pub struct Block {
pub stmts: Vec<Stmt>,
pub span: Span,
}
#[derive(Debug, Clone)]
pub enum ElseBranch {
ElseIf(Box<Stmt>),
Else(Block),
}
#[derive(Debug, Clone)]
pub enum ForInit {
Let {
name: String,
ty: TypeExpr,
init: Expr,
},
Assign {
lhs: Expr,
rhs: Expr,
},
Call(Expr),
}
#[derive(Debug, Clone)]
pub enum ForStep {
Assign { lhs: Expr, rhs: Expr },
Call(Expr),
}
#[derive(Debug, Clone)]
pub struct Case {
pub value: super::ConstExpr,
pub stmts: Vec<Stmt>,
pub span: Span,
}