aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-dataloader/v2script/AiBehaviorGrammar.hpp
blob: 012820f8847a3f60cc997ed53efe506a2e777b58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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 {};
         });
   };
}