From 529a588900e8d0ec4d3de3e70573e635f482d733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 1 Jan 2023 18:33:45 +0100 Subject: [PATCH] AST - While loops --- src/ast.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ast.rs b/src/ast.rs index f6752dd..bb580a2 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -25,6 +25,11 @@ pub enum StmtNode { then_branch: Box, else_branch: Option>, }, + /// While loop statement. + WhileStmt { + condition: ExprNode, + body: Box, + }, } /// 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()) + } } } }