Computes the set of starting flags for the given position in text. This should only be used when executing the DFA forwards over the input.
(&self, text: &[u8], at: usize)
| 1436 | /// This should only be used when executing the DFA forwards over the |
| 1437 | /// input. |
| 1438 | fn start_flags(&self, text: &[u8], at: usize) -> (EmptyFlags, StateFlags) { |
| 1439 | let mut empty_flags = EmptyFlags::default(); |
| 1440 | let mut state_flags = StateFlags::default(); |
| 1441 | empty_flags.start = at == 0; |
| 1442 | empty_flags.end = text.is_empty(); |
| 1443 | empty_flags.start_line = at == 0 || text[at - 1] == b'\n'; |
| 1444 | empty_flags.end_line = text.is_empty(); |
| 1445 | |
| 1446 | let is_word_last = at > 0 && Byte::byte(text[at - 1]).is_ascii_word(); |
| 1447 | let is_word = at < text.len() && Byte::byte(text[at]).is_ascii_word(); |
| 1448 | if is_word_last { |
| 1449 | state_flags.set_word(); |
| 1450 | } |
| 1451 | if is_word == is_word_last { |
| 1452 | empty_flags.not_word_boundary = true; |
| 1453 | } else { |
| 1454 | empty_flags.word_boundary = true; |
| 1455 | } |
| 1456 | (empty_flags, state_flags) |
| 1457 | } |
| 1458 | |
| 1459 | /// Computes the set of starting flags for the given position in text. |
| 1460 | /// |
no test coverage detected