OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Features shared by parsing and pre-parsing scanners. | 5 // Features shared by parsing and pre-parsing scanners. |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 token = Select('=', Token::ASSIGN_SHR, Token::SHR); | 459 token = Select('=', Token::ASSIGN_SHR, Token::SHR); |
460 } else { | 460 } else { |
461 token = Token::SAR; | 461 token = Token::SAR; |
462 } | 462 } |
463 } else { | 463 } else { |
464 token = Token::GT; | 464 token = Token::GT; |
465 } | 465 } |
466 break; | 466 break; |
467 | 467 |
468 case '=': | 468 case '=': |
469 // = == === | 469 // = == === => |
470 Advance(); | 470 Advance(); |
471 if (c0_ == '=') { | 471 if (c0_ == '=') { |
472 token = Select('=', Token::EQ_STRICT, Token::EQ); | 472 token = Select('=', Token::EQ_STRICT, Token::EQ); |
| 473 } else if (c0_ == '>') { |
| 474 token = Select(Token::ARROW); |
473 } else { | 475 } else { |
474 token = Token::ASSIGN; | 476 token = Token::ASSIGN; |
475 } | 477 } |
476 break; | 478 break; |
477 | 479 |
478 case '!': | 480 case '!': |
479 // ! != !== | 481 // ! != !== |
480 Advance(); | 482 Advance(); |
481 if (c0_ == '=') { | 483 if (c0_ == '=') { |
482 token = Select('=', Token::NE_STRICT, Token::NE); | 484 token = Select('=', Token::NE_STRICT, Token::NE); |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 (keyword_length <= 9 || input[9] == keyword[9])) { \ | 1001 (keyword_length <= 9 || input[9] == keyword[9])) { \ |
1000 return token; \ | 1002 return token; \ |
1001 } \ | 1003 } \ |
1002 } | 1004 } |
1003 KEYWORDS(KEYWORD_GROUP_CASE, KEYWORD) | 1005 KEYWORDS(KEYWORD_GROUP_CASE, KEYWORD) |
1004 } | 1006 } |
1005 return Token::IDENTIFIER; | 1007 return Token::IDENTIFIER; |
1006 } | 1008 } |
1007 | 1009 |
1008 | 1010 |
| 1011 bool Scanner::IdentifierIsFutureStrictReserved( |
| 1012 const AstRawString* string) const { |
| 1013 // Keywords are always 1-byte strings. |
| 1014 return string->is_one_byte() && |
| 1015 Token::FUTURE_STRICT_RESERVED_WORD == |
| 1016 KeywordOrIdentifierToken(string->raw_data(), string->length(), |
| 1017 harmony_scoping_, harmony_modules_); |
| 1018 } |
| 1019 |
| 1020 |
1009 Token::Value Scanner::ScanIdentifierOrKeyword() { | 1021 Token::Value Scanner::ScanIdentifierOrKeyword() { |
1010 ASSERT(unicode_cache_->IsIdentifierStart(c0_)); | 1022 ASSERT(unicode_cache_->IsIdentifierStart(c0_)); |
1011 LiteralScope literal(this); | 1023 LiteralScope literal(this); |
1012 // Scan identifier start character. | 1024 // Scan identifier start character. |
1013 if (c0_ == '\\') { | 1025 if (c0_ == '\\') { |
1014 uc32 c = ScanIdentifierUnicodeEscape(); | 1026 uc32 c = ScanIdentifierUnicodeEscape(); |
1015 // Only allow legal identifier start characters. | 1027 // Only allow legal identifier start characters. |
1016 if (c < 0 || | 1028 if (c < 0 || |
1017 c == '\\' || // No recursive escapes. | 1029 c == '\\' || // No recursive escapes. |
1018 !unicode_cache_->IsIdentifierStart(c)) { | 1030 !unicode_cache_->IsIdentifierStart(c)) { |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 } | 1355 } |
1344 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1356 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
1345 } | 1357 } |
1346 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1358 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
1347 | 1359 |
1348 backing_store_.AddBlock(bytes); | 1360 backing_store_.AddBlock(bytes); |
1349 return backing_store_.EndSequence().start(); | 1361 return backing_store_.EndSequence().start(); |
1350 } | 1362 } |
1351 | 1363 |
1352 } } // namespace v8::internal | 1364 } } // namespace v8::internal |
OLD | NEW |