The `(?:(?:static|const|extern|register|volatile)\s+)*` modifier loop: greedy positions after 0..=k iterations, for the k-descending backtrack the INIT/ARRAY skeletons need. No two alternatives share a prefix, so at most one literal can match at a position; an alternative that matches without trailing `\s+` ends the loop (JS: iteration fails, no other alt can fire).
(s: &[u8], start: usize)
| 514 | /// INIT/ARRAY skeletons need. No two alternatives share a prefix, so at most |
| 515 | /// one literal can match at a position; an alternative that matches without |
| 516 | /// trailing `\s+` ends the loop (JS: iteration fails, no other alt can fire). |
| 517 | fn modifier_positions(s: &[u8], start: usize) -> Vec<usize> { |
| 518 | let mut stack = vec![start]; |
| 519 | loop { |
| 520 | let cur = *stack.last().unwrap(); |
| 521 | let mut advanced = None; |
| 522 | for m in MODIFIERS { |
| 523 | if s.len() >= cur + m.len() && &s[cur..cur + m.len()] == m { |
| 524 | let e = cur + m.len(); |
| 525 | let w = skip_jsws(s, e); |
| 526 | if w > e { |
| 527 | advanced = Some(w); |
| 528 | } |
| 529 | break; // exactly one alternative can literal-match here |
| 530 | } |
| 531 | } |
| 532 | match advanced { |
| 533 | Some(w) => stack.push(w), |
| 534 | None => return stack, |
| 535 | } |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | /// `\[[^\]]*\]` at `i` (the INIT/ARRAY declarator form — the class admits |