aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/server/lexer
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-06-13 19:23:10 +0200
committerEgor Tensin <egor@tensin.name>2026-06-13 19:23:10 +0200
commit880e8c45c5621ed8432b74a0cf4f212b9c14aade (patch)
treeaa13bb1cc8d64db07b51c859b3277f1cdc855876 /server/lexer
parentget rid of functionality removed in newer Boost (diff)
downloadmath-server-880e8c45c5621ed8432b74a0cf4f212b9c14aade.tar.gz
math-server-880e8c45c5621ed8432b74a0cf4f212b9c14aade.zip
finally, perfect .clang-format settings?
Diffstat (limited to 'server/lexer')
-rw-r--r--server/lexer/details/parse.cpp17
-rw-r--r--server/lexer/token.cpp5
-rw-r--r--server/lexer/token_type.cpp10
3 files changed, 20 insertions, 12 deletions
diff --git a/server/lexer/details/parse.cpp b/server/lexer/details/parse.cpp
index 75072a4..5df6254 100644
--- a/server/lexer/details/parse.cpp
+++ b/server/lexer/details/parse.cpp
@@ -63,7 +63,8 @@ protected:
// numbers using a regex (the tests seem to pass though).
// A proper NFA would be better, I guess.
static constexpr std::string_view NUMBER_REGEX{
- R"REGEX(^(?:\d+(?:\.\d*)?|\.\d+)(e[+-]?(\d*))?)REGEX"};
+ R"REGEX(^(?:\d+(?:\.\d*)?|\.\d+)(e[+-]?(\d*))?)REGEX"
+ };
private:
bool matched_e() const {
@@ -108,9 +109,11 @@ private:
};
template <typename MatchResultsT>
-std::optional<double> parse_number(std::string_view input,
- RegexNumberMatcher<MatchResultsT>&& matcher,
- std::string_view& token) {
+std::optional<double> parse_number(
+ std::string_view input,
+ RegexNumberMatcher<MatchResultsT>&& matcher,
+ std::string_view& token
+) {
if (!matcher.match(input)) {
return {};
}
@@ -162,8 +165,10 @@ private:
};
template <typename MatchResultsT>
-std::string_view parse_whitespace(std::string_view input,
- RegexWhitespaceMatcher<MatchResultsT>&& matcher) {
+std::string_view parse_whitespace(
+ std::string_view input,
+ RegexWhitespaceMatcher<MatchResultsT>&& matcher
+) {
if (matcher.match_regex(input)) {
return matcher.to_view();
}
diff --git a/server/lexer/token.cpp b/server/lexer/token.cpp
index 61ab1e7..e2d0a3f 100644
--- a/server/lexer/token.cpp
+++ b/server/lexer/token.cpp
@@ -49,8 +49,9 @@ 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 {
diff --git a/server/lexer/token_type.cpp b/server/lexer/token_type.cpp
index b0ab9e0..d26e6a4 100644
--- a/server/lexer/token_type.cpp
+++ b/server/lexer/token_type.cpp
@@ -54,8 +54,9 @@ private:
for (const auto& [type, str] : m_map) {
const auto [_, inserted] = strings.emplace(str);
if (!inserted) {
- throw std::logic_error{"multiple tokens have the same string representation: " +
- str};
+ throw std::logic_error{
+ "multiple tokens have the same string representation: " + str
+ };
}
}
}
@@ -82,8 +83,9 @@ private:
for (const auto& [type, str] : to_string) {
const auto [_, inserted] = from_string.emplace(str, type);
if (!inserted) {
- throw std::logic_error{"multiple tokens have the same string representation: " +
- str};
+ throw std::logic_error{
+ "multiple tokens have the same string representation: " + str
+ };
}
}
return from_string;