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

Method m

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

Core dispatch, k is the continuation called with the position after node. */

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

Source from the content-addressed store, hash-verified

69
70 /* Core dispatch, k is the continuation called with the position after node. */
71 fn m(&self, node: &Node, pos: usize, caps: &mut Caps, k: &mut dyn FnMut(usize, &mut Caps) -> bool) -> bool {
72 let n = self.steps.get() + 1;
73 self.steps.set(n);
74 if n > self.budget { return false; } // budget gone, unwind every branch
75 match node {
76 Node::Empty => k(pos, caps),
77 Node::Char(_) | Node::AnyChar | Node::Class { .. } => {
78 pos < self.input.len() && self.single_match(node, pos) && k(pos + 1, caps)
79 }
80 Node::Start => self.at_start(pos) && k(pos, caps),
81 Node::End => self.at_end(pos) && k(pos, caps),
82 Node::WordBoundary => self.boundary(pos) && k(pos, caps),
83 Node::NotWordBoundary => !self.boundary(pos) && k(pos, caps),
84 Node::Concat(v) => self.m_seq(v, pos, caps, k),
85 Node::Alt(v) => {
86 for branch in v {
87 if self.m(branch, pos, caps, k) { return true; }
88 }
89 false
90 }
91 Node::NonCap(inner) => self.m(inner, pos, caps, k),
92 Node::Group { index, node: inner, .. } => {
93 let index = *index;
94 let start = pos;
95 self.m(inner, pos, caps, &mut |end, caps| {
96 let prev = caps[index];
97 caps[index] = Some((start, end));
98 if k(end, caps) { true } else { caps[index] = prev; false }
99 })
100 }
101 Node::Repeat { node: inner, min, max, greedy } => {
102 let rep = Rep { node: inner, min: *min, max: *max, greedy: *greedy };
103 self.repeat(&rep, pos, 0, caps, k)
104 }
105 Node::Backref(n) => self.backref(*n, pos, caps, k),
106 Node::Look { node: inner, behind, negative } => {
107 self.look(inner, *behind, *negative, pos, caps, k)
108 }
109 }
110 }
111
112 /* Sequence walker, threads the continuation across nodes. */
113 fn m_seq(&self, nodes: &[Node], pos: usize, caps: &mut Caps, k: &mut dyn FnMut(usize, &mut Caps) -> bool) -> bool {

Callers 5

search_fromMethod · 0.80
match_atMethod · 0.80
m_seqMethod · 0.80
repeatMethod · 0.80
lookMethod · 0.80

Calls 11

setMethod · 0.80
single_matchMethod · 0.80
at_startMethod · 0.80
boundaryMethod · 0.80
m_seqMethod · 0.80
backrefMethod · 0.80
getMethod · 0.45
lenMethod · 0.45
at_endMethod · 0.45
repeatMethod · 0.45
lookMethod · 0.45

Tested by

no test coverage detected