Index: src/preparser.cc |
diff --git a/src/preparser.cc b/src/preparser.cc |
index 3bf88cad352935a342a24bf2e1e76563649539a8..243a3ed34c52e20ca31b48d4bcffadd25bc8c8dd 100644 |
--- a/src/preparser.cc |
+++ b/src/preparser.cc |
@@ -659,6 +659,17 @@ PreParser::Statement PreParser::ParseWhileStatement(bool* ok) { |
} |
+bool PreParser::CheckInOrOf() { |
+ if (peek() == i::Token::IN || |
+ (allow_for_of() && |
+ scanner_->is_next_contextual_keyword(v8::internal::CStrVector("of")))) { |
+ Next(); |
+ return true; |
+ } |
+ return false; |
+} |
+ |
+ |
PreParser::Statement PreParser::ParseForStatement(bool* ok) { |
// ForStatement :: |
// 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement |
@@ -675,8 +686,7 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) { |
kForStatement, &decl_props, &decl_count, CHECK_OK); |
bool accept_IN = decl_count == 1 && |
!(is_let && decl_props == kHasInitializers); |
- if (peek() == i::Token::IN && accept_IN) { |
- Expect(i::Token::IN, CHECK_OK); |
+ if (accept_IN && CheckInOrOf()) { |
ParseExpression(true, CHECK_OK); |
Expect(i::Token::RPAREN, CHECK_OK); |
@@ -685,8 +695,7 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) { |
} |
} else { |
ParseExpression(false, CHECK_OK); |
- if (peek() == i::Token::IN) { |
- Expect(i::Token::IN, CHECK_OK); |
+ if (CheckInOrOf()) { |
ParseExpression(true, CHECK_OK); |
Expect(i::Token::RPAREN, CHECK_OK); |