Created `parse_value()` function.

recursive
Goren Barak 2023-11-25 19:00:00 -05:00
parent 5adf4396c7
commit 1733535322
1 changed files with 10 additions and 0 deletions

View File

@ -32,6 +32,16 @@ pub fn parse_var_declaration(mut tokens: Lexer<Token>) -> Option<Expr> {
tok
}
pub fn parse_value(token: (Token, &str)) -> Option<Value<'static>> {
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<Token>) -> Option<Expr> {
// 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?
// ↓ ↓