From b5ff24ffad40b6727c2d368ac8c5b2a2d7f9da4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sat, 31 Dec 2022 16:16:12 +0100 Subject: [PATCH] AST - Variable assignment --- src/ast.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ast.rs b/src/ast.rs index 1d47a59..51a5b05 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -22,6 +22,9 @@ pub enum StmtNode { /// An AST node that represents an expression. #[derive(Debug, Clone)] pub enum ExprNode { + /// Assignment to a variable. + Assignment { name: Token, value: Box }, + /// Binary expression. Binary { left: Box, @@ -79,6 +82,7 @@ impl AstDumper for StmtNode { impl AstDumper for ExprNode { fn dump(&self) -> String { match self { + Self::Assignment { name, value } => format!("( = {} {} )", name.lexeme, value.dump()), Self::Binary { left, operator,