AST - While loops

This commit is contained in:
Emmanuel BENOîT 2023-01-01 18:33:45 +01:00
parent a671836655
commit 529a588900

View file

@ -25,6 +25,11 @@ pub enum StmtNode {
then_branch: Box<StmtNode>,
else_branch: Option<Box<StmtNode>>,
},
/// While loop statement.
WhileStmt {
condition: ExprNode,
body: Box<StmtNode>,
},
}
/// An AST node that represents an expression.
@ -110,6 +115,10 @@ impl AstDumper for StmtNode {
stmt.dump()
),
},
Self::WhileStmt { condition, body } => {
format!("( while {} {} )", condition.dump(), body.dump())
}
}
}
}