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

Side by Side Diff: src/parsing/scanner.h

Issue 1841543003: [esnext] implement frontend changes for async/await proposal (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase over generator change cl Created 4 years, 8 months 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
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_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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 bool has_error() const { return scanner_error_ != MessageTemplate::kNone; } 358 bool has_error() const { return scanner_error_ != MessageTemplate::kNone; }
359 MessageTemplate::Template error() const { return scanner_error_; } 359 MessageTemplate::Template error() const { return scanner_error_; }
360 Location error_location() const { return scanner_error_location_; } 360 Location error_location() const { return scanner_error_location_; }
361 361
362 // Similar functions for the upcoming token. 362 // Similar functions for the upcoming token.
363 363
364 // One token look-ahead (past the token returned by Next()). 364 // One token look-ahead (past the token returned by Next()).
365 Token::Value peek() const { return next_.token; } 365 Token::Value peek() const { return next_.token; }
366 366
367 Location peek_location() const { return next_.location; } 367 Location peek_location() const { return next_.location; }
368 Location peek_ahead_location() const {
369 DCHECK(next_next_.token != Token::UNINITIALIZED);
370 return next_next_.location;
371 }
368 372
369 bool literal_contains_escapes() const { 373 bool literal_contains_escapes() const {
370 return LiteralContainsEscapes(current_); 374 return LiteralContainsEscapes(current_);
371 } 375 }
372 bool next_literal_contains_escapes() const { 376 bool next_literal_contains_escapes() const {
373 return LiteralContainsEscapes(next_); 377 return LiteralContainsEscapes(next_);
374 } 378 }
375 bool is_literal_contextual_keyword(Vector<const char> keyword) { 379 bool is_literal_contextual_keyword(Vector<const char> keyword) {
376 DCHECK_NOT_NULL(current_.literal_chars); 380 DCHECK_NOT_NULL(current_.literal_chars);
377 return current_.literal_chars->is_contextual_keyword(keyword); 381 return current_.literal_chars->is_contextual_keyword(keyword);
378 } 382 }
379 bool is_next_contextual_keyword(Vector<const char> keyword) { 383 bool is_next_contextual_keyword(Vector<const char> keyword) {
380 DCHECK_NOT_NULL(next_.literal_chars); 384 DCHECK_NOT_NULL(next_.literal_chars);
381 return next_.literal_chars->is_contextual_keyword(keyword); 385 return next_.literal_chars->is_contextual_keyword(keyword);
382 } 386 }
383 387
388 bool is_next_next_contextual_keyword(Vector<const char> keyword) {
389 DCHECK_NOT_NULL(next_next_.literal_chars);
390 return next_next_.literal_chars->is_contextual_keyword(keyword);
391 }
392
384 const AstRawString* CurrentSymbol(AstValueFactory* ast_value_factory); 393 const AstRawString* CurrentSymbol(AstValueFactory* ast_value_factory);
385 const AstRawString* NextSymbol(AstValueFactory* ast_value_factory); 394 const AstRawString* NextSymbol(AstValueFactory* ast_value_factory);
395 const AstRawString* NextNextSymbol(AstValueFactory* ast_value_factory);
386 const AstRawString* CurrentRawSymbol(AstValueFactory* ast_value_factory); 396 const AstRawString* CurrentRawSymbol(AstValueFactory* ast_value_factory);
387 397
388 double DoubleValue(); 398 double DoubleValue();
389 bool ContainsDot(); 399 bool ContainsDot();
390 bool LiteralMatches(const char* data, int length, bool allow_escapes = true) { 400 bool LiteralMatches(const char* data, int length, bool allow_escapes = true) {
391 if (is_literal_one_byte() && 401 if (is_literal_one_byte() &&
392 literal_length() == length && 402 literal_length() == length &&
393 (allow_escapes || !literal_contains_escapes())) { 403 (allow_escapes || !literal_contains_escapes())) {
394 const char* token = 404 const char* token =
395 reinterpret_cast<const char*>(literal_one_byte_string().start()); 405 reinterpret_cast<const char*>(literal_one_byte_string().start());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 // tokens, which is what it is used for. 439 // tokens, which is what it is used for.
430 void SeekForward(int pos); 440 void SeekForward(int pos);
431 441
432 // Returns true if there was a line terminator before the peek'ed token, 442 // Returns true if there was a line terminator before the peek'ed token,
433 // possibly inside a multi-line comment. 443 // possibly inside a multi-line comment.
434 bool HasAnyLineTerminatorBeforeNext() const { 444 bool HasAnyLineTerminatorBeforeNext() const {
435 return has_line_terminator_before_next_ || 445 return has_line_terminator_before_next_ ||
436 has_multiline_comment_before_next_; 446 has_multiline_comment_before_next_;
437 } 447 }
438 448
449 bool HasAnyLineTerminatorAfterNext() {
450 Token::Value ensure_next_next = PeekAhead();
451 USE(ensure_next_next);
452 return has_line_terminator_before_next2_ ||
453 has_multiline_comment_before_next2_;
454 }
455
439 // Scans the input as a regular expression pattern, previous 456 // Scans the input as a regular expression pattern, previous
440 // character(s) must be /(=). Returns true if a pattern is scanned. 457 // character(s) must be /(=). Returns true if a pattern is scanned.
441 bool ScanRegExpPattern(bool seen_equal); 458 bool ScanRegExpPattern(bool seen_equal);
442 // Scans the input as regular expression flags. Returns the flags on success. 459 // Scans the input as regular expression flags. Returns the flags on success.
443 Maybe<RegExp::Flags> ScanRegExpFlags(); 460 Maybe<RegExp::Flags> ScanRegExpFlags();
444 461
445 // Scans the input as a template literal 462 // Scans the input as a template literal
446 Token::Value ScanTemplateStart(); 463 Token::Value ScanTemplateStart();
447 Token::Value ScanTemplateContinuation(); 464 Token::Value ScanTemplateContinuation();
448 465
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 uc32 c0_; 791 uc32 c0_;
775 792
776 // Whether there is a line terminator whitespace character after 793 // Whether there is a line terminator whitespace character after
777 // the current token, and before the next. Does not count newlines 794 // the current token, and before the next. Does not count newlines
778 // inside multiline comments. 795 // inside multiline comments.
779 bool has_line_terminator_before_next_; 796 bool has_line_terminator_before_next_;
780 // Whether there is a multi-line comment that contains a 797 // Whether there is a multi-line comment that contains a
781 // line-terminator after the current token, and before the next. 798 // line-terminator after the current token, and before the next.
782 bool has_multiline_comment_before_next_; 799 bool has_multiline_comment_before_next_;
783 800
801 // For use with PeekAhead()
802 bool has_line_terminator_before_next2_;
803 bool has_multiline_comment_before_next2_;
804
784 // Whether this scanner encountered an HTML comment. 805 // Whether this scanner encountered an HTML comment.
785 bool found_html_comment_; 806 bool found_html_comment_;
786 807
787 bool allow_harmony_exponentiation_operator_; 808 bool allow_harmony_exponentiation_operator_;
788 809
789 MessageTemplate::Template scanner_error_; 810 MessageTemplate::Template scanner_error_;
790 Location scanner_error_location_; 811 Location scanner_error_location_;
791 }; 812 };
792 813
793 } // namespace internal 814 } // namespace internal
794 } // namespace v8 815 } // namespace v8
795 816
796 #endif // V8_PARSING_SCANNER_H_ 817 #endif // V8_PARSING_SCANNER_H_
OLDNEW
« src/parsing/parser.cc ('K') | « src/parsing/preparser.cc ('k') | src/parsing/scanner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698