Index: src/parsing/scanner.cc |
diff --git a/src/parsing/scanner.cc b/src/parsing/scanner.cc |
index 6a9b32e63461f3b12e334546d8b94db6c48d49d7..34e3dfb9560511c940a5dc3968e593d464e097dc 100644 |
--- a/src/parsing/scanner.cc |
+++ b/src/parsing/scanner.cc |
@@ -42,6 +42,7 @@ Scanner::Scanner(UnicodeCache* unicode_cache) |
octal_pos_(Location::invalid()), |
decimal_with_leading_zero_pos_(Location::invalid()), |
found_html_comment_(false), |
+ allow_html_comments_(true), |
allow_harmony_exponentiation_operator_(false) { |
bookmark_current_.literal_chars = &bookmark_current_literal_; |
bookmark_current_.raw_literal_chars = &bookmark_current_raw_literal_; |
@@ -49,8 +50,8 @@ Scanner::Scanner(UnicodeCache* unicode_cache) |
bookmark_next_.raw_literal_chars = &bookmark_next_raw_literal_; |
} |
- |
-void Scanner::Initialize(Utf16CharacterStream* source) { |
+void Scanner::Initialize(Utf16CharacterStream* source, |
+ bool allow_html_comments) { |
source_ = source; |
// Need to capture identifiers in order to recognize "get" and "set" |
// in object literals. |
@@ -58,6 +59,7 @@ void Scanner::Initialize(Utf16CharacterStream* source) { |
// Skip initial whitespace allowing HTML comment ends just like |
// after a newline and scan first token. |
has_line_terminator_before_next_ = true; |
+ allow_html_comments_ = allow_html_comments; |
SkipWhiteSpace(); |
Scan(); |
} |
@@ -325,7 +327,8 @@ bool Scanner::SkipWhiteSpace() { |
// line (with only whitespace in front of it), we treat the rest |
// of the line as a comment. This is in line with the way |
// SpiderMonkey handles it. |
- if (c0_ == '-' && has_line_terminator_before_next_) { |
+ if (c0_ == '-' && has_line_terminator_before_next_ && |
+ allow_html_comments_) { |
Advance(); |
if (c0_ == '-') { |
Advance(); |
@@ -498,7 +501,7 @@ void Scanner::Scan() { |
token = Select(Token::LTE); |
} else if (c0_ == '<') { |
token = Select('=', Token::ASSIGN_SHL, Token::SHL); |
- } else if (c0_ == '!') { |
+ } else if (c0_ == '!' && allow_html_comments_) { |
token = ScanHtmlComment(); |
} else { |
token = Token::LT; |
@@ -564,7 +567,8 @@ void Scanner::Scan() { |
Advance(); |
if (c0_ == '-') { |
Advance(); |
- if (c0_ == '>' && has_line_terminator_before_next_) { |
+ if (c0_ == '>' && has_line_terminator_before_next_ && |
+ allow_html_comments_) { |
// For compatibility with SpiderMonkey, we skip lines that |
// start with an HTML comment end '-->'. |
token = SkipSingleLineComment(); |