Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: src/preparser.cc

Issue 15300018: Add initial parser support for harmony iteration (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase onto current master Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/preparser.h ('k') | src/prettyprinter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/preparser.h ('k') | src/prettyprinter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698