From fb877fa524a39db7ce2ece3f9fb4ae020b252700 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Tue, 7 Jan 2020 19:58:13 -0500 Subject: [PATCH] Preserve multiline comments in lexer --- src/lexer.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lexer.rs b/src/lexer.rs index e7b0a2f..88ccd77 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -161,11 +161,20 @@ impl<'a> Lexer<'a> { self.buf.by_ref().take_while(|x| x != &'\n').for_each(drop); } '*' => { + let mut comment = String::new(); while let Some(tok) = self.buf.next() { - if tok == '*' && self.buf.next() == Some('/') { + if tok == '\n' { + self.pos.newline() + } else { + self.pos.next_char(); + } + if tok == '*' && self.buf.peek() == Some(&'/') { + self.buf.next(); break; } + comment.push(tok); } + return TokenKind::MultilineComment(comment) } _ => return TokenKind::Symbol(Symbol::Div), }