From 0637e52c83b4b66e59ac081707f16f174510e924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 1 Jan 2023 11:13:41 +0100 Subject: [PATCH] AST - Logical binary expressions --- src/ast.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ast.rs b/src/ast.rs index febe145..f6752dd 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -33,6 +33,13 @@ pub enum ExprNode { /// Assignment to a variable. Assignment { name: Token, value: Box }, + /// Logical binary expression. + Logical { + left: Box, + operator: Token, + right: Box, + }, + /// Binary expression. Binary { left: Box, @@ -111,6 +118,11 @@ impl AstDumper for ExprNode { fn dump(&self) -> String { match self { Self::Assignment { name, value } => format!("( = {} {} )", name.lexeme, value.dump()), + Self::Logical { + left, + operator, + right, + } => format!("( {} {} {} )", operator.lexeme, left.dump(), right.dump()), Self::Binary { left, operator,