diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-07-31 22:59:14 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-08-01 00:00:36 +0200 |
| commit | 3c92bad9a7cd6b880de197806443ffcce2cac9d8 (patch) | |
| tree | 1faf79c66e23bc37711af16ad690a9878e28d348 /src/parse/scanner.rs | |
| parent | fbd3d191137aac8188ab8c6503d257d65d873972 (diff) | |
Pretty-printed diagnostics with traceback
Diffstat (limited to 'src/parse/scanner.rs')
| -rw-r--r-- | src/parse/scanner.rs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/parse/scanner.rs b/src/parse/scanner.rs index 9ee7641c..bb827255 100644 --- a/src/parse/scanner.rs +++ b/src/parse/scanner.rs @@ -47,17 +47,6 @@ impl<'s> Scanner<'s> { debug_assert_eq!(next, Some(c)); } - /// Consume the next char, coalescing `\r\n` to just `\n`. - #[inline] - pub fn eat_merging_crlf(&mut self) -> Option<char> { - if self.rest().starts_with("\r\n") { - self.index += 2; - Some('\n') - } else { - self.eat() - } - } - /// Eat chars while the condition is true. #[inline] pub fn eat_while<F>(&mut self, mut f: F) -> &'s str @@ -168,3 +157,15 @@ impl Debug for Scanner<'_> { write!(f, "Scanner({}|{})", self.eaten(), self.rest()) } } + +/// Whether this character denotes a newline. +#[inline] +pub fn is_newline(character: char) -> bool { + matches!( + character, + // Line Feed, Vertical Tab, Form Feed, Carriage Return. + '\n' | '\x0B' | '\x0C' | '\r' | + // Next Line, Line Separator, Paragraph Separator. + '\u{0085}' | '\u{2028}' | '\u{2029}' + ) +} |
