using smart pointers instead of normal ones for

easier setup of tests (to call setup() multiple
times without leaks)
This commit is contained in:
Karma Riuk
2025-07-11 11:16:16 +02:00
parent 826f4de77a
commit 2174781b77
7 changed files with 14 additions and 18 deletions

View File

@@ -84,8 +84,8 @@ namespace parser {
next_token()) {};
}
ast::program* parser::parse_program() {
ast::program* p = new ast::program();
std::unique_ptr<ast::program> parser::parse_program() {
std::unique_ptr<ast::program> p = std::make_unique<ast::program>();
for (; current.type != token::type::END_OF_FILE; next_token()) {
ast::statement* stmt = parse_statement();

View File

@@ -11,6 +11,7 @@
#include "token/token.hpp"
#include <functional>
#include <memory>
#include <vector>
namespace parser {
@@ -23,7 +24,7 @@ namespace parser {
~parser();
std::vector<ast::error::error*> errors;
ast::program* parse_program();
std::unique_ptr<ast::program> parse_program();
private:
lexer::lexer& lexer;