Commit 19a8f1ba authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[scanner] Use AdvanceUntil in SkipWhiteSpace

Change-Id: I4a578589290e91da2eae4cef8f936e6c888e177c
Reviewed-on: https://chromium-review.googlesource.com/1194015Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55497}
parent 0c6c2235
......@@ -150,24 +150,23 @@ static const Token::Value one_char_tokens[] = {
// clang-format on
V8_INLINE Token::Value Scanner::SkipWhiteSpace() {
int start_position = source_pos();
// We won't skip behind the end of input.
DCHECK(!unicode_cache_->IsWhiteSpaceOrLineTerminator(kEndOfInput));
// Make sure we skip at least one character.
if (!unicode_cache_->IsWhiteSpaceOrLineTerminator(c0_)) return Token::ILLEGAL;
if (!next().after_line_terminator && unibrow::IsLineTerminator(c0_)) {
next().after_line_terminator = true;
}
// Advance as long as character is a WhiteSpace or LineTerminator.
while (unicode_cache_->IsWhiteSpaceOrLineTerminator(c0_)) {
if (!next().after_line_terminator && unibrow::IsLineTerminator(c0_)) {
AdvanceUntil([=](uc32 c0) {
if (!unicode_cache_->IsWhiteSpaceOrLineTerminator(c0)) return true;
if (!next().after_line_terminator && unibrow::IsLineTerminator(c0)) {
next().after_line_terminator = true;
}
Advance();
}
// Return whether or not we skipped any characters.
if (source_pos() == start_position) {
DCHECK_NE('0', c0_);
return Token::ILLEGAL;
}
return false;
});
return Token::WHITESPACE;
}
......
......@@ -284,7 +284,7 @@ Token::Value Scanner::SkipSingleLineComment() {
// separately by the lexical grammar and becomes part of the
// stream of input elements for the syntactic grammar (see
// ECMA-262, section 7.4).
AdvanceUntil([](uc32 c0_) { return unibrow::IsLineTerminator(c0_); });
AdvanceUntil([](uc32 c0) { return unibrow::IsLineTerminator(c0); });
return Token::WHITESPACE;
}
......
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