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 allow_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 allow_html_comments_(allow_html_comments), |
43 found_html_comment_(false), | 44 found_html_comment_(false), |
44 allow_harmony_exponentiation_operator_(false) { | 45 allow_harmony_exponentiation_operator_(false) { |
45 bookmark_current_.literal_chars = &bookmark_current_literal_; | 46 bookmark_current_.literal_chars = &bookmark_current_literal_; |
46 bookmark_current_.raw_literal_chars = &bookmark_current_raw_literal_; | 47 bookmark_current_.raw_literal_chars = &bookmark_current_raw_literal_; |
47 bookmark_next_.literal_chars = &bookmark_next_literal_; | 48 bookmark_next_.literal_chars = &bookmark_next_literal_; |
48 bookmark_next_.raw_literal_chars = &bookmark_next_raw_literal_; | 49 bookmark_next_.raw_literal_chars = &bookmark_next_raw_literal_; |
49 } | 50 } |
50 | 51 |
51 | 52 |
52 void Scanner::Initialize(Utf16CharacterStream* source) { | 53 void Scanner::Initialize(Utf16CharacterStream* source) { |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 token = ScanString(); | 478 token = ScanString(); |
478 break; | 479 break; |
479 | 480 |
480 case '<': | 481 case '<': |
481 // < <= << <<= <!-- | 482 // < <= << <<= <!-- |
482 Advance(); | 483 Advance(); |
483 if (c0_ == '=') { | 484 if (c0_ == '=') { |
484 token = Select(Token::LTE); | 485 token = Select(Token::LTE); |
485 } else if (c0_ == '<') { | 486 } else if (c0_ == '<') { |
486 token = Select('=', Token::ASSIGN_SHL, Token::SHL); | 487 token = Select('=', Token::ASSIGN_SHL, Token::SHL); |
487 } else if (c0_ == '!') { | 488 } else if (c0_ == '!' && allow_html_comments_) { |
488 token = ScanHtmlComment(); | 489 token = ScanHtmlComment(); |
489 } else { | 490 } else { |
490 token = Token::LT; | 491 token = Token::LT; |
491 } | 492 } |
492 break; | 493 break; |
493 | 494 |
494 case '>': | 495 case '>': |
495 // > >= >> >>= >>> >>>= | 496 // > >= >> >>= >>> >>>= |
496 Advance(); | 497 Advance(); |
497 if (c0_ == '=') { | 498 if (c0_ == '=') { |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); | 1679 backing_store_.Add(static_cast<uint8_t>((one_byte_length >> 7) | 0x80u)); |
1679 } | 1680 } |
1680 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); | 1681 backing_store_.Add(static_cast<uint8_t>(one_byte_length & 0x7f)); |
1681 | 1682 |
1682 backing_store_.AddBlock(bytes); | 1683 backing_store_.AddBlock(bytes); |
1683 return backing_store_.EndSequence().start(); | 1684 return backing_store_.EndSequence().start(); |
1684 } | 1685 } |
1685 | 1686 |
1686 } // namespace internal | 1687 } // namespace internal |
1687 } // namespace v8 | 1688 } // namespace v8 |
OLD | NEW |