Computes the set of starting flags for the given position in text. This should only be used when executing the DFA in reverse over the input.
(
&self,
text: &[u8],
at: usize,
)
| 1461 | /// This should only be used when executing the DFA in reverse over the |
| 1462 | /// input. |
| 1463 | fn start_flags_reverse( |
| 1464 | &self, |
| 1465 | text: &[u8], |
| 1466 | at: usize, |
| 1467 | ) -> (EmptyFlags, StateFlags) { |
| 1468 | let mut empty_flags = EmptyFlags::default(); |
| 1469 | let mut state_flags = StateFlags::default(); |
| 1470 | empty_flags.start = at == text.len(); |
| 1471 | empty_flags.end = text.is_empty(); |
| 1472 | empty_flags.start_line = at == text.len() || text[at] == b'\n'; |
| 1473 | empty_flags.end_line = text.is_empty(); |
| 1474 | |
| 1475 | let is_word_last = |
| 1476 | at < text.len() && Byte::byte(text[at]).is_ascii_word(); |
| 1477 | let is_word = at > 0 && Byte::byte(text[at - 1]).is_ascii_word(); |
| 1478 | if is_word_last { |
| 1479 | state_flags.set_word(); |
| 1480 | } |
| 1481 | if is_word == is_word_last { |
| 1482 | empty_flags.not_word_boundary = true; |
| 1483 | } else { |
| 1484 | empty_flags.word_boundary = true; |
| 1485 | } |
| 1486 | (empty_flags, state_flags) |
| 1487 | } |
| 1488 | |
| 1489 | /// Returns a reference to a State given a pointer to it. |
| 1490 | fn state(&self, si: StatePtr) -> &State { |
no test coverage detected