Commit 4e9ac0a6 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[scanner] Simplify Scan

Change-Id: I331ff09ee06db39e2ca051db0a91823f5b8fb402
Reviewed-on: https://chromium-review.googlesource.com/1193262Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55445}
parent 99a2440c
...@@ -540,23 +540,20 @@ void Scanner::Scan() { ...@@ -540,23 +540,20 @@ void Scanner::Scan() {
next().invalid_template_escape_message = MessageTemplate::kNone; next().invalid_template_escape_message = MessageTemplate::kNone;
Token::Value token; Token::Value token;
Token::Value contextual_token = Token::UNINITIALIZED;
do { do {
// Remember the position of the next token
next().location.beg_pos = source_pos();
if (static_cast<unsigned>(c0_) <= 0x7F) { if (static_cast<unsigned>(c0_) <= 0x7F) {
Token::Value token = static_cast<Token::Value>(one_char_tokens[c0_]); token = static_cast<Token::Value>(one_char_tokens[c0_]);
if (token != Token::ILLEGAL) { if (token != Token::ILLEGAL) {
int pos = source_pos();
next().token = token;
next().contextual_token = Token::UNINITIALIZED;
next().location.beg_pos = pos;
next().location.end_pos = pos + 1;
Advance(); Advance();
return; break;
} }
} }
// Remember the position of the next token
next().location.beg_pos = source_pos();
switch (c0_) { switch (c0_) {
case '"': case '"':
case '\'': case '\'':
...@@ -747,13 +744,16 @@ void Scanner::Scan() { ...@@ -747,13 +744,16 @@ void Scanner::Scan() {
(CombineSurrogatePair() && (CombineSurrogatePair() &&
unicode_cache_->IsIdentifierStart(c0_))) { unicode_cache_->IsIdentifierStart(c0_))) {
token = ScanIdentifierOrKeyword(); token = ScanIdentifierOrKeyword();
if (Token::IsContextualKeyword(token)) {
contextual_token = token;
token = Token::IDENTIFIER;
}
} else if (IsDecimalDigit(c0_)) { } else if (IsDecimalDigit(c0_)) {
token = ScanNumber(false); token = ScanNumber(false);
} else if (c0_ == kEndOfInput) { } else if (c0_ == kEndOfInput) {
token = Token::EOS; token = Token::EOS;
} else { } else {
token = SkipWhiteSpace(); token = SkipWhiteSpace();
if (token == Token::ILLEGAL) Advance();
} }
break; break;
} }
...@@ -763,13 +763,8 @@ void Scanner::Scan() { ...@@ -763,13 +763,8 @@ void Scanner::Scan() {
} while (token == Token::WHITESPACE); } while (token == Token::WHITESPACE);
next().location.end_pos = source_pos(); next().location.end_pos = source_pos();
if (Token::IsContextualKeyword(token)) {
next().token = Token::IDENTIFIER;
next().contextual_token = token;
} else {
next().token = token; next().token = token;
next().contextual_token = Token::UNINITIALIZED; next().contextual_token = contextual_token;
}
#ifdef DEBUG #ifdef DEBUG
SanityCheckTokenDesc(current()); SanityCheckTokenDesc(current());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment