AST - While loops
This commit is contained in:
parent
a671836655
commit
529a588900
1 changed files with 9 additions and 0 deletions
|
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue