-
Notifications
You must be signed in to change notification settings - Fork 196
Atomic sequence support? #108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looking back, slightly off, the function would end up looking like: 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, atomic_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 (auto r1 = evaluate(begin, current, end, captures, ctll::list<HeadContent>())) {
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;
}
}
} |
I looked into it and I think this is all needed for atomic support: |
Does it not change how certain things inside behave? Wouldn't it change sequences to atomic groups etc? Be glad to be wrong, especially if it was that easy. |
Based on this: https://www.regular-expressions.info/atomic.html the |
The examples it gives w/ a select would probably be a good static assert to test against: Playing around with a similar example on regex101: I think that means it's changing how the parts inside |
These tests added |
Should've probably seen that coming, an atomic group would behave differently if mutually exclusive or not. |
I ran into this issue when writing optimizations for select* The intuition / fix is something along the lines of this: I think I spotted some code of yours to do w/ testing against select<>'s and empty/epsilons, it's roughly equivalent to: Also makes the other way around make sense as to why that works, |
@hanickadot I'm not exactly the best template meta programmer out there*, however if there were a way to order the select<> branches by their starting characters ranges and then by their expression lengths that would be one way to handle this. Might be possible by doing some character length analysis like I've done in #166 |
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.
The text was updated successfully, but these errors were encountered: