Browse Source

Added "unimplemented" syntax errors (#901)

pull/903/head
Iban Eguia 4 years ago committed by GitHub
parent
commit
218b4715ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      boa/src/syntax/parser/error.rs
  2. 7
      boa/src/syntax/parser/statement/iteration/for_statement.rs
  3. 2
      test262

17
boa/src/syntax/parser/error.rs

@ -46,6 +46,11 @@ pub enum ParseError {
message: &'static str,
position: Position,
},
/// Unimplemented syntax error
Unimplemented {
message: &'static str,
position: Position,
},
}
impl ParseError {
@ -91,6 +96,11 @@ impl ParseError {
pub(super) fn lex(e: LexError) -> Self {
Self::Lex { err: e }
}
/// Creates a new `Unimplemented` parsing error.
pub(super) fn unimplemented(message: &'static str, position: Position) -> Self {
Self::Unimplemented { message, position }
}
}
impl fmt::Display for ParseError {
@ -156,6 +166,13 @@ impl fmt::Display for ParseError {
position.column_number()
),
Self::Lex { err } => fmt::Display::fmt(err, f),
Self::Unimplemented { message, position } => write!(
f,
"{} not yet implemented at line {}, col {}",
message,
position.line_number(),
position.column_number()
),
}
}
}

7
boa/src/syntax/parser/statement/iteration/for_statement.rs

@ -88,10 +88,13 @@ where
_ => Some(Expression::new(true, self.allow_yield, self.allow_await).parse(cursor)?),
};
// TODO: for..in, for..of
match cursor.peek(0)? {
Some(tok) if tok.kind() == &TokenKind::Keyword(Keyword::In) => {
unimplemented!("for...in statement")
// TODO: for...in
return Err(ParseError::unimplemented(
"for...in loops",
tok.span().start(),
));
}
Some(tok) if tok.kind() == &TokenKind::Keyword(Keyword::Of) && init.is_some() => {
let _ = cursor.next();

2
test262

@ -1 +1 @@
Subproject commit 3439564fcac38845669c8488d68f3d16965a7852
Subproject commit 0e7319c015fe935594f8bcafaedb0c94f7fec1df
Loading…
Cancel
Save