diff options
Diffstat (limited to 'server')
| -rw-r--r-- | server/lexer/details/parse.cpp | 8 | ||||
| -rw-r--r-- | server/lexer/input.hpp | 20 | ||||
| -rw-r--r-- | server/lexer/lexer.hpp | 8 | ||||
| -rw-r--r-- | server/lexer/token.hpp | 16 | ||||
| -rw-r--r-- | server/lexer/token_type.cpp | 20 | ||||
| -rw-r--r-- | server/main/settings.hpp | 16 | ||||
| -rw-r--r-- | server/parser/operator.hpp | 12 | ||||
| -rw-r--r-- | server/parser/parser.hpp | 4 |
8 files changed, 78 insertions, 26 deletions
diff --git a/server/lexer/details/parse.cpp b/server/lexer/details/parse.cpp index e6f0898..1ba8097 100644 --- a/server/lexer/details/parse.cpp +++ b/server/lexer/details/parse.cpp @@ -33,7 +33,9 @@ public: // ^ I fucking hate C++. } - std::string to_str() const { return m_match[0].str(); } + std::string to_str() const { + return m_match[0].str(); + } protected: MatchResultsT m_match; @@ -64,7 +66,9 @@ protected: R"REGEX(^(?:\d+(?:\.\d*)?|\.\d+)(e[+-]?(\d*))?)REGEX"}; private: - bool matched_e() const { return this->m_match[1].matched; } + bool matched_e() const { + return this->m_match[1].matched; + } bool matched_e_power() const { return this->m_match[2].matched && this->m_match[2].length() != 0; diff --git a/server/lexer/input.hpp b/server/lexer/input.hpp index addea89..0e28b13 100644 --- a/server/lexer/input.hpp +++ b/server/lexer/input.hpp @@ -16,13 +16,21 @@ class Input { public: explicit Input(const std::string_view& input) : m_pos{0}, m_input{input} {} - const std::string_view& get_input() const { return m_input; } + const std::string_view& get_input() const { + return m_input; + } - std::size_t get_pos() const { return m_pos; } + std::size_t get_pos() const { + return m_pos; + } - std::size_t get_length() const { return m_input.length(); } + std::size_t get_length() const { + return m_input.length(); + } - bool empty() const { return m_input.empty(); } + bool empty() const { + return m_input.empty(); + } void consume(std::size_t len) { if (m_input.length() < len) { @@ -32,7 +40,9 @@ public: m_input.remove_prefix(len); } - void consume(const std::string_view& sub) { consume(sub.length()); } + void consume(const std::string_view& sub) { + consume(sub.length()); + } private: std::size_t m_pos; diff --git a/server/lexer/lexer.hpp b/server/lexer/lexer.hpp index 0dbdac6..302eb66 100644 --- a/server/lexer/lexer.hpp +++ b/server/lexer/lexer.hpp @@ -30,9 +30,13 @@ public: std::vector<ParsedToken> get_tokens(); - bool has_token() const { return peek_token().has_value(); } + bool has_token() const { + return peek_token().has_value(); + } - std::optional<ParsedToken> peek_token() const { return m_token_buffer; } + std::optional<ParsedToken> peek_token() const { + return m_token_buffer; + } void drop_token(); std::optional<ParsedToken> drop_token_of_type(Type type); diff --git a/server/lexer/token.hpp b/server/lexer/token.hpp index 40e3a0d..359536f 100644 --- a/server/lexer/token.hpp +++ b/server/lexer/token.hpp @@ -22,9 +22,13 @@ public: explicit Token(double value); bool operator==(const Token& other) const; - bool operator!=(const Token& other) const { return !(*this == other); } + bool operator!=(const Token& other) const { + return !(*this == other); + } - Type get_type() const { return m_type; } + Type get_type() const { + return m_type; + } double as_number() const; @@ -40,9 +44,13 @@ public: ParsedToken(Token&& token, std::size_t pos, const std::string_view& view) : Token{std::move(token)}, m_pos{pos}, m_view{view} {} - std::size_t get_pos() const { return m_pos; } + std::size_t get_pos() const { + return m_pos; + } - std::size_t get_length() const { return m_view.length(); } + std::size_t get_length() const { + return m_view.length(); + } private: std::size_t m_pos; diff --git a/server/lexer/token_type.cpp b/server/lexer/token_type.cpp index d26d491..b0ab9e0 100644 --- a/server/lexer/token_type.cpp +++ b/server/lexer/token_type.cpp @@ -21,9 +21,13 @@ using FromStringMap = std::map<std::string, Type, std::greater<std::string>>; class ToStringConverter { public: - ToStringConverter() : m_map{to_string_map()} { validate(); } + ToStringConverter() : m_map{to_string_map()} { + validate(); + } - const ToStringMap& map() const { return m_map; } + const ToStringMap& map() const { + return m_map; + } private: static const ToStringMap& to_string_map() { @@ -41,7 +45,9 @@ private: return map; } - void validate() const { check_for_duplicates(); } + void validate() const { + check_for_duplicates(); + } void check_for_duplicates() const { std::unordered_set<std::string> strings; @@ -66,7 +72,9 @@ class FromStringConverter { public: FromStringConverter(const ToStringMap& to_string) : m_map{build_map(to_string)} {} - const FromStringMap& map() const { return m_map; } + const FromStringMap& map() const { + return m_map; + } private: static FromStringMap build_map(const ToStringMap& to_string) { @@ -100,7 +108,9 @@ public: } } - const TypeSet& set() const { return m_set; } + const TypeSet& set() const { + return m_set; + } private: TypeSet m_set; diff --git a/server/main/settings.hpp b/server/main/settings.hpp index c0c974b..9d3eed0 100644 --- a/server/main/settings.hpp +++ b/server/main/settings.hpp @@ -20,12 +20,16 @@ namespace math::server { struct Settings { static constexpr unsigned short DEFAULT_PORT = 18000; - static std::size_t default_threads() { return std::thread::hardware_concurrency(); } + static std::size_t default_threads() { + return std::thread::hardware_concurrency(); + } unsigned short m_port; std::size_t m_threads; - bool exit_with_usage() const { return m_vm.count("help"); } + bool exit_with_usage() const { + return m_vm.count("help"); + } boost::program_options::variables_map m_vm; }; @@ -45,7 +49,9 @@ public: "number of threads"); } - static const char* get_short_description() { return "[-h|--help] [-p|--port] [-n|--threads]"; } + static const char* get_short_description() { + return "[-h|--help] [-p|--port] [-n|--threads]"; + } Settings parse(int argc, char* argv[]) { namespace po = boost::program_options; @@ -58,7 +64,9 @@ public: return m_settings; } - void usage() const { std::cout << *this; } + void usage() const { + std::cout << *this; + } void usage_error(const std::exception& e) const { std::cerr << "usage error: " << e.what() << '\n'; diff --git a/server/parser/operator.hpp b/server/parser/operator.hpp index 0f88209..c4b9091 100644 --- a/server/parser/operator.hpp +++ b/server/parser/operator.hpp @@ -40,7 +40,9 @@ public: return BinaryOp{token}; } - static constexpr unsigned min_precedence() { return 0; } + static constexpr unsigned min_precedence() { + return 0; + } static unsigned get_precedence(Type type) { switch (type) { @@ -60,7 +62,9 @@ public: } } - unsigned get_precedence() const { return get_precedence(m_type); } + unsigned get_precedence() const { + return get_precedence(m_type); + } bool is_right_associative() const { switch (m_type) { @@ -72,7 +76,9 @@ public: } } - bool is_left_associative() const { return !is_right_associative(); } + bool is_left_associative() const { + return !is_right_associative(); + } double exec(double lhs, double rhs) const { switch (m_type) { diff --git a/server/parser/parser.hpp b/server/parser/parser.hpp index 07efad5..5b17f70 100644 --- a/server/parser/parser.hpp +++ b/server/parser/parser.hpp @@ -36,7 +36,9 @@ public: private: // DMAS as in Division, Multiplication, Addition and Subtraction - double exec_dmas() { return exec_binary_op(exec_factor(), parser::BinaryOp::min_precedence()); } + double exec_dmas() { + return exec_binary_op(exec_factor(), parser::BinaryOp::min_precedence()); + } // Exponentiation operator double exec_exp() { |
