Skip to content

Commit

Permalink
Merge 508a64b into fbb1077
Browse files Browse the repository at this point in the history
  • Loading branch information
Razican authored Oct 20, 2020
2 parents fbb1077 + 508a64b commit e112dbf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
17 changes: 17 additions & 0 deletions boa/src/syntax/parser/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ pub enum ParseError {
message: &'static str,
position: Position,
},
/// Unimplemented syntax error
Unimplemented {
message: &'static str,
position: Position,
},
}

impl ParseError {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 changes: 5 additions & 2 deletions boa/src/syntax/parser/statement/iteration/for_statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e112dbf

Please sign in to comment.