From 9b9103c17096cf20968db534a4fc30941ae59515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Mon, 2 Jan 2023 20:16:14 +0100 Subject: [PATCH] AST - Added return statement --- src/ast.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ast.rs b/src/ast.rs index 808737d..f6cd97e 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -43,6 +43,11 @@ pub enum StmtNode { is_break: bool, loop_name: Option, }, + /// Return statement. + Return { + token: Token, + value: Option, + }, } impl StmtNode { @@ -204,6 +209,11 @@ impl AstDumper for StmtNode { None => format!("( {} )", stmt), } } + + Self::Return { token: _, value } => match value { + Some(expr) => format!("( return {} )", expr.dump()), + None => "( return )".to_owned(), + }, } } }