• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_PARSING_SCANNER_INL_H_
6 #define V8_PARSING_SCANNER_INL_H_
7 
8 #include "src/parsing/scanner.h"
9 #include "src/unicode-cache-inl.h"
10 
11 namespace v8 {
12 namespace internal {
13 
SkipWhiteSpace()14 V8_INLINE Token::Value Scanner::SkipWhiteSpace() {
15   int start_position = source_pos();
16 
17   while (true) {
18     // We won't skip behind the end of input.
19     DCHECK(!unicode_cache_->IsWhiteSpace(kEndOfInput));
20 
21     // Advance as long as character is a WhiteSpace or LineTerminator.
22     // Remember if the latter is the case.
23     if (unibrow::IsLineTerminator(c0_)) {
24       next().after_line_terminator = true;
25     } else if (!unicode_cache_->IsWhiteSpace(c0_)) {
26       break;
27     }
28     Advance();
29   }
30 
31   // Return whether or not we skipped any characters.
32   if (source_pos() == start_position) {
33     DCHECK_NE('0', c0_);
34     return Token::ILLEGAL;
35   }
36 
37   return Token::WHITESPACE;
38 }
39 
40 }  // namespace internal
41 }  // namespace v8
42 
43 #endif  // V8_PARSING_SCANNER_INL_H_
44