30 shared_ptr<RegexBackrefManager> backrefManager)
41 BOOST_THROW_EXCEPTION(
Error(
"Regexp compile error (cannot parse " +
m_expr +
")"));
45 return compileSingleComponent();
47 size_t lastIndex =
m_expr.size() - 1;
48 if (
']' !=
m_expr[lastIndex])
49 BOOST_THROW_EXCEPTION(
Error(
"Regexp compile error (no matching ']' in " +
m_expr +
")"));
52 m_isInclusion =
false;
53 compileMultipleComponents(2, lastIndex);
56 compileMultipleComponents(1, lastIndex);
60 BOOST_THROW_EXCEPTION(
Error(
"Regexp compile error (cannot parse " +
m_expr +
")"));
65 RegexComponentSetMatcher::compileSingleComponent()
67 size_t end = extractComponent(1);
69 BOOST_THROW_EXCEPTION(Error(
"Component expr error " +
m_expr));
75 RegexComponentSetMatcher::compileMultipleComponents(
size_t start,
size_t lastIndex)
78 size_t tempIndex = start;
80 while (index < lastIndex) {
82 BOOST_THROW_EXCEPTION(Error(
"Component expr error " +
m_expr));
84 tempIndex = index + 1;
85 index = extractComponent(tempIndex);
86 m_components.push_back(make_shared<RegexComponentMatcher>(
m_expr.substr(tempIndex, index - tempIndex - 1),
90 if (index != lastIndex)
91 BOOST_THROW_EXCEPTION(Error(
"Not sufficient expr to parse " +
m_expr));
101 bool isMatched =
false;
102 for (
const auto& comp : m_components) {
103 if (comp->match(
name, offset, len)) {
111 if (m_isInclusion ? isMatched : !isMatched) {
120 RegexComponentSetMatcher::extractComponent(
size_t index)
const 125 while (lcount > rcount) {
134 BOOST_THROW_EXCEPTION(Error(
"Square brackets mismatch"));
Copyright (c) 2011-2015 Regents of the University of California.
bool match(const Name &name, size_t offset, size_t len=1) override
shared_ptr< RegexBackrefManager > m_backrefManager
void compile() override
Compile the regular expression to generate the more matchers when necessary.
std::vector< name::Component > m_matchResult
Represents an absolute name.
RegexComponentSetMatcher(const std::string &expr, shared_ptr< RegexBackrefManager > backrefManager)
Create a RegexComponentSetMatcher matcher from expr.