OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // A JSON parser. Converts strings of JSON into a Value object (see | 5 // A JSON parser. Converts strings of JSON into a Value object (see |
6 // base/values.h). | 6 // base/values.h). |
7 // http://www.ietf.org/rfc/rfc4627.txt?number=4627 | 7 // http://www.ietf.org/rfc/rfc4627.txt?number=4627 |
8 // | 8 // |
9 // Known limitations/deviations from the RFC: | 9 // Known limitations/deviations from the RFC: |
10 // - Only knows how to parse ints within the range of a signed 32 bit int and | 10 // - Only knows how to parse ints within the range of a signed 32 bit int and |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // false. | 186 // false. |
187 bool EatComment(); | 187 bool EatComment(); |
188 | 188 |
189 // Checks if |json_pos_| matches str. | 189 // Checks if |json_pos_| matches str. |
190 bool NextStringMatch(const wchar_t* str, size_t length); | 190 bool NextStringMatch(const wchar_t* str, size_t length); |
191 | 191 |
192 // Sets the error code that will be returned to the caller. The current | 192 // Sets the error code that will be returned to the caller. The current |
193 // line and column are determined and added into the final message. | 193 // line and column are determined and added into the final message. |
194 void SetErrorCode(const JsonParseError error, const wchar_t* error_pos); | 194 void SetErrorCode(const JsonParseError error, const wchar_t* error_pos); |
195 | 195 |
| 196 const Token* kInvalidToken; |
| 197 |
196 // Pointer to the starting position in the input string. | 198 // Pointer to the starting position in the input string. |
197 const wchar_t* start_pos_; | 199 const wchar_t* start_pos_; |
198 | 200 |
199 // Pointer to the current position in the input string. | 201 // Pointer to the current position in the input string. |
200 const wchar_t* json_pos_; | 202 const wchar_t* json_pos_; |
201 | 203 |
202 // Used to keep track of how many nested lists/dicts there are. | 204 // Used to keep track of how many nested lists/dicts there are. |
203 int stack_depth_; | 205 int stack_depth_; |
204 | 206 |
205 // A parser flag that allows trailing commas in objects and arrays. | 207 // A parser flag that allows trailing commas in objects and arrays. |
206 bool allow_trailing_comma_; | 208 bool allow_trailing_comma_; |
207 | 209 |
208 // Contains the error code for the last call to JsonToValue(), if any. | 210 // Contains the error code for the last call to JsonToValue(), if any. |
209 JsonParseError error_code_; | 211 JsonParseError error_code_; |
210 int error_line_; | 212 int error_line_; |
211 int error_col_; | 213 int error_col_; |
212 | 214 |
213 DISALLOW_COPY_AND_ASSIGN(JSONReader); | 215 DISALLOW_COPY_AND_ASSIGN(JSONReader); |
214 }; | 216 }; |
215 | 217 |
216 } // namespace base | 218 } // namespace base |
217 | 219 |
218 #endif // BASE_JSON_JSON_READER_H_ | 220 #endif // BASE_JSON_JSON_READER_H_ |
OLD | NEW |