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

Method compile_many

regex/src/compile.rs:160–196  ·  view source on GitHub ↗
(
        mut self,
        exprs: &[Hir],
    )

Source from the content-addressed store, hash-verified

158 }
159
160 fn compile_many(
161 mut self,
162 exprs: &[Hir],
163 ) -> result::Result<Program, Error> {
164 debug_assert!(exprs.len() > 1);
165
166 self.compiled.is_anchored_start =
167 exprs.iter().all(|e| e.is_anchored_start());
168 self.compiled.is_anchored_end =
169 exprs.iter().all(|e| e.is_anchored_end());
170 let mut dotstar_patch = Patch { hole: Hole::None, entry: 0 };
171 if self.compiled.needs_dotstar() {
172 dotstar_patch = self.c_dotstar()?;
173 self.compiled.start = dotstar_patch.entry;
174 } else {
175 self.compiled.start = 0; // first instruction is always split
176 }
177 self.fill_to_next(dotstar_patch.hole);
178
179 let mut prev_hole = Hole::None;
180 for (i, expr) in exprs[0..exprs.len() - 1].iter().enumerate() {
181 self.fill_to_next(prev_hole);
182 let split = self.push_split_hole();
183 let Patch { hole, entry } = self.c_capture(0, expr)?;
184 self.fill_to_next(hole);
185 self.compiled.matches.push(self.insts.len());
186 self.push_compiled(Inst::Match(i));
187 prev_hole = self.fill_split(split, Some(entry), None);
188 }
189 let i = exprs.len() - 1;
190 let Patch { hole, entry } = self.c_capture(0, &exprs[i])?;
191 self.fill(prev_hole, entry);
192 self.fill_to_next(hole);
193 self.compiled.matches.push(self.insts.len());
194 self.push_compiled(Inst::Match(i));
195 self.compile_finish()
196 }
197
198 fn compile_finish(mut self) -> result::Result<Program, Error> {
199 self.compiled.insts =

Callers 1

compileMethod · 0.80

Calls 15

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

Tested by

no test coverage detected