From da2b6716b1c26cee53a734522e3df5ba351a545b Mon Sep 17 00:00:00 2001 From: Karma Riuk Date: Tue, 8 Jul 2025 09:58:02 +0200 Subject: [PATCH] moved program to it's own files --- src/ast/ast.hpp | 11 ----------- src/ast/{ast.cpp => program.cpp} | 7 ++++++- src/ast/program.hpp | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 12 deletions(-) rename src/ast/{ast.cpp => program.cpp} (61%) create mode 100644 src/ast/program.hpp diff --git a/src/ast/ast.hpp b/src/ast/ast.hpp index 172d01e..a261b34 100644 --- a/src/ast/ast.hpp +++ b/src/ast/ast.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include 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 statements; - std::string token_literal() const override; - - ~program() { - for (const auto& ref : statements) - delete ref; - }; - }; } // namespace ast diff --git a/src/ast/ast.cpp b/src/ast/program.cpp similarity index 61% rename from src/ast/ast.cpp rename to src/ast/program.cpp index 6af4da3..5c83cf2 100644 --- a/src/ast/ast.cpp +++ b/src/ast/program.cpp @@ -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 diff --git a/src/ast/program.hpp b/src/ast/program.hpp new file mode 100644 index 0000000..bc809dc --- /dev/null +++ b/src/ast/program.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include "ast.hpp" + +#include +#include + +namespace ast { + struct program : public node { + std::vector statements; + std::string token_literal() const override; + virtual std::string str() const override = 0; + + ~program(); + }; +} // namespace ast