diff --git a/include/ast/expression/LoopExpression.hpp b/include/ast/expression/LoopExpression.hpp new file mode 100644 index 0000000..0c9174a --- /dev/null +++ b/include/ast/expression/LoopExpression.hpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 - Nathanne Isip + * This file is part of Zhivo. + * + * Zhivo is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * Zhivo is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Zhivo. If not, see . + */ + +#ifndef ZHIVO_AST_EXPR_LOOP_HPP +#define ZHIVO_AST_EXPR_LOOP_HPP + +#include +#include + +#include +#include + +class LoopExpression : public ASTNode { +private: + std::unique_ptr initial; + std::unique_ptr condition; + std::unique_ptr postexpr; + std::unique_ptr body; + +public: + explicit LoopExpression( + std::unique_ptr _address, + std::unique_ptr _initial, + std::unique_ptr _condition, + std::unique_ptr _postexpr, + std::unique_ptr _body + ) : initial(std::move(_initial)), + condition(std::move(_condition)), + postexpr(std::move(_postexpr)), + body(std::move(_body)) { + this->address = std::move(_address); + } + + [[nodiscard]] DynamicObject visit(SymbolTable& symbols) override; +}; + +#endif