Created parse_value()
function.
This commit is contained in:
parent
5adf4396c7
commit
1733535322
|
@ -32,6 +32,16 @@ pub fn parse_var_declaration(mut tokens: Lexer<Token>) -> Option<Expr> {
|
||||||
tok
|
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> {
|
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?
|
// 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?
|
||||||
// ↓ ↓
|
// ↓ ↓
|
||||||
|
|
Loading…
Reference in a new issue