Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index b25a7b1af2054bb060ade921caa3911f5a20330f..10a266f90fdc22ef3dd07809b94be43abd3d7aa6 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -1158,13 +1158,17 @@ Statement* Parser::ParseModuleElement(ZoneList<const AstRawString*>* labels, |
| switch (peek()) { |
| case Token::FUNCTION: |
| return ParseFunctionDeclaration(NULL, ok); |
| - case Token::LET: |
| - case Token::CONST: |
| - return ParseVariableStatement(kModuleElement, NULL, ok); |
| case Token::IMPORT: |
| return ParseImportDeclaration(ok); |
| case Token::EXPORT: |
| return ParseExportDeclaration(ok); |
| + case Token::CONST: |
| + return ParseVariableStatement(kModuleElement, NULL, ok); |
| + case Token::LET: |
| + if (allow_harmony_scoping() && strict_mode() == STRICT) { |
|
marja
2014/07/09 14:24:45
(See below; isn't allow_harmony_scoping() necessar
|
| + return ParseVariableStatement(kModuleElement, NULL, ok); |
| + } |
| + // Fall through. |
| default: { |
| Statement* stmt = ParseStatement(labels, CHECK_OK); |
| // Handle 'module' as a context-sensitive keyword. |
| @@ -1463,6 +1467,8 @@ Statement* Parser::ParseExportDeclaration(bool* ok) { |
| // |
| // TODO(ES6): implement structuring ExportSpecifiers |
| + ASSERT(strict_mode() == STRICT); |
| + |
| Expect(Token::EXPORT, CHECK_OK); |
| Statement* result = NULL; |
| @@ -1545,9 +1551,13 @@ Statement* Parser::ParseBlockElement(ZoneList<const AstRawString*>* labels, |
| switch (peek()) { |
| case Token::FUNCTION: |
| return ParseFunctionDeclaration(NULL, ok); |
| - case Token::LET: |
| case Token::CONST: |
| return ParseVariableStatement(kModuleElement, NULL, ok); |
| + case Token::LET: |
| + if (allow_harmony_scoping() && strict_mode() == STRICT) { |
|
marja
2014/07/09 14:24:45
Ditto
|
| + return ParseVariableStatement(kModuleElement, NULL, ok); |
| + } |
| + // Fall through. |
| default: |
| return ParseStatement(labels, ok); |
| } |
| @@ -1583,11 +1593,6 @@ Statement* Parser::ParseStatement(ZoneList<const AstRawString*>* labels, |
| case Token::LBRACE: |
| return ParseBlock(labels, ok); |
| - case Token::CONST: // fall through |
| - case Token::LET: |
| - case Token::VAR: |
| - return ParseVariableStatement(kStatement, NULL, ok); |
| - |
| case Token::SEMICOLON: |
| Next(); |
| return factory()->NewEmptyStatement(RelocInfo::kNoPosition); |
| @@ -1659,6 +1664,15 @@ Statement* Parser::ParseStatement(ZoneList<const AstRawString*>* labels, |
| case Token::DEBUGGER: |
| return ParseDebuggerStatement(ok); |
| + case Token::VAR: |
| + case Token::CONST: |
| + return ParseVariableStatement(kStatement, NULL, ok); |
| + |
| + case Token::LET: |
| + if (allow_harmony_scoping() && strict_mode() == STRICT) { |
|
marja
2014/07/09 14:24:45
I don't think we need to check allow_harmony_scopi
rossberg
2014/07/09 14:28:50
Yes, this was on purpose -- I wanted to be able to
|
| + return ParseVariableStatement(kStatement, NULL, ok); |
| + } |
| + // Fall through. |
| default: |
| return ParseExpressionOrLabelledStatement(labels, ok); |
| } |
| @@ -2062,20 +2076,7 @@ Block* Parser::ParseVariableDeclarations( |
| } |
| is_const = true; |
| needs_init = true; |
| - } else if (peek() == Token::LET) { |
| - // ES6 Draft Rev4 section 12.2.1: |
| - // |
| - // LetDeclaration : let LetBindingList ; |
| - // |
| - // * It is a Syntax Error if the code that matches this production is not |
| - // contained in extended code. |
| - // |
| - // TODO(rossberg): make 'let' a legal identifier in sloppy mode. |
| - if (!allow_harmony_scoping() || strict_mode() == SLOPPY) { |
| - ReportMessage("illegal_let"); |
| - *ok = false; |
| - return NULL; |
| - } |
| + } else if (peek() == Token::LET && strict_mode() == STRICT) { |
| Consume(Token::LET); |
| if (var_context == kStatement) { |
| // Let declarations are only allowed in source element positions. |
| @@ -3114,7 +3115,7 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels, |
| } else { |
| init = variable_statement; |
| } |
| - } else if (peek() == Token::LET) { |
| + } else if (peek() == Token::LET && strict_mode() == STRICT) { |
| const AstRawString* name = NULL; |
| VariableDeclarationProperties decl_props = kHasNoInitializers; |
| Block* variable_statement = |