From 8a5f449c180d76566eb3eefdb3efb3c7a0116531 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 4 Aug 2024 15:36:03 +1000 Subject: Move most code in regex_impl inside the anonymous namespace This is all internal code that should not be exposed. --- src/regex_impl.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/regex_impl.cc b/src/regex_impl.cc index 9b307f23..c32917eb 100644 --- a/src/regex_impl.cc +++ b/src/regex_impl.cc @@ -19,6 +19,9 @@ namespace Kakoune constexpr Codepoint CompiledRegex::StartDesc::count; +namespace +{ + struct ParsedRegex { enum Op : char @@ -73,9 +76,6 @@ struct ParsedRegex uint32_t capture_count; }; -namespace -{ - template struct Children { @@ -123,12 +123,14 @@ struct Children const Index m_index; }; -} // Recursive descent parser based on naming used in the ECMAScript // standard, although the syntax is not fully compatible. struct RegexParser { + static ParsedRegex parse(StringView re) { return RegexParser{re}.m_parsed_regex; } + +private: RegexParser(StringView re) : m_regex{re}, m_pos{re.begin(), re} { @@ -138,11 +140,6 @@ struct RegexParser kak_assert(root == 0); } - ParsedRegex get_parsed_regex() { return std::move(m_parsed_regex); } - - static ParsedRegex parse(StringView re) { return RegexParser{re}.get_parsed_regex(); } - -private: struct InvalidPolicy { Codepoint operator()(Codepoint cp) const { throw regex_error{"Invalid utf8 in regex"}; } @@ -1084,6 +1081,8 @@ private: ParsedRegex& m_parsed_regex; }; +} + String dump_regex(const CompiledRegex& program) { String res; -- cgit v1.2.3