| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 | 484 |
| 485 bool IdentifierIsFutureStrictReserved(const AstRawString* string) const; | 485 bool IdentifierIsFutureStrictReserved(const AstRawString* string) const; |
| 486 | 486 |
| 487 private: | 487 private: |
| 488 // The current and look-ahead token. | 488 // The current and look-ahead token. |
| 489 struct TokenDesc { | 489 struct TokenDesc { |
| 490 Token::Value token; | 490 Token::Value token; |
| 491 Location location; | 491 Location location; |
| 492 LiteralBuffer* literal_chars; | 492 LiteralBuffer* literal_chars; |
| 493 LiteralBuffer* raw_literal_chars; | 493 LiteralBuffer* raw_literal_chars; |
| 494 int smi_value_; |
| 494 }; | 495 }; |
| 495 | 496 |
| 496 static const int kCharacterLookaheadBufferSize = 1; | 497 static const int kCharacterLookaheadBufferSize = 1; |
| 497 | 498 |
| 498 // Scans octal escape sequence. Also accepts "\0" decimal escape sequence. | 499 // Scans octal escape sequence. Also accepts "\0" decimal escape sequence. |
| 499 template <bool capture_raw> | 500 template <bool capture_raw> |
| 500 uc32 ScanOctalEscape(uc32 c, int length); | 501 uc32 ScanOctalEscape(uc32 c, int length); |
| 501 | 502 |
| 502 // Call this after setting source_ to the input. | 503 // Call this after setting source_ to the input. |
| 503 void Init() { | 504 void Init() { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 TokenDesc current_; // desc for current token (as returned by Next()) | 712 TokenDesc current_; // desc for current token (as returned by Next()) |
| 712 TokenDesc next_; // desc for next token (one token look-ahead) | 713 TokenDesc next_; // desc for next token (one token look-ahead) |
| 713 | 714 |
| 714 // Input stream. Must be initialized to an Utf16CharacterStream. | 715 // Input stream. Must be initialized to an Utf16CharacterStream. |
| 715 Utf16CharacterStream* source_; | 716 Utf16CharacterStream* source_; |
| 716 | 717 |
| 717 | 718 |
| 718 // Start position of the octal literal last scanned. | 719 // Start position of the octal literal last scanned. |
| 719 Location octal_pos_; | 720 Location octal_pos_; |
| 720 | 721 |
| 721 // Value of the last smi that was scanned. | |
| 722 int smi_value_; | |
| 723 | |
| 724 // One Unicode character look-ahead; c0_ < 0 at the end of the input. | 722 // One Unicode character look-ahead; c0_ < 0 at the end of the input. |
| 725 uc32 c0_; | 723 uc32 c0_; |
| 726 | 724 |
| 727 // Whether there is a line terminator whitespace character after | 725 // Whether there is a line terminator whitespace character after |
| 728 // the current token, and before the next. Does not count newlines | 726 // the current token, and before the next. Does not count newlines |
| 729 // inside multiline comments. | 727 // inside multiline comments. |
| 730 bool has_line_terminator_before_next_; | 728 bool has_line_terminator_before_next_; |
| 731 // Whether there is a multi-line comment that contains a | 729 // Whether there is a multi-line comment that contains a |
| 732 // line-terminator after the current token, and before the next. | 730 // line-terminator after the current token, and before the next. |
| 733 bool has_multiline_comment_before_next_; | 731 bool has_multiline_comment_before_next_; |
| 734 // Whether we scan 'module', 'import', 'export' as keywords. | 732 // Whether we scan 'module', 'import', 'export' as keywords. |
| 735 bool harmony_modules_; | 733 bool harmony_modules_; |
| 736 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. | 734 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. |
| 737 bool harmony_classes_; | 735 bool harmony_classes_; |
| 738 // Whether we allow \u{xxxxx}. | 736 // Whether we allow \u{xxxxx}. |
| 739 bool harmony_unicode_; | 737 bool harmony_unicode_; |
| 740 }; | 738 }; |
| 741 | 739 |
| 742 } } // namespace v8::internal | 740 } } // namespace v8::internal |
| 743 | 741 |
| 744 #endif // V8_SCANNER_H_ | 742 #endif // V8_SCANNER_H_ |
| OLD | NEW |