From ca76b3ab3f8a71387db2ec58b75d174fc2b0aca5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= <tseeker@nocternity.net>
Date: Mon, 2 Jan 2023 12:06:37 +0100
Subject: [PATCH] AST - Changed loop representation

---
 src/ast.rs | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/ast.rs b/src/ast.rs
index 0d63d8e..ff07c11 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -25,11 +25,12 @@ pub enum StmtNode {
         then_branch: Box<StmtNode>,
         else_branch: Option<Box<StmtNode>>,
     },
-    /// While loop statement.
-    WhileStmt {
+    /// Loop statement.
+    LoopStmt {
         label: Option<Token>,
         condition: ExprNode,
         body: Box<StmtNode>,
+        after_body: Option<Box<StmtNode>>,
     },
     /// Break or continue statement.
     LoopControlStmt {
@@ -125,17 +126,29 @@ impl AstDumper for StmtNode {
                 ),
             },
 
-            Self::WhileStmt {
+            Self::LoopStmt {
                 label,
                 condition,
                 body,
+                after_body,
             } => {
                 let ltxt = if let Some(label) = label {
                     format!("@{} ", label.lexeme)
                 } else {
                     "".to_string()
                 };
-                format!("( {}while {} {} )", ltxt, condition.dump(), body.dump())
+                let abtxt = if let Some(after_body) = after_body {
+                    format!("{} ", after_body.dump())
+                } else {
+                    "".to_string()
+                };
+                format!(
+                    "( {}loop {} {} {})",
+                    ltxt,
+                    condition.dump(),
+                    body.dump(),
+                    abtxt
+                )
             }
 
             Self::LoopControlStmt {