| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // ---------------------------------------------------------------------------- | 32 // ---------------------------------------------------------------------------- |
| 33 // Scanner | 33 // Scanner |
| 34 | 34 |
| 35 Scanner::Scanner(UnicodeCache* unicode_cache) | 35 Scanner::Scanner(UnicodeCache* unicode_cache) |
| 36 : unicode_cache_(unicode_cache), | 36 : unicode_cache_(unicode_cache), |
| 37 octal_pos_(Location::invalid()), | 37 octal_pos_(Location::invalid()), |
| 38 harmony_modules_(false), | 38 harmony_modules_(false), |
| 39 harmony_numeric_literals_(false), | 39 harmony_numeric_literals_(false), |
| 40 harmony_classes_(false), | 40 harmony_classes_(false), |
| 41 harmony_templates_(false), | |
| 42 harmony_unicode_(false) {} | 41 harmony_unicode_(false) {} |
| 43 | 42 |
| 44 | 43 |
| 45 void Scanner::Initialize(Utf16CharacterStream* source) { | 44 void Scanner::Initialize(Utf16CharacterStream* source) { |
| 46 source_ = source; | 45 source_ = source; |
| 47 // Need to capture identifiers in order to recognize "get" and "set" | 46 // Need to capture identifiers in order to recognize "get" and "set" |
| 48 // in object literals. | 47 // in object literals. |
| 49 Init(); | 48 Init(); |
| 50 // Skip initial whitespace allowing HTML comment ends just like | 49 // Skip initial whitespace allowing HTML comment ends just like |
| 51 // after a newline and scan first token. | 50 // after a newline and scan first token. |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 | 647 |
| 649 case '?': | 648 case '?': |
| 650 token = Select(Token::CONDITIONAL); | 649 token = Select(Token::CONDITIONAL); |
| 651 break; | 650 break; |
| 652 | 651 |
| 653 case '~': | 652 case '~': |
| 654 token = Select(Token::BIT_NOT); | 653 token = Select(Token::BIT_NOT); |
| 655 break; | 654 break; |
| 656 | 655 |
| 657 case '`': | 656 case '`': |
| 658 if (HarmonyTemplates()) { | 657 token = ScanTemplateStart(); |
| 659 token = ScanTemplateStart(); | 658 break; |
| 660 break; | |
| 661 } | |
| 662 | 659 |
| 663 default: | 660 default: |
| 664 if (c0_ < 0) { | 661 if (c0_ < 0) { |
| 665 token = Token::EOS; | 662 token = Token::EOS; |
| 666 } else if (unicode_cache_->IsIdentifierStart(c0_)) { | 663 } else if (unicode_cache_->IsIdentifierStart(c0_)) { |
| 667 token = ScanIdentifierOrKeyword(); | 664 token = ScanIdentifierOrKeyword(); |
| 668 } else if (IsDecimalDigit(c0_)) { | 665 } else if (IsDecimalDigit(c0_)) { |
| 669 token = ScanNumber(false); | 666 token = ScanNumber(false); |
| 670 } else if (SkipWhiteSpace()) { | 667 } else if (SkipWhiteSpace()) { |
| 671 token = Token::WHITESPACE; | 668 token = Token::WHITESPACE; |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1563 } | 1560 } |
| 1564 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1561 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
| 1565 } | 1562 } |
| 1566 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1563 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
| 1567 | 1564 |
| 1568 backing_store_.AddBlock(bytes); | 1565 backing_store_.AddBlock(bytes); |
| 1569 return backing_store_.EndSequence().start(); | 1566 return backing_store_.EndSequence().start(); |
| 1570 } | 1567 } |
| 1571 | 1568 |
| 1572 } } // namespace v8::internal | 1569 } } // namespace v8::internal |
| OLD | NEW |