Skip to content

Commit

Permalink
Improve lexer by make cursor iterate over bytes (#915)
Browse files Browse the repository at this point in the history
  • Loading branch information
jevancc authored Dec 3, 2020
1 parent c5c804d commit cc47385
Show file tree
Hide file tree
Showing 11 changed files with 702 additions and 362 deletions.
10 changes: 5 additions & 5 deletions boa/src/syntax/lexer/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ impl<R> Tokenizer<R> for SingleLineComment {

// Skip either to the end of the line or to the end of the input
while let Some(ch) = cursor.peek()? {
if ch == '\n' {
if ch == b'\n' {
break;
} else {
// Consume char.
cursor.next_char()?.expect("Comment character vansihed");
cursor.next_byte()?.expect("Comment character vansihed");
}
}
Ok(Token::new(
Expand Down Expand Up @@ -66,10 +66,10 @@ impl<R> Tokenizer<R> for MultiLineComment {

let mut new_line = false;
loop {
if let Some(ch) = cursor.next_char()? {
if ch == '*' && cursor.next_is('/')? {
if let Some(ch) = cursor.next_byte()? {
if ch == b'*' && cursor.next_is(b'/')? {
break;
} else if ch == '\n' {
} else if ch == b'\n' {
new_line = true;
}
} else {
Expand Down
Loading

0 comments on commit cc47385

Please sign in to comment.