Updated parse_var_declaration().

This commit is contained in:
Goren Barak 2023-11-25 17:29:19 -05:00
parent db1bc88e7b
commit 86e5a5a5ca

View file

@ -2,7 +2,7 @@ use super::ast::*;
use crate::lex::tok::*;
use logos::Lexer;
fn parse_var_declaration(tokens: Lexer) -> Option<Expr<VarDefinition>> {
fn parse_var_declaration(tokens: Lexer) -> Option<Expr> {
let tok = None;
match tokens.next() {
Let => {
@ -16,7 +16,12 @@ fn parse_var_declaration(tokens: Lexer) -> Option<Expr<VarDefinition>> {
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};
}
}
}