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

Method compile_one

regex/src/compile.rs:135–158  ·  view source on GitHub ↗
(mut self, expr: &Hir)

Source from the content-addressed store, hash-verified

133 }
134
135 fn compile_one(mut self, expr: &Hir) -> result::Result<Program, Error> {
136 // If we're compiling a forward DFA and we aren't anchored, then
137 // add a `.*?` before the first capture group.
138 // Other matching engines handle this by baking the logic into the
139 // matching engine itself.
140 let mut dotstar_patch = Patch { hole: Hole::None, entry: 0 };
141 self.compiled.is_anchored_start = expr.is_anchored_start();
142 self.compiled.is_anchored_end = expr.is_anchored_end();
143 if self.compiled.needs_dotstar() {
144 dotstar_patch = self.c_dotstar()?;
145 self.compiled.start = dotstar_patch.entry;
146 }
147 self.compiled.captures = vec![None];
148 let patch = self.c_capture(0, expr)?;
149 if self.compiled.needs_dotstar() {
150 self.fill(dotstar_patch.hole, patch.entry);
151 } else {
152 self.compiled.start = patch.entry;
153 }
154 self.fill_to_next(patch.hole);
155 self.compiled.matches = vec![self.insts.len()];
156 self.push_compiled(Inst::Match(0));
157 self.compile_finish()
158 }
159
160 fn compile_many(
161 mut self,

Callers 1

compileMethod · 0.80

Calls 10

is_anchored_startMethod · 0.80
is_anchored_endMethod · 0.80
needs_dotstarMethod · 0.80
c_dotstarMethod · 0.80
c_captureMethod · 0.80
fillMethod · 0.80
fill_to_nextMethod · 0.80
push_compiledMethod · 0.80
compile_finishMethod · 0.80
MatchClass · 0.70

Tested by

no test coverage detected