MCPcopy Create free account
hub / github.com/davidblewett/rure-python / exec_

Method exec_

regex/src/backtrack.rs:151–180  ·  view source on GitHub ↗

Start backtracking at the given position in the input, but also look for literal prefixes.

(&mut self, mut at: InputAt, end: usize)

Source from the content-addressed store, hash-verified

149 /// Start backtracking at the given position in the input, but also look
150 /// for literal prefixes.
151 fn exec_(&mut self, mut at: InputAt, end: usize) -> bool {
152 self.clear();
153 // If this is an anchored regex at the beginning of the input, then
154 // we're either already done or we only need to try backtracking once.
155 if self.prog.is_anchored_start {
156 return if !at.is_start() {
157 false
158 } else {
159 self.backtrack(at)
160 };
161 }
162 let mut matched = false;
163 loop {
164 if !self.prog.prefixes.is_empty() {
165 at = match self.input.prefix_at(&self.prog.prefixes, at) {
166 None => break,
167 Some(at) => at,
168 };
169 }
170 matched = self.backtrack(at) || matched;
171 if matched && self.prog.matches.len() == 1 {
172 return true;
173 }
174 if at.pos() == end {
175 break;
176 }
177 at = self.input.at(at.next_pos());
178 }
179 matched
180 }
181
182 /// The main backtracking loop starting at the given input position.
183 fn backtrack(&mut self, start: InputAt) -> bool {

Callers 1

execMethod · 0.45

Calls 9

is_startMethod · 0.80
backtrackMethod · 0.80
atMethod · 0.80
next_posMethod · 0.80
clearMethod · 0.45
is_emptyMethod · 0.45
prefix_atMethod · 0.45
lenMethod · 0.45
posMethod · 0.45

Tested by

no test coverage detected