#pragma once
#include "RegexConstraint.hpp"
#include <vector>
#include "UniquePtr.hpp"
NAMESPACE_SOUP
{
struct RegexOpenEndedRangeQuantifierConstraintBase : public RegexConstraint
{
std::vector<UniquePtr<RegexConstraint>> constraints;
[[nodiscard]] RegexConstraint* getEntrypoint() noexcept final
{
return constraints.at(0)->getEntrypoint();
}
[[nodiscard]] bool matches(RegexMatcher& m) const noexcept final
{
return true;
}
[[nodiscard]] size_t getCursorAdvancement() const final
{
return constraints.at(0)->getCursorAdvancement() * constraints.size();
}
};
template <bool greedy>
struct RegexOpenEndedRangeQuantifierConstraint : public RegexOpenEndedRangeQuantifierConstraintBase
{
[[nodiscard]] std::string toString() const noexcept final
{
std::string str = constraints.at(0)->toString();
str.push_back('{');
str.append(std::to_string(constraints.size()));
str.append(",}");
if (!greedy)
{
str.push_back('?');
}
return str;
}
};
}