diff --git a/src/logic/CommandsInterpreter.cpp b/src/logic/CommandsInterpreter.cpp new file mode 100644 index 00000000..25c76362 --- /dev/null +++ b/src/logic/CommandsInterpreter.cpp @@ -0,0 +1,13 @@ +#include "CommandsInterpreter.hpp" + +#include "../coders/commons.hpp" + +using namespace cmd; + +class SchemeParser : BasicParser { + +}; + +Command Command::create(std::string_view scheme) { + +} diff --git a/src/logic/CommandsInterpreter.hpp b/src/logic/CommandsInterpreter.hpp new file mode 100644 index 00000000..8cf93fac --- /dev/null +++ b/src/logic/CommandsInterpreter.hpp @@ -0,0 +1,54 @@ +#ifndef LOGIC_COMMANDS_INTERPRETER_HPP_ +#define LOGIC_COMMANDS_INTERPRETER_HPP_ + +#include "../data/dynamic.hpp" + +#include +#include +#include + +namespace cmd { + enum class ArgType { + number, integer, enumvalue, selector, string + }; + + struct Argument { + std::string name; + ArgType type; + bool optional; + dynamic::Value def; + }; + + struct CommandInput { + dynamic::List_sptr args; // positional arguments list + dynamic::Map_sptr kwargs; // keyword arguments table + }; + + using executor_func = std::function; + + class Command { + std::string name; + std::vector args; + executor_func executor; + public: + Command( + std::string name, + std::vector args, + executor_func executor + ); + + dynamic::Value execute(const CommandInput& input) { + return executor(input.args, input.kwargs); + } + + static Command create(std::string_view scheme); + }; + + class CommandsInterpreter { + }; +} + +#endif // LOGIC_COMMANDS_INTERPRETER_HPP_