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

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: . Created 6 years, 1 month 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') | src/scanner.cc » ('J')
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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 451 }
452 void SetHarmonyNumericLiterals(bool numeric_literals) { 452 void SetHarmonyNumericLiterals(bool numeric_literals) {
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 HarmonyUnicode() const { return harmony_unicode_; }
462 void SetHarmonyUnicode(bool unicode) { harmony_unicode_ = unicode; }
461 463
462 // Returns true if there was a line terminator before the peek'ed token, 464 // Returns true if there was a line terminator before the peek'ed token,
463 // possibly inside a multi-line comment. 465 // possibly inside a multi-line comment.
464 bool HasAnyLineTerminatorBeforeNext() const { 466 bool HasAnyLineTerminatorBeforeNext() const {
465 return has_line_terminator_before_next_ || 467 return has_line_terminator_before_next_ ||
466 has_multiline_comment_before_next_; 468 has_multiline_comment_before_next_;
467 } 469 }
468 470
469 // Scans the input as a regular expression pattern, previous 471 // Scans the input as a regular expression pattern, previous
470 // character(s) must be /(=). Returns true if a pattern is scanned. 472 // character(s) must be /(=). Returns true if a pattern is scanned.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 bool is_next_literal_one_byte() { 606 bool is_next_literal_one_byte() {
605 DCHECK_NOT_NULL(next_.literal_chars); 607 DCHECK_NOT_NULL(next_.literal_chars);
606 return next_.literal_chars->is_one_byte(); 608 return next_.literal_chars->is_one_byte();
607 } 609 }
608 int next_literal_length() const { 610 int next_literal_length() const {
609 DCHECK_NOT_NULL(next_.literal_chars); 611 DCHECK_NOT_NULL(next_.literal_chars);
610 return next_.literal_chars->length(); 612 return next_.literal_chars->length();
611 } 613 }
612 614
613 uc32 ScanHexNumber(int expected_length); 615 uc32 ScanHexNumber(int expected_length);
616 // Scan a number of any length but not bigger than max_value. For example, the
617 // number can be 000000001, so it's very long in characters but its value is
618 // small.
619 uc32 ScanUnlimitedLengthHexNumber(int max_value);
614 620
615 // Scans a single JavaScript token. 621 // Scans a single JavaScript token.
616 void Scan(); 622 void Scan();
617 623
618 bool SkipWhiteSpace(); 624 bool SkipWhiteSpace();
619 Token::Value SkipSingleLineComment(); 625 Token::Value SkipSingleLineComment();
620 Token::Value SkipSourceURLComment(); 626 Token::Value SkipSourceURLComment();
621 void TryToParseSourceURLComment(); 627 void TryToParseSourceURLComment();
622 Token::Value SkipMultiLineComment(); 628 Token::Value SkipMultiLineComment();
623 // Scans a possible HTML comment -- begins with '<!'. 629 // Scans a possible HTML comment -- begins with '<!'.
624 Token::Value ScanHtmlComment(); 630 Token::Value ScanHtmlComment();
625 631
626 void ScanDecimalDigits(); 632 void ScanDecimalDigits();
627 Token::Value ScanNumber(bool seen_period); 633 Token::Value ScanNumber(bool seen_period);
628 Token::Value ScanIdentifierOrKeyword(); 634 Token::Value ScanIdentifierOrKeyword();
629 Token::Value ScanIdentifierSuffix(LiteralScope* literal); 635 Token::Value ScanIdentifierSuffix(LiteralScope* literal);
630 636
631 Token::Value ScanString(); 637 Token::Value ScanString();
632 638
633 // Scans an escape-sequence which is part of a string and adds the 639 // Scans an escape-sequence which is part of a string and adds the
634 // decoded character to the current literal. Returns true if a pattern 640 // decoded character to the current literal. Returns true if a pattern
635 // is scanned. 641 // is scanned.
636 bool ScanEscape(); 642 bool ScanEscape();
637 // Decodes a Unicode escape-sequence which is part of an identifier. 643 // Decodes a Unicode escape-sequence which is part of an identifier.
638 // If the escape sequence cannot be decoded the result is kBadChar. 644 // If the escape sequence cannot be decoded the result is kBadChar.
639 uc32 ScanIdentifierUnicodeEscape(); 645 uc32 ScanIdentifierUnicodeEscape();
646 // Helper for the above functions.
647 uc32 ScanUnicodeEscape();
640 648
641 // Return the current source position. 649 // Return the current source position.
642 int source_pos() { 650 int source_pos() {
643 return source_->pos() - kCharacterLookaheadBufferSize; 651 return source_->pos() - kCharacterLookaheadBufferSize;
644 } 652 }
645 653
646 UnicodeCache* unicode_cache_; 654 UnicodeCache* unicode_cache_;
647 655
648 // Buffers collecting literal strings, numbers, etc. 656 // Buffers collecting literal strings, numbers, etc.
649 LiteralBuffer literal_buffer1_; 657 LiteralBuffer literal_buffer1_;
(...skipping 24 matching lines...) Expand all
674 // line-terminator after the current token, and before the next. 682 // line-terminator after the current token, and before the next.
675 bool has_multiline_comment_before_next_; 683 bool has_multiline_comment_before_next_;
676 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings. 684 // Whether we scan 'let' as a keyword for harmony block-scoped let bindings.
677 bool harmony_scoping_; 685 bool harmony_scoping_;
678 // Whether we scan 'module', 'import', 'export' as keywords. 686 // Whether we scan 'module', 'import', 'export' as keywords.
679 bool harmony_modules_; 687 bool harmony_modules_;
680 // Whether we scan 0o777 and 0b111 as numbers. 688 // Whether we scan 0o777 and 0b111 as numbers.
681 bool harmony_numeric_literals_; 689 bool harmony_numeric_literals_;
682 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords. 690 // Whether we scan 'class', 'extends', 'static' and 'super' as keywords.
683 bool harmony_classes_; 691 bool harmony_classes_;
692 // Whether we allow \u{xxxxx}.
693 bool harmony_unicode_;
684 }; 694 };
685 695
686 } } // namespace v8::internal 696 } } // namespace v8::internal
687 697
688 #endif // V8_SCANNER_H_ 698 #endif // V8_SCANNER_H_
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | src/scanner.cc » ('j') | src/scanner.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698