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

Method step

regex/src/pikevm.rs:240–283  ·  view source on GitHub ↗

Step through the input, one token (byte or codepoint) at a time. nlist is the set of states that will be processed on the next token in the input. caps is the set of captures passed by the caller of the NFA. They are written to only when a match state is visited. thread_caps is the set of captures set for the current NFA state, ip. at and at_next are the current and next positions in the input

(
        &mut self,
        nlist: &mut Threads,
        matches: &mut [bool],
        slots: &mut [Slot],
        thread_caps: &mut [Option<usize>],
        ip: usize,
        at: InputAt,
        a

Source from the content-addressed store, hash-verified

238 /// at and at_next are the current and next positions in the input. at or
239 /// at_next may be EOF.
240 fn step(
241 &mut self,
242 nlist: &mut Threads,
243 matches: &mut [bool],
244 slots: &mut [Slot],
245 thread_caps: &mut [Option<usize>],
246 ip: usize,
247 at: InputAt,
248 at_next: InputAt,
249 ) -> bool {
250 use prog::Inst::*;
251 match self.prog[ip] {
252 Match(match_slot) => {
253 if match_slot < matches.len() {
254 matches[match_slot] = true;
255 }
256 for (slot, val) in slots.iter_mut().zip(thread_caps.iter()) {
257 *slot = *val;
258 }
259 true
260 }
261 Char(ref inst) => {
262 if inst.c == at.char() {
263 self.add(nlist, thread_caps, inst.goto, at_next);
264 }
265 false
266 }
267 Ranges(ref inst) => {
268 if inst.matches(at.char()) {
269 self.add(nlist, thread_caps, inst.goto, at_next);
270 }
271 false
272 }
273 Bytes(ref inst) => {
274 if let Some(b) = at.byte() {
275 if inst.matches(b) {
276 self.add(nlist, thread_caps, inst.goto, at_next);
277 }
278 }
279 false
280 }
281 EmptyLook(_) | Save(_) | Split(_) => false,
282 }
283 }
284
285 /// Follows epsilon transitions and adds them for processing to nlist,
286 /// starting at and including ip.

Callers 1

exec_Method · 0.45

Calls 6

lenMethod · 0.45
iterMethod · 0.45
charMethod · 0.45
addMethod · 0.45
matchesMethod · 0.45
byteMethod · 0.45

Tested by

no test coverage detected