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

Side by Side Diff: src/scanner-base.h

Issue 7348008: Merge up to 8597 to experimental/gc from the bleeding edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « src/scanner.cc ('k') | src/scanner-base.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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 complete_ = true; 464 complete_ = true;
465 } 465 }
466 466
467 private: 467 private:
468 JavaScriptScanner* scanner_; 468 JavaScriptScanner* scanner_;
469 bool complete_; 469 bool complete_;
470 }; 470 };
471 471
472 explicit JavaScriptScanner(UnicodeCache* scanner_contants); 472 explicit JavaScriptScanner(UnicodeCache* scanner_contants);
473 473
474 void Initialize(UC16CharacterStream* source);
475
474 // Returns the next token. 476 // Returns the next token.
475 Token::Value Next(); 477 Token::Value Next();
476 478
477 // Returns true if there was a line terminator before the peek'ed token. 479 // Returns true if there was a line terminator before the peek'ed token,
478 bool has_line_terminator_before_next() const { 480 // possibly inside a multi-line comment.
479 return has_line_terminator_before_next_; 481 bool HasAnyLineTerminatorBeforeNext() const {
482 return has_line_terminator_before_next_ ||
483 has_multiline_comment_before_next_;
480 } 484 }
481 485
482 // Scans the input as a regular expression pattern, previous 486 // Scans the input as a regular expression pattern, previous
483 // character(s) must be /(=). Returns true if a pattern is scanned. 487 // character(s) must be /(=). Returns true if a pattern is scanned.
484 bool ScanRegExpPattern(bool seen_equal); 488 bool ScanRegExpPattern(bool seen_equal);
485 // Returns true if regexp flags are scanned (always since flags can 489 // Returns true if regexp flags are scanned (always since flags can
486 // be empty). 490 // be empty).
487 bool ScanRegExpFlags(); 491 bool ScanRegExpFlags();
488 492
489 // Tells whether the buffer contains an identifier (no escapes). 493 // Tells whether the buffer contains an identifier (no escapes).
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 // Scans a possible HTML comment -- begins with '<!'. 526 // Scans a possible HTML comment -- begins with '<!'.
523 Token::Value ScanHtmlComment(); 527 Token::Value ScanHtmlComment();
524 528
525 // Decodes a unicode escape-sequence which is part of an identifier. 529 // Decodes a unicode escape-sequence which is part of an identifier.
526 // If the escape sequence cannot be decoded the result is kBadChar. 530 // If the escape sequence cannot be decoded the result is kBadChar.
527 uc32 ScanIdentifierUnicodeEscape(); 531 uc32 ScanIdentifierUnicodeEscape();
528 532
529 // Start position of the octal literal last scanned. 533 // Start position of the octal literal last scanned.
530 Location octal_pos_; 534 Location octal_pos_;
531 535
536 // Whether there is a line terminator whitespace character after
537 // the current token, and before the next. Does not count newlines
538 // inside multiline comments.
532 bool has_line_terminator_before_next_; 539 bool has_line_terminator_before_next_;
540 // Whether there is a multi-line comment that contains a
541 // line-terminator after the current token, and before the next.
542 bool has_multiline_comment_before_next_;
533 }; 543 };
534 544
535 545
536 // ---------------------------------------------------------------------------- 546 // ----------------------------------------------------------------------------
537 // Keyword matching state machine. 547 // Keyword matching state machine.
538 548
539 class KeywordMatcher { 549 class KeywordMatcher {
540 // Incrementally recognize keywords. 550 // Incrementally recognize keywords.
541 // 551 //
542 // Recognized keywords: 552 // We distinguish between normal future reserved words and words that are
543 // break case catch const* continue debugger* default delete do else 553 // considered to be future reserved words only in strict mode as required by
544 // finally false for function if in instanceof native* new null 554 // ECMA-262 7.6.1.2.
545 // return switch this throw true try typeof var void while with
546 // 555 //
547 // *: Actually "future reserved keywords". These are the only ones we 556 // Recognized as keywords:
548 // recognize, the remaining are allowed as identifiers. 557 // break, case, catch, const*, continue, debugger, default, delete, do,
549 // In ES5 strict mode, we should disallow all reserved keywords. 558 // else, finally, false, for, function, if, in, instanceof, new, null,
559 // return, switch, this, throw, true, try, typeof, var, void, while, with.
560 //
561 // Recognized as Future Reserved Keywords:
562 // class, enum, export, extends, import, super.
563 //
564 // Recognized as Future Reserved Keywords (strict mode only):
565 // implements, interface, let, package, private, protected, public,
566 // static, yield.
567 //
568 // *: Actually a "future reserved keyword". It's the only one we are
569 // recognizing outside of ES5 strict mode, the remaining are allowed
570 // as identifiers.
571 //
550 public: 572 public:
551 KeywordMatcher() 573 KeywordMatcher()
552 : state_(INITIAL), 574 : state_(INITIAL),
553 token_(Token::IDENTIFIER), 575 token_(Token::IDENTIFIER),
554 keyword_(NULL), 576 keyword_(NULL),
555 counter_(0), 577 counter_(0),
556 keyword_token_(Token::ILLEGAL) {} 578 keyword_token_(Token::ILLEGAL) {}
557 579
558 Token::Value token() { return token_; } 580 Token::Value token() { return token_; }
559 581
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // keyword with the current prefix). 683 // keyword with the current prefix).
662 const char* keyword_; 684 const char* keyword_;
663 int counter_; 685 int counter_;
664 Token::Value keyword_token_; 686 Token::Value keyword_token_;
665 }; 687 };
666 688
667 689
668 } } // namespace v8::internal 690 } } // namespace v8::internal
669 691
670 #endif // V8_SCANNER_BASE_H_ 692 #endif // V8_SCANNER_BASE_H_
OLDNEW
« no previous file with comments | « src/scanner.cc ('k') | src/scanner-base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698