Removed C style flow control
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user