moved program to it's own files
This commit is contained in:
@@ -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
|
||||
|
@@ -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
16
src/ast/program.hpp
Normal 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
|
Reference in New Issue
Block a user