Repetition. Single codepoint atoms run iteratively to bound recursion. */
(&self, rep: &Rep, pos: usize, count: usize, caps: &mut Caps, k: &mut dyn FnMut(usize, &mut Caps) -> bool)
| 121 | |
| 122 | /* Repetition. Single codepoint atoms run iteratively to bound recursion. */ |
| 123 | fn repeat(&self, rep: &Rep, pos: usize, count: usize, caps: &mut Caps, k: &mut dyn FnMut(usize, &mut Caps) -> bool) -> bool { |
| 124 | if is_single(rep.node) { |
| 125 | return self.repeat_single(rep, pos, caps, k); |
| 126 | } |
| 127 | let can_more = rep.max.is_none_or(|m| count < m); |
| 128 | if rep.greedy { |
| 129 | if can_more { |
| 130 | let stepped = self.m(rep.node, pos, caps, &mut |p, c| { |
| 131 | if p == pos { return false; } // stop zero width expansion |
| 132 | self.repeat(rep, p, count + 1, c, k) |
| 133 | }); |
| 134 | if stepped { return true; } |
| 135 | } |
| 136 | count >= rep.min && k(pos, caps) |
| 137 | } else { |
| 138 | if count >= rep.min && k(pos, caps) { return true; } |
| 139 | if can_more { |
| 140 | return self.m(rep.node, pos, caps, &mut |p, c| { |
| 141 | if p == pos { return false; } |
| 142 | self.repeat(rep, p, count + 1, c, k) |
| 143 | }); |
| 144 | } |
| 145 | false |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | /* Iterative repeat for atoms that consume exactly one codepoint. */ |
| 150 | fn repeat_single(&self, rep: &Rep, pos: usize, caps: &mut Caps, k: &mut dyn FnMut(usize, &mut Caps) -> bool) -> bool { |
no test coverage detected