Chromium Code Reviews| Index: src/scanner-base.cc |
| diff --git a/src/scanner-base.cc b/src/scanner-base.cc |
| index 89591baa243e003247e44ae4145b819590b8efce..b9f15239dc7f4a82d53c8df5a44806eafd20ffa7 100644 |
| --- a/src/scanner-base.cc |
| +++ b/src/scanner-base.cc |
| @@ -80,6 +80,7 @@ JavaScriptScanner::JavaScriptScanner(UnicodeCache* scanner_contants) |
| Token::Value JavaScriptScanner::Next() { |
| current_ = next_; |
| has_line_terminator_before_next_ = false; |
| + next_is_first_on_line_ = false; |
|
William Hesse
2011/06/21 11:37:41
Could we call these things something more parallel
|
| Scan(); |
| return current_.token; |
| } |
| @@ -109,6 +110,7 @@ bool JavaScriptScanner::SkipWhiteSpace() { |
| // Ignore line terminators, but remember them. This is necessary |
| // for automatic semicolon insertion. |
| has_line_terminator_before_next_ = true; |
| + next_is_first_on_line_ = true; |
| } |
| Advance(); |
| } |
| @@ -117,7 +119,7 @@ bool JavaScriptScanner::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_ == '-' && next_is_first_on_line_) { |
| Advance(); |
| if (c0_ == '-') { |
| Advance(); |
| @@ -167,7 +169,9 @@ Token::Value JavaScriptScanner::SkipMultiLineComment() { |
| } |
| // If we have reached the end of the multi-line comment, we |
| // consume the '/' and insert a whitespace. This way all |
| - // multi-line comments are treated as whitespace. |
| + // multi-line comments are treated as whitespace (except |
| + // when checking whether there is non-whitespace before a |
| + // --> comment). |
| if (ch == '*' && c0_ == '/') { |
| c0_ = ' '; |
| return Token::WHITESPACE; |
| @@ -211,6 +215,7 @@ void JavaScriptScanner::Scan() { |
| case '\n': |
| Advance(); |
| has_line_terminator_before_next_ = true; |
| + next_is_first_on_line_ = true; |
| token = Token::WHITESPACE; |
| break; |
| @@ -289,7 +294,7 @@ void JavaScriptScanner::Scan() { |
| Advance(); |
| if (c0_ == '-') { |
| Advance(); |
| - if (c0_ == '>' && has_line_terminator_before_next_) { |
| + if (c0_ == '>' && next_is_first_on_line_) { |
| // For compatibility with SpiderMonkey, we skip lines that |
| // start with an HTML comment end '-->'. |
| token = SkipSingleLineComment(); |