Preserve multiline comments in lexer
This commit is contained in:
parent
bc32a5a143
commit
fb877fa524
11
src/lexer.rs
11
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),
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user