MCPcopy Index your code
hub / github.com/RustPython/RustPython / _match

Function _match

crates/sre_engine/src/engine.rs:283–892  ·  view source on GitHub ↗
(req: &Request<'_, S>, state: &mut State, mut ctx: MatchContext)

Source from the content-addressed store, hash-verified

281}
282
283fn _match<S: StrDrive>(req: &Request<'_, S>, state: &mut State, mut ctx: MatchContext) -> bool {
284 let mut context_stack = vec![];
285 let mut popped_result = false;
286
287 #[allow(
288 clippy::never_loop,
289 reason = "'result loop is not an actual loop but break label"
290 )]
291 'coro: loop {
292 popped_result = 'result: loop {
293 let yielded = 'context: loop {
294 match ctx.jump {
295 Jump::OpCode => {}
296 Jump::Assert1 => {
297 if popped_result {
298 ctx.skip_code_from(req, 1);
299 } else {
300 break 'result false;
301 }
302 }
303 Jump::AssertNot1 => {
304 if popped_result {
305 break 'result false;
306 }
307 state.marks.pop();
308 ctx.skip_code_from(req, 1);
309 }
310 Jump::Branch1 => {
311 let branch_offset = ctx.count as usize;
312 let next_length = ctx.peek_code(req, branch_offset) as isize;
313 if next_length == 0 {
314 state.marks.pop_discard();
315 break 'result false;
316 }
317 state.cursor = ctx.cursor;
318 let next_ctx = ctx.next_offset(branch_offset + 1, Jump::Branch2);
319 ctx.count += next_length;
320 break 'context next_ctx;
321 }
322 Jump::Branch2 => {
323 if popped_result {
324 break 'result true;
325 }
326 state.marks.pop_keep();
327 ctx.jump = Jump::Branch1;
328 continue 'context;
329 }
330 Jump::Repeat1 => {
331 state.repeat_stack.pop();
332 break 'result popped_result;
333 }
334 Jump::UntilBacktrace => {
335 if !popped_result {
336 state.repeat_stack[ctx.repeat_ctx_id].count -= 1;
337 state.cursor = ctx.cursor;
338 }
339 break 'result popped_result;
340 }

Callers 5

py_matchMethod · 0.85
searchMethod · 0.85
search_info_literalFunction · 0.85
search_info_charsetFunction · 0.85
_countFunction · 0.85

Calls 15

atFunction · 0.85
categoryFunction · 0.85
skip_code_fromMethod · 0.80
peek_codeMethod · 0.80
pop_discardMethod · 0.80
next_offsetMethod · 0.80
pop_keepMethod · 0.80
next_atMethod · 0.80
next_peek_fromMethod · 0.80
skip_codeMethod · 0.80
remaining_codesMethod · 0.80
can_successMethod · 0.80

Tested by

no test coverage detected