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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 // 'try' Block Catch | 692 // 'try' Block Catch |
693 // 'try' Block Finally | 693 // 'try' Block Finally |
694 // 'try' Block Catch Finally | 694 // 'try' Block Catch Finally |
695 // | 695 // |
696 // Catch :: | 696 // Catch :: |
697 // 'catch' '(' Identifier ')' Block | 697 // 'catch' '(' Identifier ')' Block |
698 // | 698 // |
699 // Finally :: | 699 // Finally :: |
700 // 'finally' Block | 700 // 'finally' Block |
701 | 701 |
702 // In preparsing, allow any number of catch/finally blocks, including zero | |
703 // of both. | |
704 | |
705 Expect(Token::TRY, CHECK_OK); | 702 Expect(Token::TRY, CHECK_OK); |
706 | 703 |
707 ParseBlock(CHECK_OK); | 704 ParseBlock(CHECK_OK); |
708 | 705 |
709 bool catch_or_finally_seen = false; | 706 Token::Value tok = peek(); |
710 if (peek() == Token::CATCH) { | 707 if (tok != Token::CATCH && tok != Token::FINALLY) { |
| 708 ReportMessageAt(scanner()->location(), "no_catch_or_finally", NULL); |
| 709 *ok = false; |
| 710 return Statement::Default(); |
| 711 } |
| 712 if (tok == Token::CATCH) { |
711 Consume(Token::CATCH); | 713 Consume(Token::CATCH); |
712 Expect(Token::LPAREN, CHECK_OK); | 714 Expect(Token::LPAREN, CHECK_OK); |
713 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); | 715 ParseIdentifier(kDontAllowEvalOrArguments, CHECK_OK); |
714 Expect(Token::RPAREN, CHECK_OK); | 716 Expect(Token::RPAREN, CHECK_OK); |
715 { Scope::InsideWith iw(scope_); | 717 { Scope::InsideWith iw(scope_); |
716 ParseBlock(CHECK_OK); | 718 ParseBlock(CHECK_OK); |
717 } | 719 } |
718 catch_or_finally_seen = true; | 720 tok = peek(); |
719 } | 721 } |
720 if (peek() == Token::FINALLY) { | 722 if (tok == Token::FINALLY) { |
721 Consume(Token::FINALLY); | 723 Consume(Token::FINALLY); |
722 ParseBlock(CHECK_OK); | 724 ParseBlock(CHECK_OK); |
723 catch_or_finally_seen = true; | |
724 } | |
725 if (!catch_or_finally_seen) { | |
726 *ok = false; | |
727 } | 725 } |
728 return Statement::Default(); | 726 return Statement::Default(); |
729 } | 727 } |
730 | 728 |
731 | 729 |
732 PreParser::Statement PreParser::ParseDebuggerStatement(bool* ok) { | 730 PreParser::Statement PreParser::ParseDebuggerStatement(bool* ok) { |
733 // In ECMA-262 'debugger' is defined as a reserved keyword. In some browser | 731 // In ECMA-262 'debugger' is defined as a reserved keyword. In some browser |
734 // contexts this is used as a statement which invokes the debugger as if a | 732 // contexts this is used as a statement which invokes the debugger as if a |
735 // break point is present. | 733 // break point is present. |
736 // DebuggerStatement :: | 734 // DebuggerStatement :: |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 ASSERT(IsAccessorAccessorConflict(old_type, type)); | 1596 ASSERT(IsAccessorAccessorConflict(old_type, type)); |
1599 // Both accessors of the same type. | 1597 // Both accessors of the same type. |
1600 parser()->ReportMessageAt(scanner()->location(), | 1598 parser()->ReportMessageAt(scanner()->location(), |
1601 "accessor_get_set"); | 1599 "accessor_get_set"); |
1602 } | 1600 } |
1603 *ok = false; | 1601 *ok = false; |
1604 } | 1602 } |
1605 } | 1603 } |
1606 | 1604 |
1607 } } // v8::internal | 1605 } } // v8::internal |
OLD | NEW |