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

Side by Side Diff: src/parser.cc

Issue 1295883002: Sloppy-mode let parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: More sloppy let tests Created 5 years, 4 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 | « no previous file | src/preparser.h » ('j') | src/preparser.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/ast-literal-reindexer.h" 9 #include "src/ast-literal-reindexer.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 } 1384 }
1385 return ParseClassDeclaration(NULL, ok); 1385 return ParseClassDeclaration(NULL, ok);
1386 case Token::CONST: 1386 case Token::CONST:
1387 if (allow_const()) { 1387 if (allow_const()) {
1388 return ParseVariableStatement(kStatementListItem, NULL, ok); 1388 return ParseVariableStatement(kStatementListItem, NULL, ok);
1389 } 1389 }
1390 break; 1390 break;
1391 case Token::VAR: 1391 case Token::VAR:
1392 return ParseVariableStatement(kStatementListItem, NULL, ok); 1392 return ParseVariableStatement(kStatementListItem, NULL, ok);
1393 case Token::LET: 1393 case Token::LET:
1394 if (allow_let()) { 1394 if (IsLetKeyword()) {
1395 return ParseVariableStatement(kStatementListItem, NULL, ok); 1395 return ParseVariableStatement(kStatementListItem, NULL, ok);
1396 } 1396 }
1397 break; 1397 break;
1398 default: 1398 default:
1399 break; 1399 break;
1400 } 1400 }
1401 return ParseStatement(NULL, ok); 1401 return ParseStatement(NULL, ok);
1402 } 1402 }
1403 1403
1404 1404
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2631 ? MessageTemplate::kStrongConstructorThis 2631 ? MessageTemplate::kStrongConstructorThis
2632 : MessageTemplate::kStrongConstructorSuper); 2632 : MessageTemplate::kStrongConstructorSuper);
2633 *ok = false; 2633 *ok = false;
2634 return nullptr; 2634 return nullptr;
2635 } 2635 }
2636 } 2636 }
2637 return factory()->NewExpressionStatement(expr, pos); 2637 return factory()->NewExpressionStatement(expr, pos);
2638 } 2638 }
2639 break; 2639 break;
2640 2640
2641 // TODO(arv): Handle `let [`
2642 // https://code.google.com/p/v8/issues/detail?id=3847
2643
2644 default: 2641 default:
2645 break; 2642 break;
2646 } 2643 }
2647 2644
2648 bool starts_with_idenfifier = peek_any_identifier(); 2645 bool starts_with_idenfifier = peek_any_identifier();
2649 Expression* expr = ParseExpression(true, CHECK_OK); 2646 Expression* expr = ParseExpression(true, CHECK_OK);
2650 if (peek() == Token::COLON && starts_with_idenfifier && expr != NULL && 2647 if (peek() == Token::COLON && starts_with_idenfifier && expr != NULL &&
2651 expr->AsVariableProxy() != NULL && 2648 expr->AsVariableProxy() != NULL &&
2652 !expr->AsVariableProxy()->is_this()) { 2649 !expr->AsVariableProxy()->is_this()) {
2653 // Expression is a single identifier, and not, e.g., a parenthesized 2650 // Expression is a single identifier, and not, e.g., a parenthesized
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
3508 Scope* saved_scope = scope_; 3505 Scope* saved_scope = scope_;
3509 Scope* for_scope = NewScope(scope_, BLOCK_SCOPE); 3506 Scope* for_scope = NewScope(scope_, BLOCK_SCOPE);
3510 scope_ = for_scope; 3507 scope_ = for_scope;
3511 Expect(Token::FOR, CHECK_OK); 3508 Expect(Token::FOR, CHECK_OK);
3512 Expect(Token::LPAREN, CHECK_OK); 3509 Expect(Token::LPAREN, CHECK_OK);
3513 for_scope->set_start_position(scanner()->location().beg_pos); 3510 for_scope->set_start_position(scanner()->location().beg_pos);
3514 bool is_let_identifier_expression = false; 3511 bool is_let_identifier_expression = false;
3515 DeclarationParsingResult parsing_result; 3512 DeclarationParsingResult parsing_result;
3516 if (peek() != Token::SEMICOLON) { 3513 if (peek() != Token::SEMICOLON) {
3517 if (peek() == Token::VAR || (peek() == Token::CONST && allow_const()) || 3514 if (peek() == Token::VAR || (peek() == Token::CONST && allow_const()) ||
3518 (peek() == Token::LET && allow_let())) { 3515 (peek() == Token::LET && IsLetKeyword())) {
3519 ParseVariableDeclarations(kForStatement, &parsing_result, CHECK_OK); 3516 ParseVariableDeclarations(kForStatement, &parsing_result, CHECK_OK);
3520 is_const = parsing_result.descriptor.mode == CONST; 3517 is_const = parsing_result.descriptor.mode == CONST;
3521 3518
3522 int num_decl = parsing_result.declarations.length(); 3519 int num_decl = parsing_result.declarations.length();
3523 bool accept_IN = num_decl >= 1; 3520 bool accept_IN = num_decl >= 1;
3524 bool accept_OF = true; 3521 bool accept_OF = true;
3525 ForEachStatement::VisitMode mode; 3522 ForEachStatement::VisitMode mode;
3526 int each_beg_pos = scanner()->location().beg_pos; 3523 int each_beg_pos = scanner()->location().beg_pos;
3527 int each_end_pos = scanner()->location().end_pos; 3524 int each_end_pos = scanner()->location().end_pos;
3528 3525
(...skipping 2486 matching lines...) Expand 10 before | Expand all | Expand 10 after
6015 Expression* Parser::SpreadCallNew(Expression* function, 6012 Expression* Parser::SpreadCallNew(Expression* function,
6016 ZoneList<v8::internal::Expression*>* args, 6013 ZoneList<v8::internal::Expression*>* args,
6017 int pos) { 6014 int pos) {
6018 args->InsertAt(0, function, zone()); 6015 args->InsertAt(0, function, zone());
6019 6016
6020 return factory()->NewCallRuntime( 6017 return factory()->NewCallRuntime(
6021 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 6018 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
6022 } 6019 }
6023 } // namespace internal 6020 } // namespace internal
6024 } // namespace v8 6021 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/preparser.h » ('j') | src/preparser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698