// This file is part of Cait . // Copyright (C) 2022-2022 Fuwn // // This program 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, version 3. // // This program 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 this program. If not, see . // // Copyright (C) 2022-2022 Fuwn // SPDX-License-Identifier: GPL-3.0-only #ifndef NODE_HH #define NODE_HH #include #include #include #include #include #include #include "token.hh" namespace cait { namespace { class stringable { public: [[maybe_unused]] stringable() = default; stringable(const stringable &) = default; virtual ~stringable() = default; [[nodiscard]] virtual auto string() const -> std::string = 0; }; } // namespace namespace node { class variable; class rule; class build; class default_; class pool; class include; class subninja; using item_map_type = std::map>; using node_set = std::variant; class variable : stringable { private: const token &_name; std::vector _value_list; public: variable(const token &, std::vector); [[nodiscard]] auto string() const -> std::string override; [[nodiscard]] auto name() const noexcept -> const token &; [[maybe_unused]] [[nodiscard]] auto value_list() const noexcept -> const std::vector &; }; class rule : stringable { private: const token &_name; item_map_type _item_map; public: rule(const token &, item_map_type); [[nodiscard]] auto string() const -> std::string override; [[nodiscard]] auto name() const noexcept -> const token &; [[maybe_unused]] [[nodiscard]] auto item_map() const noexcept -> const item_map_type &; }; class pool : stringable { private: const token &_name; const token &_depth; public: pool(const token &, const token &); [[nodiscard]] auto string() const -> std::string override; [[nodiscard]] auto name() const noexcept -> const token &; [[maybe_unused]] [[nodiscard]] auto depth() const noexcept -> const token &; }; class build : stringable { private: const token &_output; const token &_rule; std::vector _inputs; public: build(const token &, const token &, std::vector); [[nodiscard]] auto string() const -> std::string override; [[maybe_unused]] [[nodiscard]] auto output() const noexcept -> const token &; [[maybe_unused]] [[nodiscard]] auto rule() const noexcept -> const token &; [[maybe_unused]] [[nodiscard]] auto inputs() const noexcept -> const std::vector &; }; class default_ : stringable { private: std::vector _targets; public: explicit default_(std::vector); [[nodiscard]] auto string() const -> std::string override; [[maybe_unused]] [[nodiscard]] auto targets() const noexcept -> const std::vector &; }; class include : stringable { private: const token &_path; public: explicit include(const token &); [[nodiscard]] auto string() const -> std::string override; [[maybe_unused]] [[nodiscard]] auto path() const noexcept -> const token &; }; class subninja : stringable { private: const token &_path; public: explicit subninja(const token &); [[nodiscard]] auto string() const -> std::string override; [[maybe_unused]] [[nodiscard]] auto path() const noexcept -> const token &; }; } // namespace node } // namespace cait #endif // NODE_HH