From 173353532236544cacb6d89a508e86ff6e810ab5 Mon Sep 17 00:00:00 2001 From: Goren Barak Date: Sat, 25 Nov 2023 19:00:00 -0500 Subject: [PATCH] Created `parse_value()` function. --- src/parse/parse.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/parse/parse.rs b/src/parse/parse.rs index cd7f1a8..d964f3d 100644 --- a/src/parse/parse.rs +++ b/src/parse/parse.rs @@ -32,6 +32,16 @@ pub fn parse_var_declaration(mut tokens: Lexer) -> Option { tok } +pub fn parse_value(token: (Token, &str)) -> Option> { + let mut value = None; + + if let Number(n) = token.0 { + value = Some(Value::Number(n)); + } else if token.0 == Identifier { + value = Some(Value::Var(VarReference { name: token.1 })); + } +} + pub fn parse_fun_call(mut tokens: Lexer) -> Option { // Is it an Ident? → Is it a LeftParen? → Is it a value (I should really make a function to parse that) or is it a RightParen? // ↓ ↓