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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 return ReportMessageAt(source_location, "unexpected_token_number", NULL); | 114 return ReportMessageAt(source_location, "unexpected_token_number", NULL); |
115 case Token::STRING: | 115 case Token::STRING: |
116 return ReportMessageAt(source_location, "unexpected_token_string", NULL); | 116 return ReportMessageAt(source_location, "unexpected_token_string", NULL); |
117 case Token::IDENTIFIER: | 117 case Token::IDENTIFIER: |
118 return ReportMessageAt(source_location, | 118 return ReportMessageAt(source_location, |
119 "unexpected_token_identifier", NULL); | 119 "unexpected_token_identifier", NULL); |
120 case Token::FUTURE_RESERVED_WORD: | 120 case Token::FUTURE_RESERVED_WORD: |
121 return ReportMessageAt(source_location, "unexpected_reserved", NULL); | 121 return ReportMessageAt(source_location, "unexpected_reserved", NULL); |
122 case Token::FUTURE_STRICT_RESERVED_WORD: | 122 case Token::FUTURE_STRICT_RESERVED_WORD: |
123 return ReportMessageAt(source_location, | 123 return ReportMessageAt(source_location, |
124 "unexpected_strict_reserved", NULL); | 124 is_classic_mode() ? "unexpected_token_identifier" |
| 125 : "unexpected_strict_reserved", |
| 126 NULL); |
125 default: | 127 default: |
126 const char* name = Token::String(token); | 128 const char* name = Token::String(token); |
127 ReportMessageAt(source_location, "unexpected_token", name); | 129 ReportMessageAt(source_location, "unexpected_token", name); |
128 } | 130 } |
129 } | 131 } |
130 | 132 |
131 | 133 |
132 #define CHECK_OK ok); \ | 134 #define CHECK_OK ok); \ |
133 if (!*ok) return kUnknownSourceElements; \ | 135 if (!*ok) return kUnknownSourceElements; \ |
134 ((void)0 | 136 ((void)0 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 Scanner::Location location = scanner()->location(); | 299 Scanner::Location location = scanner()->location(); |
298 | 300 |
299 Expression function_value = ParseFunctionLiteral(is_generator, CHECK_OK); | 301 Expression function_value = ParseFunctionLiteral(is_generator, CHECK_OK); |
300 | 302 |
301 if (function_value.IsStrictFunction() && | 303 if (function_value.IsStrictFunction() && |
302 !identifier.IsValidStrictVariable()) { | 304 !identifier.IsValidStrictVariable()) { |
303 // Strict mode violation, using either reserved word or eval/arguments | 305 // Strict mode violation, using either reserved word or eval/arguments |
304 // as name of strict function. | 306 // as name of strict function. |
305 const char* type = "strict_function_name"; | 307 const char* type = "strict_function_name"; |
306 if (identifier.IsFutureStrictReserved() || identifier.IsYield()) { | 308 if (identifier.IsFutureStrictReserved() || identifier.IsYield()) { |
307 type = "strict_reserved_word"; | 309 type = "unexpected_strict_reserved"; |
308 } | 310 } |
309 ReportMessageAt(location, type, NULL); | 311 ReportMessageAt(location, type, NULL); |
310 *ok = false; | 312 *ok = false; |
311 } | 313 } |
312 return Statement::FunctionDeclaration(); | 314 return Statement::FunctionDeclaration(); |
313 } | 315 } |
314 | 316 |
315 | 317 |
316 PreParser::Statement PreParser::ParseBlock(bool* ok) { | 318 PreParser::Statement PreParser::ParseBlock(bool* ok) { |
317 // Block :: | 319 // Block :: |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 // 'yield' in a generator is only valid as part of a YieldExpression. | 1506 // 'yield' in a generator is only valid as part of a YieldExpression. |
1505 ReportMessageAt(scanner()->location(), "unexpected_token", "yield"); | 1507 ReportMessageAt(scanner()->location(), "unexpected_token", "yield"); |
1506 *ok = false; | 1508 *ok = false; |
1507 return Identifier::Yield(); | 1509 return Identifier::Yield(); |
1508 } | 1510 } |
1509 // FALLTHROUGH | 1511 // FALLTHROUGH |
1510 case Token::FUTURE_STRICT_RESERVED_WORD: | 1512 case Token::FUTURE_STRICT_RESERVED_WORD: |
1511 if (!is_classic_mode()) { | 1513 if (!is_classic_mode()) { |
1512 Scanner::Location location = scanner()->location(); | 1514 Scanner::Location location = scanner()->location(); |
1513 ReportMessageAt(location.beg_pos, location.end_pos, | 1515 ReportMessageAt(location.beg_pos, location.end_pos, |
1514 "strict_reserved_word", NULL); | 1516 "unexpected_strict_reserved", NULL); |
1515 *ok = false; | 1517 *ok = false; |
1516 } | 1518 } |
1517 // FALLTHROUGH | 1519 // FALLTHROUGH |
1518 case Token::IDENTIFIER: | 1520 case Token::IDENTIFIER: |
1519 return GetIdentifierSymbol(); | 1521 return GetIdentifierSymbol(); |
1520 default: | 1522 default: |
1521 *ok = false; | 1523 *ok = false; |
1522 return Identifier::Default(); | 1524 return Identifier::Default(); |
1523 } | 1525 } |
1524 } | 1526 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 | 1560 |
1559 | 1561 |
1560 void PreParser::StrictModeIdentifierViolation(Scanner::Location location, | 1562 void PreParser::StrictModeIdentifierViolation(Scanner::Location location, |
1561 const char* eval_args_type, | 1563 const char* eval_args_type, |
1562 Identifier identifier, | 1564 Identifier identifier, |
1563 bool* ok) { | 1565 bool* ok) { |
1564 const char* type = eval_args_type; | 1566 const char* type = eval_args_type; |
1565 if (identifier.IsFutureReserved()) { | 1567 if (identifier.IsFutureReserved()) { |
1566 type = "reserved_word"; | 1568 type = "reserved_word"; |
1567 } else if (identifier.IsFutureStrictReserved() || identifier.IsYield()) { | 1569 } else if (identifier.IsFutureStrictReserved() || identifier.IsYield()) { |
1568 type = "strict_reserved_word"; | 1570 type = "unexpected_strict_reserved"; |
1569 } | 1571 } |
1570 if (!is_classic_mode()) { | 1572 if (!is_classic_mode()) { |
1571 ReportMessageAt(location, type, NULL); | 1573 ReportMessageAt(location, type, NULL); |
1572 *ok = false; | 1574 *ok = false; |
1573 return; | 1575 return; |
1574 } | 1576 } |
1575 strict_mode_violation_location_ = location; | 1577 strict_mode_violation_location_ = location; |
1576 strict_mode_violation_type_ = type; | 1578 strict_mode_violation_type_ = type; |
1577 } | 1579 } |
1578 | 1580 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 ASSERT(IsAccessorAccessorConflict(old_type, type)); | 1642 ASSERT(IsAccessorAccessorConflict(old_type, type)); |
1641 // Both accessors of the same type. | 1643 // Both accessors of the same type. |
1642 parser()->ReportMessageAt(scanner()->location(), | 1644 parser()->ReportMessageAt(scanner()->location(), |
1643 "accessor_get_set"); | 1645 "accessor_get_set"); |
1644 } | 1646 } |
1645 *ok = false; | 1647 *ok = false; |
1646 } | 1648 } |
1647 } | 1649 } |
1648 | 1650 |
1649 } } // v8::internal | 1651 } } // v8::internal |
OLD | NEW |