Removed C style flow control

This commit is contained in:
2026-06-10 04:35:11 +02:00
parent 286894c5db
commit afd3d05e2f
10 changed files with 42 additions and 111 deletions
+5 -20
View File
@@ -10,32 +10,26 @@ pub struct Block {
pub soft_return: Option<Spanned<Expression>>,
}
#[derive(Debug, Clone, Serialize)]
pub enum StatementBody {
Statement(Expression),
Expression(Expression),
}
#[derive(Debug, Clone, Serialize)]
pub enum Statement {
Block(Block),
If {
initial: StatementBranch,
else_if: Vec<StatementBranch>,
else_branch: Option<StatementBody>,
else_branch: Option<Block>,
},
Loop(StatementBody),
Loop(Block),
While(StatementBranch),
CStyleFor {
init: Expression,
condition: Expression,
update: Expression,
body: StatementBody,
body: Block,
},
For {
pattern: Pattern,
iterator: Expression,
body: StatementBody,
body: Block,
},
Match(Expression, Vec<Spanned<MatchItem>>),
@@ -63,7 +57,7 @@ pub struct VarDeclStmt {
#[derive(Debug, Clone, Serialize)]
pub struct StatementBranch {
pub condition: Expression,
pub body: Box<StatementBody>,
pub body: Box<Block>,
}
impl Statement {
@@ -80,12 +74,3 @@ impl Statement {
}
}
}
impl StatementBody {
pub fn is_soft_return(&self) -> bool {
match self {
Self::Expression(_) => true,
_ => false,
}
}
}