Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: src/scanner.h

Issue 716423002: ES6 unicode extensions, part 1. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add tests Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/preparser.h ('k') | src/scanner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 harmony_numeric_literals_ = numeric_literals; 453 harmony_numeric_literals_ = numeric_literals;
454 } 454 }
455 bool HarmonyClasses() const { 455 bool HarmonyClasses() const {
456 return harmony_classes_; 456 return harmony_classes_;
457 } 457 }
458 void SetHarmonyClasses(bool classes) { 458 void SetHarmonyClasses(bool classes) {
459 harmony_classes_ = classes; 459 harmony_classes_ = classes;
460 } 460 }
461 bool HarmonyTemplates() const { return harmony_templates_; } 461 bool HarmonyTemplates() const { return harmony_templates_; }
462 void SetHarmonyTemplates(bool templates) { harmony_templates_ = templates; } 462 void SetHarmonyTemplates(bool templates) { harmony_templates_ = templates; }
463 bool HarmonyUnicode() const { return harmony_unicode_; }
464 void SetHarmonyUnicode(bool unicode) { harmony_unicode_ = unicode; }
463 465
464 // Returns true if there was a line terminator before the peek'ed token, 466 // Returns true if there was a line terminator before the peek'ed token,
465 // possibly inside a multi-line comment. 467 // possibly inside a multi-line comment.
466 bool HasAnyLineTerminatorBeforeNext() const { 468 bool HasAnyLineTerminatorBeforeNext() const {
467 return has_line_terminator_before_next_ || 469 return has_line_terminator_before_next_ ||
468 has_multiline_comment_before_next_; 470 has_multiline_comment_before_next_;
469 } 471 }
470 472
471 // Scans the input as a regular expression pattern, previous 473 // Scans the input as a regular expression pattern, previous
472 // character(s) must be /(=). Returns true if a pattern is scanned. 474 // character(s) must be /(=). Returns true if a pattern is scanned.
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 bool is_next_literal_one_byte() { 611 bool is_next_literal_one_byte() {
610 DCHECK_NOT_NULL(next_.literal_chars); 612 DCHECK_NOT_NULL(next_.literal_chars);
611 return next_.literal_chars->is_one_byte(); 613 return next_.literal_chars->is_one_byte();
612 } 614 }
613 int next_literal_length() const { 615 int next_literal_length() const {
614 DCHECK_NOT_NULL(next_.literal_chars); 616 DCHECK_NOT_NULL(next_.literal_chars);
615 return next_.literal_chars->length(); 617 return next_.literal_chars->length();
616 } 618 }
617 619
618 uc32 ScanHexNumber(int expected_length); 620 uc32 ScanHexNumber(int expected_length);
621 // Scan a number of any length but not bigger than max_value. For example, the
622 // number can be 000000001, so it's very long in characters but its value is
623 // small.
624 uc32 ScanUnlimitedLengthHexNumber(int max_value);
619 625
620 // Scans a single JavaScript token. 626 // Scans a single JavaScript token.
621 void Scan(); 627 void Scan();
622 628
623 bool SkipWhiteSpace(); 629 bool SkipWhiteSpace();
624 Token::Value SkipSingleLineComment(); 630 Token::Value SkipSingleLineComment();
625 Token::Value SkipSourceURLComment(); 631 Token::Value SkipSourceURLComment();
626 void TryToParseSourceURLComment(); 632 void TryToParseSourceURLComment();
627 Token::Value SkipMultiLineComment(); 633 Token::Value SkipMultiLineComment();
628 // Scans a possible HTML comment -- begins with '<!'. 634 // Scans a possible HTML comment -- begins with '<!'.
629 Token::Value ScanHtmlComment(); 635 Token::Value ScanHtmlComment();
630 636
631 void ScanDecimalDigits(); 637 void ScanDecimalDigits();
632 Token::Value ScanNumber(bool seen_period); 638 Token::Value ScanNumber(bool seen_period);
633 Token::Value ScanIdentifierOrKeyword(); 639 Token::Value ScanIdentifierOrKeyword();
634 Token::Value ScanIdentifierSuffix(LiteralScope* literal); 640 Token::Value ScanIdentifierSuffix(LiteralScope* literal);
635 641
636 Token::Value ScanString(); 642 Token::Value ScanString();
637 643
638 // Scans an escape-sequence which is part of a string and adds the 644 // Scans an escape-sequence which is part of a string and adds the
639 // decoded character to the current literal. Returns true if a pattern 645 // decoded character to the current literal. Returns true if a pattern
640 // is scanned. 646 // is scanned.
641 bool ScanEscape(); 647 bool ScanEscape();
642 // Decodes a Unicode escape-sequence which is part of an identifier. 648 // Decodes a Unicode escape-sequence which is part of an identifier.
643 // If the escape sequence cannot be decoded the result is kBadChar. 649 // If the escape sequence cannot be decoded the result is kBadChar.
644 uc32 ScanIdentifierUnicodeEscape(); 650 uc32 ScanIdentifierUnicodeEscape();
651 // Helper for the above functions.
652 uc32 ScanUnicodeEscape();
645 653
646 // Return the current source position. 654 // Return the current source position.
647 int source_pos() { 655 int source_pos() {
648 return source_->pos() - kCharacterLookaheadBufferSize; 656 return source_->pos() - kCharacterLookaheadBufferSize;
649 } 657 }
650 658
651 UnicodeCache* unicode_cache_; 659 UnicodeCache* unicode_cache_;
652 660
653 // Buffers collecting literal strings, numbers, etc. 661 // Buffers collecting literal strings, numbers, etc.
654 LiteralBuffer literal_buffer1_; 662 LiteralBuffer literal_buffer1_;
(...skipping 26 matching lines...) Expand all
681 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings. 689 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings.
682 bool harmony_scoping_; 690 bool harmony_scoping_;
683 // Whether we scan 'module', 'import', 'export' as keywords. 691 // Whether we scan 'module', 'import', 'export' as keywords.
684 bool harmony_modules_; 692 bool harmony_modules_;
685 // Whether we scan 0o777 and 0b111 as numbers. 693 // Whether we scan 0o777 and 0b111 as numbers.
686 bool harmony_numeric_literals_; 694 bool harmony_numeric_literals_;
687 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. 695 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords.
688 bool harmony_classes_; 696 bool harmony_classes_;
689 // Whether we scan TEMPLATE_SPAN and TEMPLATE_TAIL 697 // Whether we scan TEMPLATE_SPAN and TEMPLATE_TAIL
690 bool harmony_templates_; 698 bool harmony_templates_;
699 // Whether we allow \u{xxxxx}.
700 bool harmony_unicode_;
691 }; 701 };
692 702
693 } } // namespace v8::internal 703 } } // namespace v8::internal
694 704
695 #endif // V8_SCANNER_H_ 705 #endif // V8_SCANNER_H_
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | src/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698