diff --git a/compiler/cl-lexer/src/lib.rs b/compiler/cl-lexer/src/lib.rs index 1c1d294..4ee8ec7 100644 --- a/compiler/cl-lexer/src/lib.rs +++ b/compiler/cl-lexer/src/lib.rs @@ -321,18 +321,21 @@ impl<'t> Lexer<'t> { /// Comments impl<'t> Lexer<'t> { fn line_comment(&mut self) -> LResult { + let mut comment = String::new(); while Ok('\n') != self.peek() { - self.consume()?; + comment.push(self.next()?); } - self.produce(Kind::Comment, ()) + self.produce(Kind::Comment, comment) } fn block_comment(&mut self) -> LResult { + let mut comment = String::new(); while let Ok(c) = self.next() { - if '*' == c && Ok('/') == self.next() { + if '*' == c && Ok('/') == self.peek() { break; } + comment.push(c); } - self.produce(Kind::Comment, ()) + self.consume()?.produce(Kind::Comment, comment) } } /// Identifiers