From 0cebffbf9b6694bab009ac332306cec5835d3317 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= <tseeker@nocternity.net>
Date: Sun, 8 Jan 2023 11:04:32 +0100
Subject: [PATCH] AST - Getter expression

---
 src/ast.rs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/ast.rs b/src/ast.rs
index dabe209..dc7e09c 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -74,6 +74,15 @@ impl StmtNode {
     }
 }
 
+/// A getter expression.
+#[derive(Debug, Clone)]
+pub struct GetExpr {
+    /// The instance being accessed.
+    pub instance: Box<ExprNode>,
+    /// The name of the property.
+    pub name: Token,
+}
+
 /// An AST node that represents an expression.
 #[derive(Debug, Clone)]
 pub enum ExprNode {
@@ -134,6 +143,9 @@ pub enum ExprNode {
         /// The list of function arguments.
         arguments: Vec<ExprNode>,
     },
+
+    /// A get expression.
+    Get(GetExpr),
 }
 
 /* -------------------------------- *
@@ -326,6 +338,14 @@ impl AstDumper for ExprNode {
                     )
                 }
             }
+
+            ExprNode::Get(get_expr) => {
+                format!(
+                    "( get {} {} )",
+                    get_expr.instance.dump(),
+                    get_expr.name.lexeme
+                )
+            }
         }
     }
 }