Regex: Add support for \Q...\E quoted parts
This commit is contained in:
parent
7a313ddafe
commit
2f450e0080
|
@ -200,6 +200,19 @@ private:
|
|||
{
|
||||
const Codepoint cp = *m_pos++;
|
||||
|
||||
if (cp == 'Q')
|
||||
{
|
||||
auto escaped_sequence = new_node(ParsedRegex::Sequence);
|
||||
constexpr StringView end_mark{"\\E"};
|
||||
auto quote_end = std::search(m_pos.base(), m_regex.end(), end_mark.begin(), end_mark.end());
|
||||
while (m_pos != quote_end)
|
||||
escaped_sequence->children.push_back(new_node(ParsedRegex::Literal, *m_pos++));
|
||||
if (quote_end != m_regex.end())
|
||||
m_pos += 2;
|
||||
|
||||
return escaped_sequence;
|
||||
}
|
||||
|
||||
// CharacterClassEscape
|
||||
for (auto& character_class : character_class_escapes)
|
||||
{
|
||||
|
@ -962,6 +975,17 @@ auto test_regex = UnitTest{[]{
|
|||
kak_assert(vm.exec("123-456"));
|
||||
kak_assert(not vm.exec("123_456"));
|
||||
}
|
||||
|
||||
{
|
||||
TestVM vm{R"(\Q{}[]*+?\Ea+)"};
|
||||
kak_assert(vm.exec("{}[]*+?aa"));
|
||||
}
|
||||
|
||||
{
|
||||
TestVM vm{R"(\Q...)"};
|
||||
kak_assert(vm.exec("..."));
|
||||
kak_assert(not vm.exec("bla"));
|
||||
}
|
||||
}};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user