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}; } } }