OLD | NEW |
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 #include "src/parsing/scanner.h" | 7 #include "src/parsing/scanner.h" |
8 | 8 |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 (keyword_length <= 9 || input[9] == keyword[9])) { \ | 1333 (keyword_length <= 9 || input[9] == keyword[9])) { \ |
1334 return token; \ | 1334 return token; \ |
1335 } \ | 1335 } \ |
1336 } | 1336 } |
1337 KEYWORDS(KEYWORD_GROUP_CASE, KEYWORD) | 1337 KEYWORDS(KEYWORD_GROUP_CASE, KEYWORD) |
1338 } | 1338 } |
1339 return Token::IDENTIFIER; | 1339 return Token::IDENTIFIER; |
1340 } | 1340 } |
1341 | 1341 |
1342 | 1342 |
1343 bool Scanner::IdentifierIsFutureStrictReserved( | |
1344 const AstRawString* string) const { | |
1345 // Keywords are always 1-byte strings. | |
1346 if (!string->is_one_byte()) return false; | |
1347 if (string->IsOneByteEqualTo("let") || string->IsOneByteEqualTo("static") || | |
1348 string->IsOneByteEqualTo("yield")) { | |
1349 return true; | |
1350 } | |
1351 return Token::FUTURE_STRICT_RESERVED_WORD == | |
1352 KeywordOrIdentifierToken(string->raw_data(), string->length()); | |
1353 } | |
1354 | |
1355 | |
1356 Token::Value Scanner::ScanIdentifierOrKeyword() { | 1343 Token::Value Scanner::ScanIdentifierOrKeyword() { |
1357 DCHECK(unicode_cache_->IsIdentifierStart(c0_)); | 1344 DCHECK(unicode_cache_->IsIdentifierStart(c0_)); |
1358 LiteralScope literal(this); | 1345 LiteralScope literal(this); |
1359 if (IsInRange(c0_, 'a', 'z')) { | 1346 if (IsInRange(c0_, 'a', 'z')) { |
1360 do { | 1347 do { |
1361 char first_char = static_cast<char>(c0_); | 1348 char first_char = static_cast<char>(c0_); |
1362 Advance<false, false>(); | 1349 Advance<false, false>(); |
1363 AddLiteralChar(first_char); | 1350 AddLiteralChar(first_char); |
1364 } while (IsInRange(c0_, 'a', 'z')); | 1351 } while (IsInRange(c0_, 'a', 'z')); |
1365 | 1352 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 // 2, reset the source to the desired position, | 1624 // 2, reset the source to the desired position, |
1638 source_->Seek(position); | 1625 source_->Seek(position); |
1639 // 3, re-scan, by scanning the look-ahead char + 1 token (next_). | 1626 // 3, re-scan, by scanning the look-ahead char + 1 token (next_). |
1640 c0_ = source_->Advance(); | 1627 c0_ = source_->Advance(); |
1641 Next(); | 1628 Next(); |
1642 DCHECK_EQ(next_.location.beg_pos, static_cast<int>(position)); | 1629 DCHECK_EQ(next_.location.beg_pos, static_cast<int>(position)); |
1643 } | 1630 } |
1644 | 1631 |
1645 } // namespace internal | 1632 } // namespace internal |
1646 } // namespace v8 | 1633 } // namespace v8 |
OLD | NEW |