| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 | 372 |
| 373 PreParser::Statement PreParser::ParseBlock(bool* ok) { | 373 PreParser::Statement PreParser::ParseBlock(bool* ok) { |
| 374 // Block :: | 374 // Block :: |
| 375 // '{' Statement* '}' | 375 // '{' Statement* '}' |
| 376 | 376 |
| 377 // Note that a Block does not introduce a new execution scope! | 377 // Note that a Block does not introduce a new execution scope! |
| 378 // (ECMA-262, 3rd, 12.2) | 378 // (ECMA-262, 3rd, 12.2) |
| 379 // | 379 // |
| 380 Expect(Token::LBRACE, CHECK_OK); | 380 Expect(Token::LBRACE, CHECK_OK); |
| 381 while (peek() != Token::RBRACE) { | 381 while (peek() != Token::RBRACE) { |
| 382 if (FLAG_harmony_scoping && strict_mode() == STRICT) { | 382 if (allow_harmony_scoping() && strict_mode() == STRICT) { |
| 383 ParseSourceElement(CHECK_OK); | 383 ParseSourceElement(CHECK_OK); |
| 384 } else { | 384 } else { |
| 385 ParseStatement(CHECK_OK); | 385 ParseStatement(CHECK_OK); |
| 386 } | 386 } |
| 387 } | 387 } |
| 388 Expect(Token::RBRACE, ok); | 388 Expect(Token::RBRACE, ok); |
| 389 return Statement::Default(); | 389 return Statement::Default(); |
| 390 } | 390 } |
| 391 | 391 |
| 392 | 392 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 // ConstDeclaration : const ConstBinding (',' ConstBinding)* ';' | 437 // ConstDeclaration : const ConstBinding (',' ConstBinding)* ';' |
| 438 // | 438 // |
| 439 // * It is a Syntax Error if the code that matches this production is not | 439 // * It is a Syntax Error if the code that matches this production is not |
| 440 // contained in extended code. | 440 // contained in extended code. |
| 441 // | 441 // |
| 442 // However disallowing const in sloppy mode will break compatibility with | 442 // However disallowing const in sloppy mode will break compatibility with |
| 443 // existing pages. Therefore we keep allowing const with the old | 443 // existing pages. Therefore we keep allowing const with the old |
| 444 // non-harmony semantics in sloppy mode. | 444 // non-harmony semantics in sloppy mode. |
| 445 Consume(Token::CONST); | 445 Consume(Token::CONST); |
| 446 if (strict_mode() == STRICT) { | 446 if (strict_mode() == STRICT) { |
| 447 if (FLAG_harmony_scoping) { | 447 if (allow_harmony_scoping()) { |
| 448 if (var_context != kSourceElement && var_context != kForStatement) { | 448 if (var_context != kSourceElement && var_context != kForStatement) { |
| 449 ReportMessageAt(scanner()->peek_location(), "unprotected_const"); | 449 ReportMessageAt(scanner()->peek_location(), "unprotected_const"); |
| 450 *ok = false; | 450 *ok = false; |
| 451 return Statement::Default(); | 451 return Statement::Default(); |
| 452 } | 452 } |
| 453 require_initializer = true; | 453 require_initializer = true; |
| 454 } else { | 454 } else { |
| 455 Scanner::Location location = scanner()->peek_location(); | 455 Scanner::Location location = scanner()->peek_location(); |
| 456 ReportMessageAt(location, "strict_const"); | 456 ReportMessageAt(location, "strict_const"); |
| 457 *ok = false; | 457 *ok = false; |
| 458 return Statement::Default(); | 458 return Statement::Default(); |
| 459 } | 459 } |
| 460 } | 460 } |
| 461 } else if (peek() == Token::LET) { | 461 } else if (peek() == Token::LET) { |
| 462 // ES6 Draft Rev4 section 12.2.1: | 462 // ES6 Draft Rev4 section 12.2.1: |
| 463 // | 463 // |
| 464 // LetDeclaration : let LetBindingList ; | 464 // LetDeclaration : let LetBindingList ; |
| 465 // | 465 // |
| 466 // * It is a Syntax Error if the code that matches this production is not | 466 // * It is a Syntax Error if the code that matches this production is not |
| 467 // contained in extended code. | 467 // contained in extended code. |
| 468 // | 468 // |
| 469 // TODO(rossberg): make 'let' a legal identifier in sloppy mode. | 469 // TODO(rossberg): make 'let' a legal identifier in sloppy mode. |
| 470 if (!FLAG_harmony_scoping || strict_mode() == SLOPPY) { | 470 if (!allow_harmony_scoping() || strict_mode() == SLOPPY) { |
| 471 ReportMessageAt(scanner()->peek_location(), "illegal_let"); | 471 ReportMessageAt(scanner()->peek_location(), "illegal_let"); |
| 472 *ok = false; | 472 *ok = false; |
| 473 return Statement::Default(); | 473 return Statement::Default(); |
| 474 } | 474 } |
| 475 Consume(Token::LET); | 475 Consume(Token::LET); |
| 476 if (var_context != kSourceElement && | 476 if (var_context != kSourceElement && |
| 477 var_context != kForStatement) { | 477 var_context != kForStatement) { |
| 478 ReportMessageAt(scanner()->peek_location(), "unprotected_let"); | 478 ReportMessageAt(scanner()->peek_location(), "unprotected_let"); |
| 479 *ok = false; | 479 *ok = false; |
| 480 return Statement::Default(); | 480 return Statement::Default(); |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 | 977 |
| 978 | 978 |
| 979 void PreParser::LogSymbol() { | 979 void PreParser::LogSymbol() { |
| 980 if (log_->ShouldLogSymbols()) { | 980 if (log_->ShouldLogSymbols()) { |
| 981 scanner()->LogSymbol(log_, position()); | 981 scanner()->LogSymbol(log_, position()); |
| 982 } | 982 } |
| 983 } | 983 } |
| 984 | 984 |
| 985 | 985 |
| 986 } } // v8::internal | 986 } } // v8::internal |
| OLD | NEW |