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_PARSING_SCANNER_H_ | 7 #ifndef V8_PARSING_SCANNER_H_ |
8 #define V8_PARSING_SCANNER_H_ | 8 #define V8_PARSING_SCANNER_H_ |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 bool FindSymbol(DuplicateFinder* finder); | 271 bool FindSymbol(DuplicateFinder* finder); |
272 | 272 |
273 UnicodeCache* unicode_cache() { return unicode_cache_; } | 273 UnicodeCache* unicode_cache() { return unicode_cache_; } |
274 | 274 |
275 // Returns the location of the last seen octal literal. | 275 // Returns the location of the last seen octal literal. |
276 Location octal_position() const { return octal_pos_; } | 276 Location octal_position() const { return octal_pos_; } |
277 void clear_octal_position() { | 277 void clear_octal_position() { |
278 octal_pos_ = Location::invalid(); | 278 octal_pos_ = Location::invalid(); |
279 octal_message_ = MessageTemplate::kNone; | 279 octal_message_ = MessageTemplate::kNone; |
280 } | 280 } |
281 // Returns the location of the last seen decimal literal with a leading zero. | |
282 Location decimal_with_leading_zero_position() const { | |
283 return decimal_with_leading_zero_pos_; | |
284 } | |
285 void clear_decimal_with_leading_zero_position() { | |
286 decimal_with_leading_zero_pos_ = Location::invalid(); | |
287 } | |
288 MessageTemplate::Template octal_message() const { return octal_message_; } | 281 MessageTemplate::Template octal_message() const { return octal_message_; } |
289 | 282 |
290 // Returns the value of the last smi that was scanned. | 283 // Returns the value of the last smi that was scanned. |
291 uint32_t smi_value() const { return current_.smi_value_; } | 284 uint32_t smi_value() const { return current_.smi_value_; } |
292 | 285 |
293 // Seek forward to the given position. This operation does not | 286 // Seek forward to the given position. This operation does not |
294 // work in general, for instance when there are pushed back | 287 // work in general, for instance when there are pushed back |
295 // characters, but works for seeking forward until simple delimiter | 288 // characters, but works for seeking forward until simple delimiter |
296 // tokens, which is what it is used for. | 289 // tokens, which is what it is used for. |
297 void SeekForward(int pos); | 290 void SeekForward(int pos); |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 | 775 |
783 TokenDesc current_; // desc for current token (as returned by Next()) | 776 TokenDesc current_; // desc for current token (as returned by Next()) |
784 TokenDesc next_; // desc for next token (one token look-ahead) | 777 TokenDesc next_; // desc for next token (one token look-ahead) |
785 TokenDesc next_next_; // desc for the token after next (after PeakAhead()) | 778 TokenDesc next_next_; // desc for the token after next (after PeakAhead()) |
786 | 779 |
787 // Input stream. Must be initialized to an Utf16CharacterStream. | 780 // Input stream. Must be initialized to an Utf16CharacterStream. |
788 Utf16CharacterStream* source_; | 781 Utf16CharacterStream* source_; |
789 | 782 |
790 // Last-seen positions of potentially problematic tokens. | 783 // Last-seen positions of potentially problematic tokens. |
791 Location octal_pos_; | 784 Location octal_pos_; |
792 Location decimal_with_leading_zero_pos_; | |
793 MessageTemplate::Template octal_message_; | 785 MessageTemplate::Template octal_message_; |
794 | 786 |
795 // One Unicode character look-ahead; c0_ < 0 at the end of the input. | 787 // One Unicode character look-ahead; c0_ < 0 at the end of the input. |
796 uc32 c0_; | 788 uc32 c0_; |
797 | 789 |
798 // Whether there is a line terminator whitespace character after | 790 // Whether there is a line terminator whitespace character after |
799 // the current token, and before the next. Does not count newlines | 791 // the current token, and before the next. Does not count newlines |
800 // inside multiline comments. | 792 // inside multiline comments. |
801 bool has_line_terminator_before_next_; | 793 bool has_line_terminator_before_next_; |
802 // Whether there is a multi-line comment that contains a | 794 // Whether there is a multi-line comment that contains a |
803 // line-terminator after the current token, and before the next. | 795 // line-terminator after the current token, and before the next. |
804 bool has_multiline_comment_before_next_; | 796 bool has_multiline_comment_before_next_; |
805 bool has_line_terminator_after_next_; | 797 bool has_line_terminator_after_next_; |
806 | 798 |
807 // Whether this scanner encountered an HTML comment. | 799 // Whether this scanner encountered an HTML comment. |
808 bool found_html_comment_; | 800 bool found_html_comment_; |
809 | 801 |
810 MessageTemplate::Template scanner_error_; | 802 MessageTemplate::Template scanner_error_; |
811 Location scanner_error_location_; | 803 Location scanner_error_location_; |
812 }; | 804 }; |
813 | 805 |
814 } // namespace internal | 806 } // namespace internal |
815 } // namespace v8 | 807 } // namespace v8 |
816 | 808 |
817 #endif // V8_PARSING_SCANNER_H_ | 809 #endif // V8_PARSING_SCANNER_H_ |
OLD | NEW |