use serde::Serialize; use super::*; #[derive(Debug, Clone, Serialize, Default)] pub struct Block(pub Vec); #[derive(Debug, Clone, Serialize)] pub enum Statement { Expression(Expression), Block(Block), VarDecl(VarDeclStmt), Assign { target: Expression, compound: String, value: Expression, }, If { initial: StatementBranch, else_if: Vec, else_branch: Option>, }, While(StatementBranch), CStyleFor { init: Box, condition: Expression, update: Box, body: Box, }, For { mutable: bool, pattern: Pattern, iterator: Expression, body: Box, }, Match(Expression, Vec<(Pattern, Block)>), Return(Option), Break, Continue, Increment(Expression), Decrement(Expression), } #[derive(Debug, Clone, Serialize)] pub struct VarDecl { pub mutable: bool, pub name: Pattern, pub type_: Option, } #[derive(Debug, Clone, Serialize)] pub struct VarDeclStmt { pub decl: VarDecl, pub init: Option, } #[derive(Debug, Clone, Serialize)] pub struct StatementBranch { pub condition: Expression, pub body: Box, }