MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / repeat_single

Method repeat_single

std/re/src/main/matcher.rs:150–173  ·  view source on GitHub ↗

Iterative repeat for atoms that consume exactly one codepoint. */

(&self, rep: &Rep, pos: usize, caps: &mut Caps, k: &mut dyn FnMut(usize, &mut Caps) -> bool)

Source from the content-addressed store, hash-verified

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 {
151 let mut n = 0;
152 let mut p = pos;
153 while rep.max.is_none_or(|m| n < m) && p < self.input.len() && self.single_match(rep.node, p) {
154 p += 1;
155 n += 1;
156 }
157 if n < rep.min { return false; }
158 if rep.greedy {
159 let mut i = n;
160 loop {
161 if k(pos + i, caps) { return true; }
162 if i == rep.min { return false; }
163 i -= 1;
164 }
165 } else {
166 let mut i = rep.min;
167 loop {
168 if k(pos + i, caps) { return true; }
169 if i == n { return false; }
170 i += 1;
171 }
172 }
173 }
174
175 fn backref(&self, n: usize, pos: usize, caps: &mut Caps, k: &mut dyn FnMut(usize, &mut Caps) -> bool) -> bool {
176 match caps.get(n).copied().flatten() {

Callers 1

repeatMethod · 0.80

Calls 2

single_matchMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected