| 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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 429 |
| 430 int FindSymbol(DuplicateFinder* finder, int value); | 430 int FindSymbol(DuplicateFinder* finder, int value); |
| 431 | 431 |
| 432 UnicodeCache* unicode_cache() { return unicode_cache_; } | 432 UnicodeCache* unicode_cache() { return unicode_cache_; } |
| 433 | 433 |
| 434 // Returns the location of the last seen octal literal. | 434 // Returns the location of the last seen octal literal. |
| 435 Location octal_position() const { return octal_pos_; } | 435 Location octal_position() const { return octal_pos_; } |
| 436 void clear_octal_position() { octal_pos_ = Location::invalid(); } | 436 void clear_octal_position() { octal_pos_ = Location::invalid(); } |
| 437 | 437 |
| 438 // Returns the value of the last smi that was scanned. | 438 // Returns the value of the last smi that was scanned. |
| 439 int smi_value() const { return smi_value_; } | 439 int smi_value() const { return current_.smi_value_; } |
| 440 | 440 |
| 441 // Seek forward to the given position. This operation does not | 441 // Seek forward to the given position. This operation does not |
| 442 // work in general, for instance when there are pushed back | 442 // work in general, for instance when there are pushed back |
| 443 // characters, but works for seeking forward until simple delimiter | 443 // characters, but works for seeking forward until simple delimiter |
| 444 // tokens, which is what it is used for. | 444 // tokens, which is what it is used for. |
| 445 void SeekForward(int pos); | 445 void SeekForward(int pos); |
| 446 | 446 |
| 447 bool HarmonyModules() const { | 447 bool HarmonyModules() const { |
| 448 return harmony_modules_; | 448 return harmony_modules_; |
| 449 } | 449 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 | 490 |
| 491 bool IdentifierIsFutureStrictReserved(const AstRawString* string) const; | 491 bool IdentifierIsFutureStrictReserved(const AstRawString* string) const; |
| 492 | 492 |
| 493 private: | 493 private: |
| 494 // The current and look-ahead token. | 494 // The current and look-ahead token. |
| 495 struct TokenDesc { | 495 struct TokenDesc { |
| 496 Token::Value token; | 496 Token::Value token; |
| 497 Location location; | 497 Location location; |
| 498 LiteralBuffer* literal_chars; | 498 LiteralBuffer* literal_chars; |
| 499 LiteralBuffer* raw_literal_chars; | 499 LiteralBuffer* raw_literal_chars; |
| 500 int smi_value_; |
| 500 }; | 501 }; |
| 501 | 502 |
| 502 static const int kCharacterLookaheadBufferSize = 1; | 503 static const int kCharacterLookaheadBufferSize = 1; |
| 503 | 504 |
| 504 // Scans octal escape sequence. Also accepts "\0" decimal escape sequence. | 505 // Scans octal escape sequence. Also accepts "\0" decimal escape sequence. |
| 505 template <bool capture_raw> | 506 template <bool capture_raw> |
| 506 uc32 ScanOctalEscape(uc32 c, int length); | 507 uc32 ScanOctalEscape(uc32 c, int length); |
| 507 | 508 |
| 508 // Call this after setting source_ to the input. | 509 // Call this after setting source_ to the input. |
| 509 void Init() { | 510 void Init() { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 TokenDesc current_; // desc for current token (as returned by Next()) | 718 TokenDesc current_; // desc for current token (as returned by Next()) |
| 718 TokenDesc next_; // desc for next token (one token look-ahead) | 719 TokenDesc next_; // desc for next token (one token look-ahead) |
| 719 | 720 |
| 720 // Input stream. Must be initialized to an Utf16CharacterStream. | 721 // Input stream. Must be initialized to an Utf16CharacterStream. |
| 721 Utf16CharacterStream* source_; | 722 Utf16CharacterStream* source_; |
| 722 | 723 |
| 723 | 724 |
| 724 // Start position of the octal literal last scanned. | 725 // Start position of the octal literal last scanned. |
| 725 Location octal_pos_; | 726 Location octal_pos_; |
| 726 | 727 |
| 727 // Value of the last smi that was scanned. | |
| 728 int smi_value_; | |
| 729 | |
| 730 // One Unicode character look-ahead; c0_ < 0 at the end of the input. | 728 // One Unicode character look-ahead; c0_ < 0 at the end of the input. |
| 731 uc32 c0_; | 729 uc32 c0_; |
| 732 | 730 |
| 733 // Whether there is a line terminator whitespace character after | 731 // Whether there is a line terminator whitespace character after |
| 734 // the current token, and before the next. Does not count newlines | 732 // the current token, and before the next. Does not count newlines |
| 735 // inside multiline comments. | 733 // inside multiline comments. |
| 736 bool has_line_terminator_before_next_; | 734 bool has_line_terminator_before_next_; |
| 737 // Whether there is a multi-line comment that contains a | 735 // Whether there is a multi-line comment that contains a |
| 738 // line-terminator after the current token, and before the next. | 736 // line-terminator after the current token, and before the next. |
| 739 bool has_multiline_comment_before_next_; | 737 bool has_multiline_comment_before_next_; |
| 740 // Whether we scan 'module', 'import', 'export' as keywords. | 738 // Whether we scan 'module', 'import', 'export' as keywords. |
| 741 bool harmony_modules_; | 739 bool harmony_modules_; |
| 742 // Whether we scan 0o777 and 0b111 as numbers. | 740 // Whether we scan 0o777 and 0b111 as numbers. |
| 743 bool harmony_numeric_literals_; | 741 bool harmony_numeric_literals_; |
| 744 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. | 742 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. |
| 745 bool harmony_classes_; | 743 bool harmony_classes_; |
| 746 // Whether we allow \u{xxxxx}. | 744 // Whether we allow \u{xxxxx}. |
| 747 bool harmony_unicode_; | 745 bool harmony_unicode_; |
| 748 }; | 746 }; |
| 749 | 747 |
| 750 } } // namespace v8::internal | 748 } } // namespace v8::internal |
| 751 | 749 |
| 752 #endif // V8_SCANNER_H_ | 750 #endif // V8_SCANNER_H_ |
| OLD | NEW |