Extract a simple `$variable` or bare identifier ending at position `end` (exclusive). Skips trailing whitespace, then walks backwards through identifier characters. If a `$` prefix is found, includes it (producing e.g. `"$this"`, `"$var"`). Otherwise returns whatever identifier was collected (e.g. `"self"`, `"parent"`), which may be empty.
(chars: &[char], end: usize)
| 626 | /// `"$this"`, `"$var"`). Otherwise returns whatever identifier was |
| 627 | /// collected (e.g. `"self"`, `"parent"`), which may be empty. |
| 628 | fn extract_simple_variable(chars: &[char], end: usize) -> String { |
| 629 | let mut i = end; |
| 630 | // skip whitespace |
| 631 | while i > 0 && chars[i - 1] == ' ' { |
| 632 | i -= 1; |
| 633 | } |
| 634 | let var_end = i; |
| 635 | // walk back through identifier chars |
| 636 | while i > 0 && (chars[i - 1].is_alphanumeric() || chars[i - 1] == '_') { |
| 637 | i -= 1; |
| 638 | } |
| 639 | // expect `$` prefix |
| 640 | if i > 0 && chars[i - 1] == '$' { |
| 641 | i -= 1; |
| 642 | chars[i..var_end].iter().collect() |
| 643 | } else { |
| 644 | // no `$` — return whatever we collected (may be empty) |
| 645 | chars[i..var_end].iter().collect() |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | /// Extract the identifier/keyword before `::`. |
| 650 | /// |
no test coverage detected