aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-dataloader/v2script/EffectGrammar.hpp
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2023-08-22 20:30:59 +0200
committer Spartan322 <Megacake1234@gmail.com>2023-08-22 20:30:59 +0200
commitdabf33050b6287fa7217858cb6021e1105f96894 (patch)
treea5f7b3e52e296a41ea9688b50ce53a8f495c4f13 /src/openvic-dataloader/v2script/EffectGrammar.hpp
parentb1bc7d520f09430c8d2372c6541ce23ec8099e13 (diff)
Add event_parse to Parser
Move ostream_output_iterator to detail/OStreamOutputIterator.hpp
Diffstat (limited to 'src/openvic-dataloader/v2script/EffectGrammar.hpp')
-rw-r--r--src/openvic-dataloader/v2script/EffectGrammar.hpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/openvic-dataloader/v2script/EffectGrammar.hpp b/src/openvic-dataloader/v2script/EffectGrammar.hpp
index 4ee19dd..71697c4 100644
--- a/src/openvic-dataloader/v2script/EffectGrammar.hpp
+++ b/src/openvic-dataloader/v2script/EffectGrammar.hpp
@@ -1,14 +1,40 @@
#pragma once
#include "SimpleGrammar.hpp"
+#include <lexy/callback.hpp>
#include <lexy/dsl.hpp>
+#include <openvic-dataloader/v2script/AbstractSyntaxTree.hpp>
namespace ovdl::v2script::grammar {
struct EffectStatement {
- 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::Effect, LEXY_MOV(name), LEXY_MOV(initalizer));
+ });
};
struct EffectList {
- static constexpr auto rule = lexy::dsl::list(lexy::dsl::p<EffectStatement>);
+ 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::Effect, LEXY_MOV(list));
+ });
+ };
+
+ struct EffectBlock {
+ static constexpr auto rule = lexy::dsl::curly_bracketed.opt(lexy::dsl::p<EffectList>);
+
+ static constexpr auto value = lexy::callback<ast::NodePtr>(
+ [](auto&& list) {
+ return LEXY_MOV(list);
+ },
+ [](lexy::nullopt = {}) {
+ return nullptr;
+ });
};
} \ No newline at end of file