diff options
Diffstat (limited to 'src/openvic-dataloader/v2script/ModifierGrammar.hpp')
-rw-r--r-- | src/openvic-dataloader/v2script/ModifierGrammar.hpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/openvic-dataloader/v2script/ModifierGrammar.hpp b/src/openvic-dataloader/v2script/ModifierGrammar.hpp new file mode 100644 index 0000000..ad0704a --- /dev/null +++ b/src/openvic-dataloader/v2script/ModifierGrammar.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include <openvic-dataloader/v2script/AbstractSyntaxTree.hpp> + +#include <lexy/dsl.hpp> + +#include "SimpleGrammar.hpp" +#include "TriggerGrammar.hpp" + +namespace ovdl::v2script::grammar { + constexpr auto modifier_keyword = LEXY_KEYWORD("modifier", lexy::dsl::inline_<Identifier>); + constexpr auto factor_keyword = LEXY_KEYWORD("factor", lexy::dsl::inline_<Identifier>); + + struct FactorStatement { + static constexpr auto rule = factor_keyword >> lexy::dsl::equal_sign + lexy::dsl::inline_<Identifier>; + static constexpr auto value = lexy::as_string<std::string> | lexy::new_<ast::FactorNode, ast::NodePtr>; + }; + + struct ModifierStatement { + static constexpr auto rule = + modifier_keyword >> + lexy::dsl::curly_bracketed.list( + lexy::dsl::p<FactorStatement> | + lexy::dsl::p<TriggerList>); + + static constexpr auto value = + lexy::as_list<std::vector<ast::NodePtr>> >> + lexy::callback<ast::NodePtr>( + [](auto&& list) { + return make_node_ptr<ast::ModifierNode>(LEXY_MOV(list)); + }); + }; +}
\ No newline at end of file |