Find the next non-DEDENT token's position and source line. Returns ((line, col), line_str).
(
tokens: &[Token],
index: usize,
source: &'a str,
line_index: &LineIndex,
default_pos: (usize, usize),
)
| 434 | /// Find the next non-DEDENT token's position and source line. |
| 435 | /// Returns ((line, col), line_str). |
| 436 | fn next_non_dedent_info<'a>( |
| 437 | tokens: &[Token], |
| 438 | index: usize, |
| 439 | source: &'a str, |
| 440 | line_index: &LineIndex, |
| 441 | default_pos: (usize, usize), |
| 442 | ) -> ((usize, usize), &'a str) { |
| 443 | for future in &tokens[index..] { |
| 444 | match future.kind() { |
| 445 | TokenKind::Dedent => continue, |
| 446 | TokenKind::EndOfFile => return (default_pos, ""), |
| 447 | _ => { |
| 448 | let flc = line_index.line_column(future.range().start(), source); |
| 449 | let pos = (flc.line.get(), flc.column.to_zero_indexed()); |
| 450 | return (pos, source.full_line_str(future.range().start())); |
| 451 | } |
| 452 | } |
| 453 | } |
| 454 | (default_pos, "") |
| 455 | } |
| 456 | |
| 457 | /// Raise a SyntaxError with the given message and position. |
| 458 | fn raise_syntax_error( |
no test coverage detected