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() {
next().invalid_template_escape_message = MessageTemplate::kNone;
Token::Value token;
Token::Value contextual_token = Token::UNINITIALIZED;
do {
// Remember the position of the next token
next().location.beg_pos = source_pos();
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) {
int pos = source_pos();
next().token = token;
next().contextual_token = Token::UNINITIALIZED;
next().location.beg_pos = pos;
next().location.end_pos = pos + 1;
Advance();
return;
break;
}
}
// Remember the position of the next token
next().location.beg_pos = source_pos();
switch (c0_) {
case '"':
case '\'':
......@@ -747,13 +744,16 @@ void Scanner::Scan() {
(CombineSurrogatePair() &&
unicode_cache_->IsIdentifierStart(c0_))) {
token = ScanIdentifierOrKeyword();
if (Token::IsContextualKeyword(token)) {
contextual_token = token;
token = Token::IDENTIFIER;
}
} else if (IsDecimalDigit(c0_)) {
token = ScanNumber(false);
} else if (c0_ == kEndOfInput) {
token = Token::EOS;
} else {
token = SkipWhiteSpace();
if (token == Token::ILLEGAL) Advance();
}
break;
}
......@@ -763,13 +763,8 @@ void Scanner::Scan() {
} while (token == Token::WHITESPACE);
next().location.end_pos = source_pos();
if (Token::IsContextualKeyword(token)) {
next().token = Token::IDENTIFIER;
next().contextual_token = token;
} else {
next().token = token;
next().contextual_token = Token::UNINITIALIZED;
}
next().token = token;
next().contextual_token = contextual_token;
#ifdef DEBUG
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