diff options
Diffstat (limited to 'server/lexer')
| -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 |
5 files changed, 54 insertions, 18 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; |
