diff options
Diffstat (limited to 'src/parse/scanner.rs')
| -rw-r--r-- | src/parse/scanner.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/parse/scanner.rs b/src/parse/scanner.rs index 8e3e4278..edf28e17 100644 --- a/src/parse/scanner.rs +++ b/src/parse/scanner.rs @@ -106,6 +106,16 @@ impl<'s> Scanner<'s> { self.index } + /// The column index of a given index in the source string. + #[inline] + pub fn column(&self, index: usize) -> usize { + self.src[.. index] + .chars() + .rev() + .take_while(|&c| !is_newline(c)) + .count() + } + /// Jump to an index in the source string. #[inline] pub fn jump(&mut self, index: usize) { |
