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

Unified Diff: src/scanner.cc

Issue 160073006: Implement handling of arrow functions in the parser (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Version with parsing code only, tests into test-parsing.cc Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: src/scanner.cc
diff --git a/src/scanner.cc b/src/scanner.cc
index 92f0b94053fd78dd8c199a18fb96ea29a9a88645..dea1e324c803497168cdd33ff4de79ce7de59d8b 100644
--- a/src/scanner.cc
+++ b/src/scanner.cc
@@ -24,6 +24,7 @@ namespace internal {
Scanner::Scanner(UnicodeCache* unicode_cache)
: unicode_cache_(unicode_cache),
+ param_list_finder_(unicode_cache_),
octal_pos_(Location::invalid()),
harmony_scoping_(false),
harmony_modules_(false),
@@ -210,6 +211,7 @@ Token::Value Scanner::Next() {
current_ = next_;
has_line_terminator_before_next_ = false;
has_multiline_comment_before_next_ = false;
+ param_list_finder_.Update(this);
if (static_cast<unsigned>(c0_) <= 0x7f) {
Token::Value token = static_cast<Token::Value>(one_char_tokens[c0_]);
if (token != Token::ILLEGAL) {
@@ -395,10 +397,12 @@ void Scanner::Scan() {
break;
case '=':
- // = == ===
+ // = == === =>
Advance();
if (c0_ == '=') {
token = Select('=', Token::EQ_STRICT, Token::EQ);
+ } else if (c0_ == '>') {
+ token = Select(Token::ARROW);
} else {
token = Token::ASSIGN;
}
@@ -928,6 +932,29 @@ static Token::Value KeywordOrIdentifierToken(const uint8_t* input,
}
+bool Scanner::IdentifierIsFutureStrictReserved(const AstString* string) const {
marja 2014/06/17 11:47:38 This sounds wrong, since we have a separate token
+ if (string->is_one_byte()) {
+ return Token::FUTURE_STRICT_RESERVED_WORD == KeywordOrIdentifierToken(
+ string->raw_data(), string->length(),
+ harmony_scoping_, harmony_modules_);
+ }
+
+ // Language keywords are always ASCII-only, so we can just pick the
+ // lower bytes to have a one-byte representation of the keyword.
+ const unsigned len = string->length();
+ Vector<unsigned char> chars = Vector<unsigned char>::New(len);
+ const uint16_t* uchars = reinterpret_cast<const uint16_t*>(string->raw_data());
+
+ for (unsigned i = 0; i < len; i++)
+ (chars.start())[i] = 0xFF & uchars[i];
+
+ bool result = Token::FUTURE_STRICT_RESERVED_WORD == KeywordOrIdentifierToken(
+ chars.start(), len, harmony_scoping_, harmony_modules_);
+ chars.Dispose();
+ return result;
+}
+
+
Token::Value Scanner::ScanIdentifierOrKeyword() {
ASSERT(unicode_cache_->IsIdentifierStart(c0_));
LiteralScope literal(this);

Powered by Google App Engine
This is Rietveld 408576698