diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de4aa61..caba745 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,10 +42,6 @@ PRIVATE yycc/carton/binstore/setting.cpp yycc/carton/binstore/configuration.cpp yycc/carton/binstore/storage.cpp - yycc/carton/brigadier/types.cpp - yycc/carton/brigadier/constraint.cpp - yycc/carton/brigadier/node.cpp - yycc/carton/brigadier/parser.cpp yycc/carton/lexer61.cpp ) target_sources(YYCCommonplace @@ -115,11 +111,6 @@ FILES yycc/carton/binstore/configuration.hpp yycc/carton/binstore/storage.hpp yycc/carton/lexer61.hpp - yycc/carton/brigadier.hpp - yycc/carton/brigadier/types.hpp - yycc/carton/brigadier/constraint.hpp - yycc/carton/brigadier/node.hpp - yycc/carton/brigadier/parser.hpp yycc/carton/fft.hpp ) # Setup header infomations diff --git a/src/yycc/carton/brigadier.hpp b/src/yycc/carton/brigadier.hpp deleted file mode 100644 index 5dd7a97..0000000 --- a/src/yycc/carton/brigadier.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -namespace yycc::carton::brigadier {} diff --git a/src/yycc/carton/brigadier/constraint.cpp b/src/yycc/carton/brigadier/constraint.cpp deleted file mode 100644 index 5351ad1..0000000 --- a/src/yycc/carton/brigadier/constraint.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "constraint.hpp" - -namespace yycc::carton::brigadier::constraint { - -#pragma region Validator - - IValidator::IValidator() {} - - IValidator::~IValidator() {} - -#pragma endregion - - -} diff --git a/src/yycc/carton/brigadier/constraint.hpp b/src/yycc/carton/brigadier/constraint.hpp deleted file mode 100644 index 74971ba..0000000 --- a/src/yycc/carton/brigadier/constraint.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include - -namespace yycc::carton::brigadier::constraint { - - class IValidator { - public: - IValidator(); - virtual ~IValidator(); - - public: - virtual bool validate(const std::u8string_view& sv) const = 0; - }; - - template - concept Converter = requires(const T& t, const std::u8string_view& sv) { - // Check whether there is T::ReturnType type - typename T::ReturnType; - // Check whether there is "convert" member function and it has correct signature. - { t.convert(sv) } -> std::same_as; - }; - - //template - //concept Constraint = requires(const T& t) { - // { t.get_validator() } -> std::same_as>; - // { t.get_converter() } -> std::same_as; - //}; - - template - requires std::is_base_of_v - struct Constraint { - std::unique_ptr validator() const { throw std::logic_error("not implemented function"); } - TConverter converter() const { throw std::logic_error("not implemented function"); } - }; - -} // namespace yycc::carton::brigadier::constraint diff --git a/src/yycc/carton/brigadier/node.cpp b/src/yycc/carton/brigadier/node.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/yycc/carton/brigadier/node.hpp b/src/yycc/carton/brigadier/node.hpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/yycc/carton/brigadier/parser.cpp b/src/yycc/carton/brigadier/parser.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/yycc/carton/brigadier/parser.hpp b/src/yycc/carton/brigadier/parser.hpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/yycc/carton/brigadier/types.cpp b/src/yycc/carton/brigadier/types.cpp deleted file mode 100644 index faf1ef2..0000000 --- a/src/yycc/carton/brigadier/types.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "types.hpp" -#include "../../patch/format.hpp" -#include -#include - -#define FORMAT ::yycc::patch::format - -namespace yycc::carton::brigadier::types { - -#pragma region ArgumentStack - - ArgumentStack::ArgumentStack(std::vector &&args) : stack(std::move(args)), cursor(0) {} - - ArgumentStack::~ArgumentStack() {} - - void ArgumentStack::reset() { - this->cursor = 0; - } - - bool ArgumentStack::empty() const { - return cursor >= this->stack.size(); - } - - std::u8string_view ArgumentStack::peek() const { - return std::u8string_view(this->stack.at(this->cursor)); - } - - void ArgumentStack::push() { - if (cursor == 0) throw std::logic_error("no arguments can be pushed"); - else --cursor; - } - - void ArgumentStack::push() { - if (cursor >= this->stack.size()) throw std::logic_error("no arguments can be poped"); - else ++cursor; - } - -#pragma endregion - -#pragma region ConflictSet - - ConflictSet::ConflictSet() : inner() {} - - ConflictSet::~ConflictSet() {} - - void ConflictSet::add_literal(const std::u8string_view &value) { - if (value.empty()) throw std::invalid_argument("try to insert empty item to conflict set."); - auto entry = FORMAT::format(u8"literal:{}", value); - - auto result = this->inner.emplace(std::move(entry)); - if (!result.second) throw std::runtime_error("try to insert duplicated item in conflict set."); - } - - void ConflictSet::add_argument(const std::u8string_view &value) { - if (value.empty()) throw std::invalid_argument("try to insert empty item to conflict set."); - auto entry = FORMAT::format(u8"argument:{}", value); - - auto result = this->inner.emplace(std::move(entry)); - if (!result.second) throw std::runtime_error("try to insert duplicated item in conflict set."); - } - - bool ConflictSet::is_conflict_with(const ConflictSet &rhs) const { - // create a cache to store computed intersection - std::vector intersection; - // compute intersection - std::set_intersection(this->inner.begin(), this->inner.end(), rhs.inner.begin(), rhs.inner.begin(), std::back_inserter(intersection)); - // check whether it is empty intersection - return !intersection.empty(); - } - -#pragma endregion - -} // namespace yycc::carton::brigadier::types diff --git a/src/yycc/carton/brigadier/types.hpp b/src/yycc/carton/brigadier/types.hpp deleted file mode 100644 index 1577808..0000000 --- a/src/yycc/carton/brigadier/types.hpp +++ /dev/null @@ -1,84 +0,0 @@ -#pragma once -#include "../../macro/class_copy_move.hpp" -#include -#include -#include -#include - -namespace yycc::carton::brigadier::types { - - /** - * @private - * @brief A wrapper for argument visiting in brigadier. - * @details - * When using this stack, the top of stack is the first argument, - * and the bottom of stack is the last argument for the convenient calling from brigadier. - * - * Actually, in all usage, all poped items will be finally pushed with FILO order again. - * So I simply use a vector and cursor to represent a fake stack. - */ - class ArgumentStack { - public: - ArgumentStack(std::vector&& args); - ~ArgumentStack(); - YYCC_DEFAULT_COPY_MOVE(ArgumentStack) - - public: - void reset(); - bool empty() const; - std::u8string_view peek() const; - void pop(); - void push(); - - private: - std::vector stack; - size_t cursor; - }; - - /// @private - /// @brief Internal node used conflict set for detecting potential conflict. - class ConflictSet { - public: - ConflictSet(); - ~ConflictSet(); - YYCC_DEFAULT_COPY_MOVE(ConflictSet) - - public: - /** - * @brief Add literal item into conflict set. - * @param[in] value Literal item. - * @remarks - * \li Literal item is the string input in command line. - * \li The word in Literal, and the vocabulary in Choice should be put by this function. - * \li Added item will add \c literal: prefix to make it in literal scope, - * so that it will not be compared with argument name items. - * Because we allow 2 literal item and argument name item have same name. - */ - void add_literal(const std::u8string_view& value); - /** - * @brief Add argument name item into conflict - * @param[in] value Argument name item. - * @remarks - * \li Argument name item is the key name put in ArgumentsMap. - * \li The argument name in Choice and Argument should be put by this function. - * \li Added item will add \c argument: prefix to make it in argument name scope, - * so that it will not be compared with literal items. - * Because we allow 2 literal item and argument name item have same name. - */ - void add_argument(const std::u8string_view& value); - /** - * @brief Check whether this set is conflict with another. - * @param[in] rhs The set to be compared. - * @return True if they have conflict. - * @remarks - * This function simply compute the intersection of two set. - * If the result is not empty, it means that there is a conflict. - */ - bool is_conflict_with(const ConflictSet& rhs) const; - - private: - std::set inner; - }; - -} -