-
Notifications
You must be signed in to change notification settings - Fork 199
Open
Labels
Description
Atomic groups much like possessive modifiers assist in preventing excessive backtracking.
If I'm not too far off I think this roughly models an atomic group*. How to modify pcre.hpp to add the ll1 parser is a bit beyond me.
// matching atomic sequence in patterns
template <typename R, typename Iterator, typename EndIterator, typename HeadContent, typename... TailContent, typename... Tail>
constexpr CTRE_FORCE_INLINE R evaluate(const Iterator begin, Iterator current, const EndIterator end, R captures, ctll::list<atomic_sequence<HeadContent, TailContent...>, Tail...>) noexcept {
if constexpr (sizeof...(TailContent) > 0) {
if (auto r1 = evaluate(begin, current, end, captures, ctll::list<HeadContent, sequence<TailContent...>())) { //find the first match like a regular sequence*
current = r1.get_end_position();
return evaluate(begin, current, end, captures, ctll::list<Tail...>()); //continue w/o being able to backtrack past the atomic group
} else {
return not_matched;
}
} else { //if nothing follows an atomic group / sequence, (?>abc|def) it's like evaluating abc|def
return evaluate(begin, current, end, captures, ctll::list<HeadContent, Tail...>());
}
}