| Index: src/preparser.cc
|
| diff --git a/src/preparser.cc b/src/preparser.cc
|
| index b1541f616afe133554881e99aec4f71a9f5e45e0..a104678f9fb0f43a9ea6a75d9bf8c0d127536973 100644
|
| --- a/src/preparser.cc
|
| +++ b/src/preparser.cc
|
| @@ -496,15 +496,11 @@ PreParser::Statement PreParser::ParseVariableDeclarations(
|
| // VariableDeclarations ::
|
| // ('var' | 'const') (Identifier ('=' AssignmentExpression)?)+[',']
|
| //
|
| - // The ES6 Draft Rev3 specifies the following grammar for const declarations
|
| - //
|
| // ConstDeclaration ::
|
| // const ConstBinding (',' ConstBinding)* ';'
|
| - // ConstBinding ::
|
| - // Identifier '=' AssignmentExpression
|
| //
|
| - // TODO(ES6):
|
| // ConstBinding ::
|
| + // Identifier '=' AssignmentExpression
|
| // BindingPattern '=' AssignmentExpression
|
| bool require_initializer = false;
|
| bool is_strict_const = false;
|
| @@ -980,6 +976,7 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) {
|
| //
|
| // Catch ::
|
| // 'catch' '(' Identifier ')' Block
|
| + // 'catch' '(' BindingPattern ')' Block
|
| //
|
| // Finally ::
|
| // 'finally' Block
|
| @@ -997,11 +994,29 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) {
|
| if (tok == Token::CATCH) {
|
| Consume(Token::CATCH);
|
| Expect(Token::LPAREN, CHECK_OK);
|
| - ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK);
|
| +
|
| + ExpressionClassifier pattern_classifier;
|
| + Token::Value next = peek();
|
| + PreParserExpression pattern =
|
| + ParsePrimaryExpression(&pattern_classifier, CHECK_OK);
|
| + ValidateBindingPattern(&pattern_classifier, CHECK_OK);
|
| +
|
| + if (!allow_harmony_destructuring() && !pattern.IsIdentifier()) {
|
| + ReportUnexpectedToken(next);
|
| + *ok = false;
|
| + return Statement::Default();
|
| + }
|
| +
|
| Expect(Token::RPAREN, CHECK_OK);
|
| - {
|
| - Scope* with_scope = NewScope(scope_, WITH_SCOPE);
|
| - BlockState block_state(&scope_, with_scope);
|
| +
|
| + if (pattern.IsIdentifier()) {
|
| + Scope* catch_scope = NewScope(scope_, CATCH_SCOPE);
|
| + BlockState block_state(&scope_, catch_scope);
|
| + ParseBlock(CHECK_OK);
|
| + } else {
|
| + Scope* catch_scope = NewScope(scope_, CATCH_SCOPE);
|
| + Scope* destruct_scope = NewScope(catch_scope, BLOCK_SCOPE);
|
| + BlockState block_state(&scope_, destruct_scope);
|
| ParseBlock(CHECK_OK);
|
| }
|
| tok = peek();
|
|
|