From a52e386e8dcb33c699b85a2ee97a7932f8a7baaa Mon Sep 17 00:00:00 2001 From: Emmanuel Benoit Date: Mon, 9 Jan 2023 07:00:52 +0100 Subject: [PATCH] Parser - Set expressions --- src/parser.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/parser.rs b/src/parser.rs index def4eb4..8a4529a 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,7 +1,7 @@ use std::collections::HashSet; use crate::{ - ast::{ClassDecl, ExprNode, FunDecl, GetExpr, ProgramNode, StmtNode}, + ast::{ClassDecl, ExprNode, FunDecl, GetExpr, ProgramNode, SetExpr, StmtNode}, errors::{ErrorHandler, ErrorKind, SloxError, SloxResult}, tokens::{Token, TokenType}, }; @@ -532,6 +532,12 @@ impl Parser { value: Box::new(value), id: self.make_id(), }) + } else if let ExprNode::Get(get_expr) = expr { + Ok(ExprNode::Set(SetExpr { + instance: get_expr.instance, + name: get_expr.name, + value: Box::new(value), + })) } else { Err(SloxError::with_token( ErrorKind::Parse,