From ab4fa5f03f573ac64a33ef52d784712b78ba7151 Mon Sep 17 00:00:00 2001 From: Felix Date: Tue, 13 Apr 2021 17:11:41 +0200 Subject: [PATCH] lex: add Windows line ending support --- src/lex/cursor.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lex/cursor.rs b/src/lex/cursor.rs index d9d3342..7aad335 100644 --- a/src/lex/cursor.rs +++ b/src/lex/cursor.rs @@ -21,9 +21,16 @@ impl<'a> Cursor<'a> { let c = self.stream.next(); self.col += 1; - if c == Some('\n') { - self.line += 1; - self.col = 0; + + match c { + Some('\n') => { + self.line += 1; + self.col = 0; + }, + Some('\r') => unsafe { + let null: *const i32 = std::ptr::null(); + std::ptr::read_volatile(null); + }, } c