aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/server/lexer/token.cpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-01-13 08:39:02 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-01-13 08:42:08 +0300
commit6913c6d965d64481ed09fc06a43154f35e8bd914 (patch)
treefa8d3f360a651a31fba4b91a09a5bba505a904c4 /server/lexer/token.cpp
parentTravis: only run clang-format on master (diff)
downloadmath-server-6913c6d965d64481ed09fc06a43154f35e8bd914.tar.gz
math-server-6913c6d965d64481ed09fc06a43154f35e8bd914.zip
clang-format all the code
Diffstat (limited to 'server/lexer/token.cpp')
-rw-r--r--server/lexer/token.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/server/lexer/token.cpp b/server/lexer/token.cpp
index 79c3a63..9bcd9f3 100644
--- a/server/lexer/token.cpp
+++ b/server/lexer/token.cpp
@@ -3,21 +3,25 @@
// For details, see https://github.com/egor-tensin/math-server.
// Distributed under the MIT License.
-#include "error.hpp"
#include "token.hpp"
+
+#include "error.hpp"
#include "token_type.hpp"
#include <cmath>
-
#include <limits>
#include <variant>
namespace math::server::lexer {
namespace {
-static constexpr double nan() { return std::numeric_limits<double>::quiet_NaN(); }
+static constexpr double nan() {
+ return std::numeric_limits<double>::quiet_NaN();
+}
-static bool is_nan(double x) { return std::isnan(x); }
+static bool is_nan(double x) {
+ return std::isnan(x);
+}
static bool numbers_equal(double x, double y) {
if (is_nan(x) && is_nan(y)) {
@@ -26,19 +30,15 @@ static bool numbers_equal(double x, double y) {
return x == y;
}
-}
-
-Token::Token(Type type)
- : m_type{type} {
+} // namespace
+Token::Token(Type type) : m_type{type} {
if (token::token_has_value(type)) {
throw LexerError{"internal: must have a value: " + token::type_to_int_string(type)};
}
}
-Token::Token(double value)
- : m_type{Type::NUMBER}, m_value{value}
-{ }
+Token::Token(double value) : m_type{Type::NUMBER}, m_value{value} {}
bool Token::operator==(const Token& other) const {
if (m_type != other.m_type) {
@@ -50,7 +50,8 @@ bool Token::operator==(const Token& other) const {
if (m_type == Type::NUMBER) {
return numbers_equal(as_number(), other.as_number());
}
- throw LexerError{"internal: can't compare tokens of type: " + token::type_to_int_string(m_type)};
+ throw LexerError{"internal: can't compare tokens of type: " +
+ token::type_to_int_string(m_type)};
}
double Token::as_number() const {
@@ -73,4 +74,4 @@ std::ostream& operator<<(std::ostream& os, const Token& token) {
return os;
}
-}
+} // namespace math::server::lexer