Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index 51e79bb14cf1c6519de925d6bb1434e06ccc225f..29e010b87260deabbcba23f52d828e4108ac7ddf 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -1711,22 +1711,21 @@ Statement* Parser::ParseStatement(ZoneList<const AstRawString*>* labels, |
| return ParseFunctionDeclaration(NULL, ok); |
| } |
| - case Token::CLASS: |
| - return ParseClassDeclaration(NULL, ok); |
| - |
| case Token::DEBUGGER: |
| return ParseDebuggerStatement(ok); |
| case Token::VAR: |
| - case Token::CONST: |
| return ParseVariableStatement(kStatement, NULL, ok); |
| - case Token::LET: |
| - DCHECK(allow_harmony_scoping()); |
| - if (strict_mode() == STRICT) { |
| + case Token::CONST: |
| + // In ES6 CONST is not allowed as a Statement , only as a |
| + // LexicalDeclaration, however we continue to allow it in sloppy mode for |
| + // backwards compatibility. |
| + if (strict_mode() == SLOPPY) { |
| return ParseVariableStatement(kStatement, NULL, ok); |
| } |
| - // Fall through. |
| + |
| + // Fall through. |
| default: |
| return ParseExpressionOrLabelledStatement(labels, ok); |
| } |
| @@ -2438,6 +2437,26 @@ Statement* Parser::ParseExpressionOrLabelledStatement( |
| // ExpressionStatement | LabelledStatement :: |
| // Expression ';' |
| // Identifier ':' Statement |
| + // |
| + // ExpressionStatement[Yield] : |
| + // [lookahead ∉ {{, function, class, let [}] Expression[In, ?Yield] ; |
| + |
| + switch (peek()) { |
| + case Token::FUNCTION: |
| + case Token::LBRACE: |
| + UNREACHABLE(); // Always handled by the callers. |
| + case Token::CLASS: |
| + ReportUnexpectedToken(Next()); |
| + *ok = false; |
| + return nullptr; |
|
adamk
2015/01/23 20:11:39
Nit: the rest of the code in this file still uses
|
| + |
| + // TODO(arv): Handle `let [` |
| + // https://code.google.com/p/v8/issues/detail?id=3847 |
| + |
| + default: |
| + break; |
| + } |
| + |
| int pos = peek_position(); |
| bool starts_with_idenfifier = peek_any_identifier(); |
| Expression* expr = ParseExpression(true, CHECK_OK); |