@@ -287,9 +287,9 @@ constexpr CTRE_FORCE_INLINE R evaluate(const Iterator begin, Iterator current, c
287
287
288
288
template <typename R, typename Iterator, typename EndIterator, typename ... Tail>
289
289
constexpr CTRE_FORCE_INLINE R ordered_evaluate (const Iterator begin, Iterator current, const EndIterator end, R captures, ctll::list<assert_begin, Tail...>) noexcept {
290
- if (begin != current) { // TODO I'm really not sure how to handle this.
291
- // Problematic pattern: "x*+^[a-z]*" (words that don't start with x)
292
- return not_matched ;
290
+ if (begin != current) {
291
+ captures. mask_elg ({ 0 , 1 , 1 });
292
+ return captures ;
293
293
}
294
294
return ordered_evaluate (begin, current, end, captures, ctll::list<Tail...>());
295
295
}
@@ -406,7 +406,6 @@ constexpr CTRE_FORCE_INLINE R evaluate(const Iterator begin, Iterator current, c
406
406
407
407
template <typename R, typename Iterator, typename EndIterator, size_t A, size_t B, typename ... Content, typename ... Tail>
408
408
constexpr CTRE_FORCE_INLINE R ordered_evaluate (const Iterator begin, Iterator current, const EndIterator end, R captures, ctll::list<possessive_repeat<A,B,Content...>, Tail...>) noexcept {
409
- // TODO this doesn't work yet!
410
409
// A..B
411
410
size_t i{0 };
412
411
for (; i < A && (A != 0 ); ++i) {
@@ -419,12 +418,18 @@ constexpr CTRE_FORCE_INLINE R ordered_evaluate(const Iterator begin, Iterator cu
419
418
420
419
for (; (i < B) || (B == 0 ); ++i) {
421
420
// try as many of inner as possible and then try outer once
421
+
422
+ // I have to mask this ordering beforehand, as we can't backtrack later.
423
+ // This basically throws away the usual runtime benefits of a possessive repeat.
424
+ auto outer_result = ordered_evaluate (begin, current, end, captures, ctll::list<Tail...>());
425
+ captures.mask_lg (outer_result);
426
+
422
427
auto inner_result = ordered_evaluate (begin, current, end, captures, ctll::list<sequence<Content...>, end_cycle_mark>());
423
428
captures.mask_lg (inner_result);
424
429
if (inner_result) {
425
430
current = inner_result.get_end_position ();
426
431
} else {
427
- return ordered_evaluate (begin, current, end, captures, ctll::list<Tail...>()) ;
432
+ return outer_result ;
428
433
}
429
434
}
430
435
0 commit comments