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 18 matching lines...) Expand all Loading... | |
29 | 29 |
30 | 30 |
31 // Default implementation for streams that do not support bookmarks. | 31 // Default implementation for streams that do not support bookmarks. |
32 bool Utf16CharacterStream::SetBookmark() { return false; } | 32 bool Utf16CharacterStream::SetBookmark() { return false; } |
33 void Utf16CharacterStream::ResetToBookmark() { UNREACHABLE(); } | 33 void Utf16CharacterStream::ResetToBookmark() { UNREACHABLE(); } |
34 | 34 |
35 | 35 |
36 // ---------------------------------------------------------------------------- | 36 // ---------------------------------------------------------------------------- |
37 // Scanner | 37 // Scanner |
38 | 38 |
39 Scanner::Scanner(UnicodeCache* unicode_cache) | 39 Scanner::Scanner(UnicodeCache* unicode_cache, bool ignore_html_comments) |
40 : unicode_cache_(unicode_cache), | 40 : unicode_cache_(unicode_cache), |
41 bookmark_c0_(kNoBookmark), | 41 bookmark_c0_(kNoBookmark), |
42 octal_pos_(Location::invalid()), | 42 octal_pos_(Location::invalid()), |
43 ignore_html_comments_(ignore_html_comments), | |
43 found_html_comment_(false) { | 44 found_html_comment_(false) { |
44 bookmark_current_.literal_chars = &bookmark_current_literal_; | 45 bookmark_current_.literal_chars = &bookmark_current_literal_; |
45 bookmark_current_.raw_literal_chars = &bookmark_current_raw_literal_; | 46 bookmark_current_.raw_literal_chars = &bookmark_current_raw_literal_; |
46 bookmark_next_.literal_chars = &bookmark_next_literal_; | 47 bookmark_next_.literal_chars = &bookmark_next_literal_; |
47 bookmark_next_.raw_literal_chars = &bookmark_next_raw_literal_; | 48 bookmark_next_.raw_literal_chars = &bookmark_next_raw_literal_; |
48 } | 49 } |
49 | 50 |
50 | 51 |
51 void Scanner::Initialize(Utf16CharacterStream* source) { | 52 void Scanner::Initialize(Utf16CharacterStream* source) { |
52 source_ = source; | 53 source_ = source; |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
476 token = ScanString(); | 477 token = ScanString(); |
477 break; | 478 break; |
478 | 479 |
479 case '<': | 480 case '<': |
480 // < <= << <<= <!-- | 481 // < <= << <<= <!-- |
481 Advance(); | 482 Advance(); |
482 if (c0_ == '=') { | 483 if (c0_ == '=') { |
483 token = Select(Token::LTE); | 484 token = Select(Token::LTE); |
484 } else if (c0_ == '<') { | 485 } else if (c0_ == '<') { |
485 token = Select('=', Token::ASSIGN_SHL, Token::SHL); | 486 token = Select('=', Token::ASSIGN_SHL, Token::SHL); |
486 } else if (c0_ == '!') { | 487 } else if (c0_ == '!' && ignore_html_comments_) { |
rossberg
2016/03/18 13:14:07
So "skip" == "ignore" == do parse? That is confusi
vogelheim
2016/03/18 13:56:01
Done.
Yeah, I struggled with the naming... I like
| |
487 token = ScanHtmlComment(); | 488 token = ScanHtmlComment(); |
488 } else { | 489 } else { |
489 token = Token::LT; | 490 token = Token::LT; |
490 } | 491 } |
491 break; | 492 break; |
492 | 493 |
493 case '>': | 494 case '>': |
494 // > >= >> >>= >>> >>>= | 495 // > >= >> >>= >>> >>>= |
495 Advance(); | 496 Advance(); |
496 if (c0_ == '=') { | 497 if (c0_ == '=') { |
(...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1670 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1671 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
1671 } | 1672 } |
1672 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1673 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
1673 | 1674 |
1674 backing_store_.AddBlock(bytes); | 1675 backing_store_.AddBlock(bytes); |
1675 return backing_store_.EndSequence().start(); | 1676 return backing_store_.EndSequence().start(); |
1676 } | 1677 } |
1677 | 1678 |
1678 } // namespace internal | 1679 } // namespace internal |
1679 } // namespace v8 | 1680 } // namespace v8 |
OLD | NEW |