aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-dataloader/v2script/AiBehaviorGrammar.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-dataloader/v2script/AiBehaviorGrammar.hpp')
-rw-r--r--src/openvic-dataloader/v2script/AiBehaviorGrammar.hpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/openvic-dataloader/v2script/AiBehaviorGrammar.hpp b/src/openvic-dataloader/v2script/AiBehaviorGrammar.hpp
new file mode 100644
index 0000000..012820f
--- /dev/null
+++ b/src/openvic-dataloader/v2script/AiBehaviorGrammar.hpp
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <openvic-dataloader/v2script/AbstractSyntaxTree.hpp>
+
+#include <lexy/dsl.hpp>
+
+#include "ModifierGrammar.hpp"
+#include "SimpleGrammar.hpp"
+#include "TriggerGrammar.hpp"
+
+namespace ovdl::v2script::grammar {
+ struct AiBehaviorList {
+ static constexpr auto rule = lexy::dsl::list(lexy::dsl::p<FactorStatement> | lexy::dsl::p<ModifierStatement>);
+
+ static constexpr auto value =
+ lexy::as_list<std::vector<ast::NodePtr>> >>
+ lexy::callback<ast::NodePtr>(
+ [](auto&& list) {
+ return ast::make_node_ptr<ast::BehaviorListNode>(LEXY_MOV(list));
+ });
+ };
+
+ struct AiBehaviorBlock {
+ static constexpr auto rule = lexy::dsl::curly_bracketed.opt(lexy::dsl::p<AiBehaviorList>);
+
+ static constexpr auto value = lexy::callback<ast::NodePtr>(
+ [](auto&& list) {
+ return LEXY_MOV(list);
+ },
+ [](lexy::nullopt = {}) {
+ return lexy::nullopt {};
+ });
+ };
+} \ No newline at end of file