moved program to it's own files

This commit is contained in:
Karma Riuk
2025-07-08 09:58:02 +02:00
parent 1d259e6988
commit da2b6716b1
3 changed files with 22 additions and 12 deletions

View File

@@ -1,7 +1,6 @@
#pragma once
#include <string>
#include <vector>
namespace ast {
struct node {
@@ -16,14 +15,4 @@ namespace ast {
struct expression : node {
virtual std::string token_literal() const override = 0;
};
struct program : public node {
std::vector<statement*> statements;
std::string token_literal() const override;
~program() {
for (const auto& ref : statements)
delete ref;
};
};
} // namespace ast

View File

@@ -1,4 +1,4 @@
#include "ast.hpp"
#include "program.hpp"
namespace ast {
std::string program ::token_literal() const {
@@ -6,4 +6,9 @@ namespace ast {
return statements[0]->token_literal();
return "";
}
program::~program() {
for (const auto& ref : statements)
delete ref;
};
} // namespace ast

16
src/ast/program.hpp Normal file
View File

@@ -0,0 +1,16 @@
#pragma once
#include "ast.hpp"
#include <string>
#include <vector>
namespace ast {
struct program : public node {
std::vector<statement*> statements;
std::string token_literal() const override;
virtual std::string str() const override = 0;
~program();
};
} // namespace ast