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>)
| 557 | /// `(?:^|[;{}])` then a body, and resume from the end of each match. `body` |
| 558 | /// returns (token, match_end) when the body matches at the position after the |
| 559 | /// anchor. |
| 560 | fn scan_anchored<F>(s: &[u8], mut body: F, out: &mut Vec<String>) |
| 561 | where |
| 562 | F: FnMut(&[u8], usize) -> Option<(String, usize)>, |
| 563 | { |
| 564 | let mut last = 0usize; |
| 565 | // The `^` branch consumes nothing and only exists at position 0. |
| 566 | if last == 0 { |
| 567 | if let Some((tok, end)) = body(s, 0) { |
| 568 | out.push(tok); |
| 569 | last = end; |
| 570 | } |
| 571 | } |
| 572 | let mut p = last; |
| 573 | while p < s.len() { |
| 574 | let ch = s[p]; |
| 575 | if ch == b';' || ch == b'{' || ch == b'}' { |
| 576 | if let Some((tok, end)) = body(s, p + 1) { |
| 577 | out.push(tok); |
| 578 | p = end; |
| 579 | continue; |
| 580 | } |
| 581 | } |
| 582 | p += 1; |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | /// INIT_RE body after the anchor: |