diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2020-01-04 01:57:20 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2020-01-04 01:57:20 +0300 |
commit | 1206de56d8fb5e8095ed97ff49db3ddd74b03d4b (patch) | |
tree | 6de9a2c458c5703d5a01f80ceb26460edd4a217d /server | |
parent | Docker: forgot to add Boost.Regex (diff) | |
download | math-server-1206de56d8fb5e8095ed97ff49db3ddd74b03d4b.tar.gz math-server-1206de56d8fb5e8095ed97ff49db3ddd74b03d4b.zip |
lexer: switch to Boost.Regex
Diffstat (limited to '')
-rw-r--r-- | server/lexer/details/parse.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/server/lexer/details/parse.cpp b/server/lexer/details/parse.cpp index 9f56573..79ad4cf 100644 --- a/server/lexer/details/parse.cpp +++ b/server/lexer/details/parse.cpp @@ -157,7 +157,7 @@ std::optional<double> boost_parse_number(const std::string_view& input) { } std::optional<double> parse_number(const std::string_view& input, std::string_view& token) { - return impl::std_parse_number(input, token); + return impl::boost_parse_number(input, token); } std::optional<double> parse_number(const std::string_view& input) { @@ -182,15 +182,12 @@ std::optional<token::Type> parse_const_token(const std::string_view& input) { } std::string_view parse_whitespace(const std::string_view& input) { - static const std::regex ws_regex{R"(^\s+)"}; - - std::cmatch match; - { - const auto begin = input.data(); - const auto end = begin + input.length(); - if (std::regex_search(begin, end, match, ws_regex)) { - return std::string_view(match[0].first, match[0].length()); - } + static const boost::regex ws_regex{R"(^\s+)"}; + + boost::match_results<std::string_view::const_iterator> match; + if (boost::regex_search(input.cbegin(), input.cend(), match, ws_regex)) { + return {&*match[0].first, static_cast<std::size_t>(match[0].length())}; + // ^ Still fucking hate C++. } return {}; } |