| 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 #ifndef V8_SCANNER_H_ | 7 #ifndef V8_SCANNER_H_ |
| 8 #define V8_SCANNER_H_ | 8 #define V8_SCANNER_H_ |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 bool is_next_literal_one_byte() { | 604 bool is_next_literal_one_byte() { |
| 605 DCHECK_NOT_NULL(next_.literal_chars); | 605 DCHECK_NOT_NULL(next_.literal_chars); |
| 606 return next_.literal_chars->is_one_byte(); | 606 return next_.literal_chars->is_one_byte(); |
| 607 } | 607 } |
| 608 int next_literal_length() const { | 608 int next_literal_length() const { |
| 609 DCHECK_NOT_NULL(next_.literal_chars); | 609 DCHECK_NOT_NULL(next_.literal_chars); |
| 610 return next_.literal_chars->length(); | 610 return next_.literal_chars->length(); |
| 611 } | 611 } |
| 612 | 612 |
| 613 uc32 ScanHexNumber(int expected_length); | 613 uc32 ScanHexNumber(int expected_length); |
| 614 // Scan a number of any length but not bigger than max_value. For example, the |
| 615 // number can be 000000001, so it's very long in characters but its value is |
| 616 // small. |
| 617 uc32 ScanUnlimitedLengthHexNumber(int max_value); |
| 614 | 618 |
| 615 // Scans a single JavaScript token. | 619 // Scans a single JavaScript token. |
| 616 void Scan(); | 620 void Scan(); |
| 617 | 621 |
| 618 bool SkipWhiteSpace(); | 622 bool SkipWhiteSpace(); |
| 619 Token::Value SkipSingleLineComment(); | 623 Token::Value SkipSingleLineComment(); |
| 620 Token::Value SkipSourceURLComment(); | 624 Token::Value SkipSourceURLComment(); |
| 621 void TryToParseSourceURLComment(); | 625 void TryToParseSourceURLComment(); |
| 622 Token::Value SkipMultiLineComment(); | 626 Token::Value SkipMultiLineComment(); |
| 623 // Scans a possible HTML comment -- begins with '<!'. | 627 // Scans a possible HTML comment -- begins with '<!'. |
| 624 Token::Value ScanHtmlComment(); | 628 Token::Value ScanHtmlComment(); |
| 625 | 629 |
| 626 void ScanDecimalDigits(); | 630 void ScanDecimalDigits(); |
| 627 Token::Value ScanNumber(bool seen_period); | 631 Token::Value ScanNumber(bool seen_period); |
| 628 Token::Value ScanIdentifierOrKeyword(); | 632 Token::Value ScanIdentifierOrKeyword(); |
| 629 Token::Value ScanIdentifierSuffix(LiteralScope* literal); | 633 Token::Value ScanIdentifierSuffix(LiteralScope* literal); |
| 630 | 634 |
| 631 Token::Value ScanString(); | 635 Token::Value ScanString(); |
| 632 | 636 |
| 633 // Scans an escape-sequence which is part of a string and adds the | 637 // Scans an escape-sequence which is part of a string and adds the |
| 634 // decoded character to the current literal. Returns true if a pattern | 638 // decoded character to the current literal. Returns true if a pattern |
| 635 // is scanned. | 639 // is scanned. |
| 636 bool ScanEscape(); | 640 bool ScanEscape(); |
| 637 // Decodes a Unicode escape-sequence which is part of an identifier. | 641 // Decodes a Unicode escape-sequence which is part of an identifier. |
| 638 // If the escape sequence cannot be decoded the result is kBadChar. | 642 // If the escape sequence cannot be decoded the result is kBadChar. |
| 639 uc32 ScanIdentifierUnicodeEscape(); | 643 uc32 ScanIdentifierUnicodeEscape(); |
| 644 // Helper for the above functions. |
| 645 uc32 ScanUnicodeEscape(); |
| 640 | 646 |
| 641 // Return the current source position. | 647 // Return the current source position. |
| 642 int source_pos() { | 648 int source_pos() { |
| 643 return source_->pos() - kCharacterLookaheadBufferSize; | 649 return source_->pos() - kCharacterLookaheadBufferSize; |
| 644 } | 650 } |
| 645 | 651 |
| 646 UnicodeCache* unicode_cache_; | 652 UnicodeCache* unicode_cache_; |
| 647 | 653 |
| 648 // Buffers collecting literal strings, numbers, etc. | 654 // Buffers collecting literal strings, numbers, etc. |
| 649 LiteralBuffer literal_buffer1_; | 655 LiteralBuffer literal_buffer1_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 679 bool harmony_modules_; | 685 bool harmony_modules_; |
| 680 // Whether we scan 0o777 and 0b111 as numbers. | 686 // Whether we scan 0o777 and 0b111 as numbers. |
| 681 bool harmony_numeric_literals_; | 687 bool harmony_numeric_literals_; |
| 682 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. | 688 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. |
| 683 bool harmony_classes_; | 689 bool harmony_classes_; |
| 684 }; | 690 }; |
| 685 | 691 |
| 686 } } // namespace v8::internal | 692 } } // namespace v8::internal |
| 687 | 693 |
| 688 #endif // V8_SCANNER_H_ | 694 #endif // V8_SCANNER_H_ |
| OLD | NEW |