From 1206de56d8fb5e8095ed97ff49db3ddd74b03d4b Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 4 Jan 2020 01:57:20 +0300 Subject: lexer: switch to Boost.Regex --- server/lexer/details/parse.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'server/lexer/details') 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 boost_parse_number(const std::string_view& input) { } std::optional 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 parse_number(const std::string_view& input) { @@ -182,15 +182,12 @@ std::optional 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 match; + if (boost::regex_search(input.cbegin(), input.cend(), match, ws_regex)) { + return {&*match[0].first, static_cast(match[0].length())}; + // ^ Still fucking hate C++. } return {}; } -- cgit v1.2.3