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

Side by Side Diff: src/preparser.cc

Issue 1315673009: Sloppy-mode let parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: clarify comment Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « src/preparser.h ('k') | src/scanner.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 6
7 #include "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 case Token::FUNCTION: 192 case Token::FUNCTION:
193 return ParseFunctionDeclaration(ok); 193 return ParseFunctionDeclaration(ok);
194 case Token::CLASS: 194 case Token::CLASS:
195 return ParseClassDeclaration(ok); 195 return ParseClassDeclaration(ok);
196 case Token::CONST: 196 case Token::CONST:
197 if (allow_const()) { 197 if (allow_const()) {
198 return ParseVariableStatement(kStatementListItem, ok); 198 return ParseVariableStatement(kStatementListItem, ok);
199 } 199 }
200 break; 200 break;
201 case Token::LET: 201 case Token::LET:
202 if (allow_let()) { 202 if (IsNextLetKeyword()) {
203 return ParseVariableStatement(kStatementListItem, ok); 203 return ParseVariableStatement(kStatementListItem, ok);
204 } 204 }
205 break; 205 break;
206 default: 206 default:
207 break; 207 break;
208 } 208 }
209 return ParseStatement(ok); 209 return ParseStatement(ok);
210 } 210 }
211 211
212 212
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 PreParser::Statement PreParser::ParseForStatement(bool* ok) { 886 PreParser::Statement PreParser::ParseForStatement(bool* ok) {
887 // ForStatement :: 887 // ForStatement ::
888 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement 888 // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement
889 889
890 Expect(Token::FOR, CHECK_OK); 890 Expect(Token::FOR, CHECK_OK);
891 Expect(Token::LPAREN, CHECK_OK); 891 Expect(Token::LPAREN, CHECK_OK);
892 bool is_let_identifier_expression = false; 892 bool is_let_identifier_expression = false;
893 if (peek() != Token::SEMICOLON) { 893 if (peek() != Token::SEMICOLON) {
894 ForEachStatement::VisitMode mode; 894 ForEachStatement::VisitMode mode;
895 if (peek() == Token::VAR || (peek() == Token::CONST && allow_const()) || 895 if (peek() == Token::VAR || (peek() == Token::CONST && allow_const()) ||
896 (peek() == Token::LET && allow_let())) { 896 (peek() == Token::LET && IsNextLetKeyword())) {
897 int decl_count; 897 int decl_count;
898 Scanner::Location first_initializer_loc = Scanner::Location::invalid(); 898 Scanner::Location first_initializer_loc = Scanner::Location::invalid();
899 Scanner::Location bindings_loc = Scanner::Location::invalid(); 899 Scanner::Location bindings_loc = Scanner::Location::invalid();
900 ParseVariableDeclarations(kForStatement, &decl_count, 900 ParseVariableDeclarations(kForStatement, &decl_count,
901 &first_initializer_loc, &bindings_loc, 901 &first_initializer_loc, &bindings_loc,
902 CHECK_OK); 902 CHECK_OK);
903 bool accept_IN = decl_count >= 1; 903 bool accept_IN = decl_count >= 1;
904 bool accept_OF = true; 904 bool accept_OF = true;
905 if (accept_IN && CheckInOrOf(accept_OF, &mode, ok)) { 905 if (accept_IN && CheckInOrOf(accept_OF, &mode, ok)) {
906 if (!*ok) return Statement::Default(); 906 if (!*ok) return Statement::Default();
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 1223
1224 DCHECK(!spread_pos.IsValid()); 1224 DCHECK(!spread_pos.IsValid());
1225 1225
1226 return Expression::Default(); 1226 return Expression::Default();
1227 } 1227 }
1228 1228
1229 #undef CHECK_OK 1229 #undef CHECK_OK
1230 1230
1231 1231
1232 } } // v8::internal 1232 } } // v8::internal
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | src/scanner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698