diff options
author | Spartan322 <Megacake1234@gmail.com> | 2023-08-24 23:29:52 +0200 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2023-08-24 23:29:52 +0200 |
commit | 6add5bd2298c7ce7e27144b7db28aecec60fd1dd (patch) | |
tree | 1f04f10be2c588ecafa764ccd4ce893b035b4450 /include/openvic-dataloader | |
parent | 9d530253ee944228d5d19e6ae41d93e3e2b8cfbc (diff) |
Cleanup and streamlineevent-and-decisions
Diffstat (limited to 'include/openvic-dataloader')
-rw-r--r-- | include/openvic-dataloader/v2script/AbstractSyntaxTree.hpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/include/openvic-dataloader/v2script/AbstractSyntaxTree.hpp b/include/openvic-dataloader/v2script/AbstractSyntaxTree.hpp index 0d0b019..1dcd7c7 100644 --- a/include/openvic-dataloader/v2script/AbstractSyntaxTree.hpp +++ b/include/openvic-dataloader/v2script/AbstractSyntaxTree.hpp @@ -1,6 +1,7 @@ #pragma once #include <memory> +#include <optional> #include <string> #include <string_view> #include <type_traits> @@ -50,6 +51,12 @@ namespace ovdl::v2script::ast { constexpr bool is_type() const { return get_type().compare(detail::type_name<T>()) == 0; } + + template<typename T> + constexpr std::optional<T&> cast_to() { + if (is_type<T>()) return static_cast<T>(*this); + return std::nullopt; + } }; using NodePtr = Node*; @@ -77,7 +84,7 @@ namespace ovdl::v2script::ast { std::vector<NodeUPtr> result; result.reserve(ptrs.size()); for (auto&& p : ptrs) { - if (p == nullptr) continue; + if (!p || p == nullptr) continue; result.push_back(NodeUPtr(p)); } return result; @@ -103,13 +110,15 @@ namespace ovdl::v2script::ast { }) \ } + // Value Expression Nodes OVDL_AST_STRING_NODE(IdentifierNode); + OVDL_AST_STRING_NODE(StringNode); + + // Assignment Nodes OVDL_AST_STRING_NODE(FactorNode); OVDL_AST_STRING_NODE(MonthNode); OVDL_AST_STRING_NODE(NameNode); - OVDL_AST_STRING_NODE(StringNode); OVDL_AST_STRING_NODE(FireOnlyNode); - OVDL_AST_STRING_NODE(IdNode); OVDL_AST_STRING_NODE(TitleNode); OVDL_AST_STRING_NODE(DescNode); @@ -172,6 +181,7 @@ namespace ovdl::v2script::ast { } OVDL_AST_LIST_NODE(ListNode); + OVDL_AST_LIST_NODE(ModifierNode); OVDL_AST_LIST_NODE(MtthNode); OVDL_AST_LIST_NODE(EventOptionNode); |