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

Method repeat

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

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)

Source from the content-addressed store, hash-verified

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 {

Callers 3

mMethod · 0.45
serialize_sequenceFunction · 0.45
serialize_objectFunction · 0.45

Calls 3

is_singleFunction · 0.85
repeat_singleMethod · 0.80
mMethod · 0.80

Tested by

no test coverage detected