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_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 if (token == T_OBJECT_END && !(options_ & JSON_ALLOW_TRAILING_COMMAS)) { | 535 if (token == T_OBJECT_END && !(options_ & JSON_ALLOW_TRAILING_COMMAS)) { |
536 ReportError(JSONReader::JSON_TRAILING_COMMA, 1); | 536 ReportError(JSONReader::JSON_TRAILING_COMMA, 1); |
537 return NULL; | 537 return NULL; |
538 } | 538 } |
539 } else if (token != T_OBJECT_END) { | 539 } else if (token != T_OBJECT_END) { |
540 ReportError(JSONReader::JSON_SYNTAX_ERROR, 0); | 540 ReportError(JSONReader::JSON_SYNTAX_ERROR, 0); |
541 return NULL; | 541 return NULL; |
542 } | 542 } |
543 } | 543 } |
544 | 544 |
545 if (token != T_OBJECT_END) | |
546 return NULL; | |
547 | |
548 return dict.release(); | 545 return dict.release(); |
549 } | 546 } |
550 | 547 |
551 Value* JSONParser::ConsumeList() { | 548 Value* JSONParser::ConsumeList() { |
552 if (*pos_ != '[') { | 549 if (*pos_ != '[') { |
553 ReportError(JSONReader::JSON_UNEXPECTED_TOKEN, 1); | 550 ReportError(JSONReader::JSON_UNEXPECTED_TOKEN, 1); |
554 return NULL; | 551 return NULL; |
555 } | 552 } |
556 | 553 |
557 StackMarker depth_check(&stack_depth_); | 554 StackMarker depth_check(&stack_depth_); |
(...skipping 23 matching lines...) Expand all Loading... |
581 if (token == T_ARRAY_END && !(options_ & JSON_ALLOW_TRAILING_COMMAS)) { | 578 if (token == T_ARRAY_END && !(options_ & JSON_ALLOW_TRAILING_COMMAS)) { |
582 ReportError(JSONReader::JSON_TRAILING_COMMA, 1); | 579 ReportError(JSONReader::JSON_TRAILING_COMMA, 1); |
583 return NULL; | 580 return NULL; |
584 } | 581 } |
585 } else if (token != T_ARRAY_END) { | 582 } else if (token != T_ARRAY_END) { |
586 ReportError(JSONReader::JSON_SYNTAX_ERROR, 1); | 583 ReportError(JSONReader::JSON_SYNTAX_ERROR, 1); |
587 return NULL; | 584 return NULL; |
588 } | 585 } |
589 } | 586 } |
590 | 587 |
591 if (token != T_ARRAY_END) | |
592 return NULL; | |
593 | |
594 return list.release(); | 588 return list.release(); |
595 } | 589 } |
596 | 590 |
597 Value* JSONParser::ConsumeString() { | 591 Value* JSONParser::ConsumeString() { |
598 StringBuilder string; | 592 StringBuilder string; |
599 if (!ConsumeStringRaw(&string)) | 593 if (!ConsumeStringRaw(&string)) |
600 return NULL; | 594 return NULL; |
601 | 595 |
602 // Create the Value representation, using a hidden root, if configured | 596 // Create the Value representation, using a hidden root, if configured |
603 // to do so, and if the string can be represented by StringPiece. | 597 // to do so, and if the string can be represented by StringPiece. |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 const std::string& description) { | 958 const std::string& description) { |
965 if (line || column) { | 959 if (line || column) { |
966 return StringPrintf("Line: %i, column: %i, %s", | 960 return StringPrintf("Line: %i, column: %i, %s", |
967 line, column, description.c_str()); | 961 line, column, description.c_str()); |
968 } | 962 } |
969 return description; | 963 return description; |
970 } | 964 } |
971 | 965 |
972 } // namespace internal | 966 } // namespace internal |
973 } // namespace base | 967 } // namespace base |
OLD | NEW |