From 86e5a5a5ca2fcc47294b0dacb76f4886bf604412 Mon Sep 17 00:00:00 2001 From: Goren Barak Date: Sat, 25 Nov 2023 17:29:19 -0500 Subject: [PATCH] Updated parse_var_declaration(). --- src/parse/parse.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/parse/parse.rs b/src/parse/parse.rs index f24f1cc..e0ca71f 100644 --- a/src/parse/parse.rs +++ b/src/parse/parse.rs @@ -2,7 +2,7 @@ use super::ast::*; use crate::lex::tok::*; use logos::Lexer; -fn parse_var_declaration(tokens: Lexer) -> Option> { +fn parse_var_declaration(tokens: Lexer) -> Option { let tok = None; match tokens.next() { Let => { @@ -16,7 +16,12 @@ fn parse_var_declaration(tokens: Lexer) -> Option> { Number(n) => { let value = Value::Number(n); println!("{:?}", value); - return VarDefenition {name, value}; + return Expr::VarDefenition {name, value}; + }, + + Identifier => { + let value = Value::Var(VarReference { name: tokens.slice() }); + return Expr::Vardefenition {name, value}; } } }