OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 #include "base/json/json_parser.h" | 5 #include "base/json/json_parser.h" |
6 | 6 |
7 #include "base/float_util.h" | 7 #include "base/float_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 428 |
429 char next_char = *NextChar(); | 429 char next_char = *NextChar(); |
430 if (next_char == '/') { | 430 if (next_char == '/') { |
431 // Single line comment, read to newline. | 431 // Single line comment, read to newline. |
432 while (CanConsume(1)) { | 432 while (CanConsume(1)) { |
433 char next_char = *NextChar(); | 433 char next_char = *NextChar(); |
434 if (next_char == '\n' || next_char == '\r') | 434 if (next_char == '\n' || next_char == '\r') |
435 return true; | 435 return true; |
436 } | 436 } |
437 } else if (next_char == '*') { | 437 } else if (next_char == '*') { |
| 438 char previous_char = '\0'; |
438 // Block comment, read until end marker. | 439 // Block comment, read until end marker. |
439 while (CanConsume(2)) { | 440 while (CanConsume(1)) { |
440 if (*NextChar() == '*' && *NextChar() == '/') { | 441 next_char = *NextChar(); |
| 442 if (previous_char == '*' && next_char == '/') { |
441 // EatWhitespaceAndComments will inspect pos_, which will still be on | 443 // EatWhitespaceAndComments will inspect pos_, which will still be on |
442 // the last / of the comment, so advance once more (which may also be | 444 // the last / of the comment, so advance once more (which may also be |
443 // end of input). | 445 // end of input). |
444 NextChar(); | 446 NextChar(); |
445 return true; | 447 return true; |
446 } | 448 } |
| 449 previous_char = next_char; |
447 } | 450 } |
448 | 451 |
449 // If the comment is unterminated, GetNextToken will report T_END_OF_INPUT. | 452 // If the comment is unterminated, GetNextToken will report T_END_OF_INPUT. |
450 } | 453 } |
451 | 454 |
452 return false; | 455 return false; |
453 } | 456 } |
454 | 457 |
455 Value* JSONParser::ParseNextToken() { | 458 Value* JSONParser::ParseNextToken() { |
456 return ParseToken(GetNextToken()); | 459 return ParseToken(GetNextToken()); |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 const std::string& description) { | 958 const std::string& description) { |
956 if (line || column) { | 959 if (line || column) { |
957 return StringPrintf("Line: %i, column: %i, %s", | 960 return StringPrintf("Line: %i, column: %i, %s", |
958 line, column, description.c_str()); | 961 line, column, description.c_str()); |
959 } | 962 } |
960 return description; | 963 return description; |
961 } | 964 } |
962 | 965 |
963 } // namespace internal | 966 } // namespace internal |
964 } // namespace base | 967 } // namespace base |
OLD | NEW |