diff --git a/src/parsing.cpp b/src/parsing.cpp index 54b5058..b022d08 100644 --- a/src/parsing.cpp +++ b/src/parsing.cpp @@ -50,6 +50,23 @@ namespace parsing { auto ret = new AST::ReturnStatement{ std::move(expression) }; return new std::unique_ptr{ ret }; } + else if (inner.peek().type == token::Type::Ident) { + auto ty = parse_type(inner).unwrap(); + auto name = inner.expect(token::Type::Ident); + + std::optional> expr = {}; + if (inner.peek().type == token::Type::Symbol && inner.peek().content == "=") { + std::cout << "hello" << std::endl; + inner.expect(token::Type::Symbol, "="); + expr = parse_expression(inner).unwrap(); + } + + inner.expect(token::Type::Symbol, ";"); + + stream.m_position = inner.m_position; + auto init = new AST::InitializationStatement{ std::move(ty), name.content, std::move(expr) }; + return new std::unique_ptr{ init }; + } else { throw std::runtime_error("Expected return-keyword"); }