MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / scan_anchored

Function scan_anchored

codegraph-kernel/src/cfnptr.rs:538–562  ·  view source on GitHub ↗

Anchor-skeleton driver shared by INIT_RE and ARRAY_TABLE_RE: both match `(?:^|[;{}])` then a body, and resume from the end of each match. `body` returns (token, match_end) when the body matches at the position after the anchor.

(s: &[u8], mut body: F, out: &mut Vec<String>)

Source from the content-addressed store, hash-verified

536/// `(?:^|[;{}])` then a body, and resume from the end of each match. `body`
537/// returns (token, match_end) when the body matches at the position after the
538/// anchor.
539fn scan_anchored<F>(s: &[u8], mut body: F, out: &mut Vec<String>)
540where
541 F: FnMut(&[u8], usize) -> Option<(String, usize)>,
542{
543 let mut last = 0usize;
544 // The `^` branch consumes nothing and only exists at position 0.
545 if last == 0 {
546 if let Some((tok, end)) = body(s, 0) {
547 out.push(tok);
548 last = end;
549 }
550 }
551 let mut p = last;
552 while p < s.len() {
553 let ch = s[p];
554 if ch == b';' || ch == b'{' || ch == b'}' {
555 if let Some((tok, end)) = body(s, p + 1) {
556 out.push(tok);
557 p = end;
558 continue;
559 }
560 }
561 p += 1;
562 }
563}
564
565/// INIT_RE body after the anchor:

Callers 1

scan_fileFunction · 0.85

Calls 1

lenMethod · 0.80

Tested by

no test coverage detected