31 shared_ptr<RegexBackrefManager> backrefManager)
40 size_t len =
m_expr.size();
42 size_t subHead = index;
47 if (!extractPattern(subHead, &index))
48 BOOST_THROW_EXCEPTION(
Error(
"Compile error"));
53 RegexPatternListMatcher::extractPattern(
size_t index,
size_t* next)
57 size_t indicator = index;
62 index = extractSubPattern(
'(',
')', index);
64 end = extractRepetition(index);
65 if (indicator == end) {
66 auto matcher = make_shared<RegexBackrefMatcher>(
m_expr.substr(start, end - start),
69 matcher->lateCompile();
73 m_matchers.push_back(make_shared<RegexRepeatMatcher>(
m_expr.substr(start, end - start),
79 index = extractSubPattern(
'<',
'>', index);
81 end = extractRepetition(index);
82 m_matchers.push_back(make_shared<RegexRepeatMatcher>(
m_expr.substr(start, end - start),
88 index = extractSubPattern(
'[',
']', index);
90 end = extractRepetition(index);
91 m_matchers.push_back(make_shared<RegexRepeatMatcher>(
m_expr.substr(start, end - start),
96 BOOST_THROW_EXCEPTION(Error(
"Unexpected syntax"));
104 RegexPatternListMatcher::extractSubPattern(
const char left,
const char right,
size_t index)
109 while (lcount > rcount) {
110 if (index >=
m_expr.size())
111 BOOST_THROW_EXCEPTION(Error(
"Parenthesis mismatch"));
113 if (left ==
m_expr[index])
116 if (right ==
m_expr[index])
126 RegexPatternListMatcher::extractRepetition(
size_t index)
128 size_t exprSize =
m_expr.size();
130 if (index == exprSize)
137 if (
'{' ==
m_expr[index]) {
138 while (
'}' !=
m_expr[index]) {
140 if (index == exprSize)
143 if (index == exprSize)
144 BOOST_THROW_EXCEPTION(Error(
"Missing right brace bracket"));
Copyright (c) 2011-2015 Regents of the University of California.
shared_ptr< RegexBackrefManager > m_backrefManager
RegexPatternListMatcher(const std::string &expr, shared_ptr< RegexBackrefManager > backrefManager)
std::vector< shared_ptr< RegexMatcher > > m_matchers
void compile() override
Compile the regular expression to generate the more matchers when necessary.