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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 has_multiline_comment_before_next_; | 443 has_multiline_comment_before_next_; |
444 } | 444 } |
445 | 445 |
446 // Scans the input as a regular expression pattern, previous | 446 // Scans the input as a regular expression pattern, previous |
447 // character(s) must be /(=). Returns true if a pattern is scanned. | 447 // character(s) must be /(=). Returns true if a pattern is scanned. |
448 bool ScanRegExpPattern(bool seen_equal); | 448 bool ScanRegExpPattern(bool seen_equal); |
449 // Returns true if regexp flags are scanned (always since flags can | 449 // Returns true if regexp flags are scanned (always since flags can |
450 // be empty). | 450 // be empty). |
451 bool ScanRegExpFlags(); | 451 bool ScanRegExpFlags(); |
452 | 452 |
| 453 bool HasSourceMapComment() { return has_source_map_comment_; } |
| 454 Handle<String> AllocateInternalizedSourceMapComment(Isolate* isolate); |
| 455 |
453 private: | 456 private: |
454 // The current and look-ahead token. | 457 // The current and look-ahead token. |
455 struct TokenDesc { | 458 struct TokenDesc { |
456 Token::Value token; | 459 Token::Value token; |
457 Location location; | 460 Location location; |
458 LiteralBuffer* literal_chars; | 461 LiteralBuffer* literal_chars; |
459 }; | 462 }; |
460 | 463 |
461 static const int kCharacterLookaheadBufferSize = 1; | 464 static const int kCharacterLookaheadBufferSize = 1; |
462 | 465 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 return next_.literal_chars->length(); | 567 return next_.literal_chars->length(); |
565 } | 568 } |
566 | 569 |
567 uc32 ScanHexNumber(int expected_length); | 570 uc32 ScanHexNumber(int expected_length); |
568 | 571 |
569 // Scans a single JavaScript token. | 572 // Scans a single JavaScript token. |
570 void Scan(); | 573 void Scan(); |
571 | 574 |
572 bool SkipWhiteSpace(); | 575 bool SkipWhiteSpace(); |
573 Token::Value SkipSingleLineComment(); | 576 Token::Value SkipSingleLineComment(); |
| 577 Token::Value SkipSourceMapComment(); |
574 Token::Value SkipMultiLineComment(); | 578 Token::Value SkipMultiLineComment(); |
575 // Scans a possible HTML comment -- begins with '<!'. | 579 // Scans a possible HTML comment -- begins with '<!'. |
576 Token::Value ScanHtmlComment(); | 580 Token::Value ScanHtmlComment(); |
577 | 581 |
578 void ScanDecimalDigits(); | 582 void ScanDecimalDigits(); |
579 Token::Value ScanNumber(bool seen_period); | 583 Token::Value ScanNumber(bool seen_period); |
580 Token::Value ScanIdentifierOrKeyword(); | 584 Token::Value ScanIdentifierOrKeyword(); |
581 Token::Value ScanIdentifierSuffix(LiteralScope* literal); | 585 Token::Value ScanIdentifierSuffix(LiteralScope* literal); |
582 | 586 |
583 Token::Value ScanString(); | 587 Token::Value ScanString(); |
(...skipping 14 matching lines...) Expand all Loading... |
598 int source_pos() { | 602 int source_pos() { |
599 return source_->pos() - kCharacterLookaheadBufferSize; | 603 return source_->pos() - kCharacterLookaheadBufferSize; |
600 } | 604 } |
601 | 605 |
602 UnicodeCache* unicode_cache_; | 606 UnicodeCache* unicode_cache_; |
603 | 607 |
604 // Buffers collecting literal strings, numbers, etc. | 608 // Buffers collecting literal strings, numbers, etc. |
605 LiteralBuffer literal_buffer1_; | 609 LiteralBuffer literal_buffer1_; |
606 LiteralBuffer literal_buffer2_; | 610 LiteralBuffer literal_buffer2_; |
607 | 611 |
| 612 LiteralBuffer source_map_comment_; |
| 613 |
608 TokenDesc current_; // desc for current token (as returned by Next()) | 614 TokenDesc current_; // desc for current token (as returned by Next()) |
609 TokenDesc next_; // desc for next token (one token look-ahead) | 615 TokenDesc next_; // desc for next token (one token look-ahead) |
610 | 616 |
611 // Input stream. Must be initialized to an Utf16CharacterStream. | 617 // Input stream. Must be initialized to an Utf16CharacterStream. |
612 Utf16CharacterStream* source_; | 618 Utf16CharacterStream* source_; |
613 | 619 |
614 | 620 |
615 // Start position of the octal literal last scanned. | 621 // Start position of the octal literal last scanned. |
616 Location octal_pos_; | 622 Location octal_pos_; |
617 | 623 |
618 // One Unicode character look-ahead; c0_ < 0 at the end of the input. | 624 // One Unicode character look-ahead; c0_ < 0 at the end of the input. |
619 uc32 c0_; | 625 uc32 c0_; |
620 | 626 |
621 // Whether there is a line terminator whitespace character after | 627 // Whether there is a line terminator whitespace character after |
622 // the current token, and before the next. Does not count newlines | 628 // the current token, and before the next. Does not count newlines |
623 // inside multiline comments. | 629 // inside multiline comments. |
624 bool has_line_terminator_before_next_; | 630 bool has_line_terminator_before_next_; |
625 // Whether there is a multi-line comment that contains a | 631 // Whether there is a multi-line comment that contains a |
626 // line-terminator after the current token, and before the next. | 632 // line-terminator after the current token, and before the next. |
627 bool has_multiline_comment_before_next_; | 633 bool has_multiline_comment_before_next_; |
| 634 // Whether the last line we have scanned is a source map comment. |
| 635 bool has_source_map_comment_; |
628 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings. | 636 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings. |
629 bool harmony_scoping_; | 637 bool harmony_scoping_; |
630 // Whether we scan 'module', 'import', 'export' as keywords. | 638 // Whether we scan 'module', 'import', 'export' as keywords. |
631 bool harmony_modules_; | 639 bool harmony_modules_; |
632 // Whether we scan 0o777 and 0b111 as numbers. | 640 // Whether we scan 0o777 and 0b111 as numbers. |
633 bool harmony_numeric_literals_; | 641 bool harmony_numeric_literals_; |
634 }; | 642 }; |
635 | 643 |
636 } } // namespace v8::internal | 644 } } // namespace v8::internal |
637 | 645 |
638 #endif // V8_SCANNER_H_ | 646 #endif // V8_SCANNER_H_ |
OLD | NEW |