Skip to content

Commit

Permalink
Added check to ignore semicolon in parser
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelOnFira committed Oct 24, 2020
1 parent 4eb2ed4 commit 1e67661
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions boa/src/syntax/parser/statement/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ impl StatementList {
if break_nodes.contains(token.kind()) {
break;
}
else if token.kind() == &TokenKind::Punctuator(Punctuator::Semicolon) {
cursor.next()?;
continue;
}
} else {
return Err(ParseError::AbruptEnd);
}
Expand All @@ -285,8 +289,8 @@ impl StatementList {

items.push(item);

// move the cursor forward for any consecutive semicolon.
while cursor.next_if(Punctuator::Semicolon)?.is_some() {}
// // move the cursor forward for any consecutive semicolon.
// while cursor.next_if(Punctuator::Semicolon)?.is_some() {}
}

items.sort_by(Node::hoistable_order);
Expand Down Expand Up @@ -314,6 +318,10 @@ where
return Err(ParseError::unexpected(token.clone(), None));
}
}
Some(token) if token.kind() == &TokenKind::Punctuator(Punctuator::Semicolon) => {
cursor.next()?;
continue;
}
None => {
if self.break_when_closingbraces {
return Err(ParseError::AbruptEnd);
Expand All @@ -332,9 +340,6 @@ where
)
.parse(cursor)?;
items.push(item);

// move the cursor forward for any consecutive semicolon.
while cursor.next_if(Punctuator::Semicolon)?.is_some() {}
}

items.sort_by(Node::hoistable_order);
Expand Down

0 comments on commit 1e67661

Please sign in to comment.