Skip to content

Commit

Permalink
fix: add unicode terminator to line comment
Browse files Browse the repository at this point in the history
  • Loading branch information
creampnx-x committed Sep 24, 2022
1 parent 77e739c commit 783f8e2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions boa_engine/src/syntax/lexer/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ impl<R> Tokenizer<R> for SingleLineComment {
let _timer = Profiler::global().start_event("SingleLineComment", "Lexing");

// Skip either to the end of the line or to the end of the input
while let Some(ch) = cursor.peek()? {
if ch == b'\n' || ch == b'\r' {
break;
}
// Consume char.
cursor.next_byte()?.expect("Comment character vanished");
while let Some(ch) = cursor.next_char()? {
let tried_ch = char::try_from(ch);
match tried_ch {
Ok(c) if c == '\r' || c == '\n' || c == '\u{2028}' || c == '\u{2029}' => {
break;
}
_ => {}
};
}
Ok(Token::new(
TokenKind::Comment,
Expand Down

0 comments on commit 783f8e2

Please sign in to comment.