diff options
| author | Maxime Coste <mawww@kakoune.org> | 2024-08-04 15:36:03 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2024-08-04 15:36:03 +1000 |
| commit | 8a5f449c180d76566eb3eefdb3efb3c7a0116531 (patch) | |
| tree | afa634cdc10c9f63d56b602a216f3864ee6d8719 /src/regex_impl.cc | |
| parent | 10ed78fe8a580b3558348746ee53f81c5b0aeae1 (diff) | |
Move most code in regex_impl inside the anonymous namespace
This is all internal code that should not be exposed.
Diffstat (limited to 'src/regex_impl.cc')
| -rw-r--r-- | src/regex_impl.cc | 17 |
1 files changed, 8 insertions, 9 deletions
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<RegexMode mode = RegexMode::Forward> 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; |
