From 154d072ca848d7df4b7933f84a7228f9f6a04225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 1 Jan 2023 19:55:30 +0100 Subject: [PATCH] AST - Break and continue --- src/ast.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ast.rs b/src/ast.rs index f26be7e..48c8ccd 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -30,6 +30,10 @@ pub enum StmtNode { condition: ExprNode, body: Box, }, + /// Break statement + BreakStmt, + /// Continue statement + ContinueStmt, } /// An AST node that represents an expression. @@ -93,6 +97,8 @@ impl AstDumper for StmtNode { match self { Self::VarDecl(name, Some(expr)) => format!("( var {} {} )", name.lexeme, expr.dump()), Self::VarDecl(name, None) => format!("( var {} nil )", name.lexeme), + Self::BreakStmt => String::from("break"), + Self::ContinueStmt => String::from("continue"), Self::Expression(expr) => format!("{}", expr.dump()), Self::Print(expr) => format!("(print {})", expr.dump()),