diff options
Diffstat (limited to 'src/openvic-dataloader/v2script/TriggerGrammar.hpp')
-rw-r--r-- | src/openvic-dataloader/v2script/TriggerGrammar.hpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/openvic-dataloader/v2script/TriggerGrammar.hpp b/src/openvic-dataloader/v2script/TriggerGrammar.hpp index 6f3436b..5b04e5b 100644 --- a/src/openvic-dataloader/v2script/TriggerGrammar.hpp +++ b/src/openvic-dataloader/v2script/TriggerGrammar.hpp @@ -1,14 +1,34 @@ #pragma once #include "SimpleGrammar.hpp" +#include <lexy/callback.hpp> #include <lexy/dsl.hpp> +#include <openvic-dataloader/v2script/AbstractSyntaxTree.hpp> namespace ovdl::v2script::grammar { struct TriggerStatement { - static constexpr auto rule = lexy::dsl::p<SimpleAssignmentStatement>; + static constexpr auto rule = lexy::dsl::inline_<SimpleAssignmentStatement>; + + static constexpr auto value = lexy::callback<ast::NodePtr>( + [](auto name, auto&& initalizer) { + return ast::make_node_ptr<ast::ExecutionNode>(ast::ExecutionNode::Type::Trigger, LEXY_MOV(name), LEXY_MOV(initalizer)); + }); }; struct TriggerList { - static constexpr auto rule = lexy::dsl::list(lexy::dsl::p<TriggerStatement>); + static constexpr auto rule = lexy::dsl::list(lexy::dsl::p<SimpleAssignmentStatement>); + + static constexpr auto value = + lexy::as_list<std::vector<ast::NodePtr>> >> + lexy::callback<ast::NodePtr>( + [](auto&& list) { + return ast::make_node_ptr<ast::ExecutionListNode>(ast::ExecutionNode::Type::Trigger, LEXY_MOV(list)); + }); + }; + + struct TriggerBlock { + static constexpr auto rule = lexy::dsl::curly_bracketed.opt(lexy::dsl::p<TriggerList>); + + static constexpr auto value = lexy::forward<ast::NodePtr>; }; }
\ No newline at end of file |