OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 // Parse a single JSON value from input (grammar production JSONValue). | 124 // Parse a single JSON value from input (grammar production JSONValue). |
125 // A JSON value is either a (double-quoted) string literal, a number literal, | 125 // A JSON value is either a (double-quoted) string literal, a number literal, |
126 // one of "true", "false", or "null", or an object or array literal. | 126 // one of "true", "false", or "null", or an object or array literal. |
127 Handle<Object> ParseJsonValue(); | 127 Handle<Object> ParseJsonValue(); |
128 | 128 |
129 // Parse a JSON object literal (grammar production JSONObject). | 129 // Parse a JSON object literal (grammar production JSONObject). |
130 // An object literal is a squiggly-braced and comma separated sequence | 130 // An object literal is a squiggly-braced and comma separated sequence |
131 // (possibly empty) of key/value pairs, where the key is a JSON string | 131 // (possibly empty) of key/value pairs, where the key is a JSON string |
132 // literal, the value is a JSON value, and the two are separated by a colon. | 132 // literal, the value is a JSON value, and the two are separated by a colon. |
133 // A JSON array dosn't allow numbers and identifiers as keys, like a | 133 // A JSON array doesn't allow numbers and identifiers as keys, like a |
134 // JavaScript array. | 134 // JavaScript array. |
135 Handle<Object> ParseJsonObject(); | 135 Handle<Object> ParseJsonObject(); |
136 | 136 |
137 // Parses a JSON array literal (grammar production JSONArray). An array | 137 // Parses a JSON array literal (grammar production JSONArray). An array |
138 // literal is a square-bracketed and comma separated sequence (possibly empty) | 138 // literal is a square-bracketed and comma separated sequence (possibly empty) |
139 // of JSON values. | 139 // of JSON values. |
140 // A JSON array doesn't allow leaving out values from the sequence, nor does | 140 // A JSON array doesn't allow leaving out values from the sequence, nor does |
141 // it allow a terminal comma, like a JavaScript array does. | 141 // it allow a terminal comma, like a JavaScript array does. |
142 Handle<Object> ParseJsonArray(); | 142 Handle<Object> ParseJsonArray(); |
143 | 143 |
(...skipping 26 matching lines...) Expand all Loading... |
170 source_ = source; | 170 source_ = source; |
171 source_length_ = source_->length(); | 171 source_length_ = source_->length(); |
172 | 172 |
173 // Optimized fast case where we only have ASCII characters. | 173 // Optimized fast case where we only have ASCII characters. |
174 if (seq_ascii) { | 174 if (seq_ascii) { |
175 seq_source_ = Handle<SeqAsciiString>::cast(source_); | 175 seq_source_ = Handle<SeqAsciiString>::cast(source_); |
176 } | 176 } |
177 | 177 |
178 // Set initial position right before the string. | 178 // Set initial position right before the string. |
179 position_ = -1; | 179 position_ = -1; |
180 // Advance to the first character (posibly EOS) | 180 // Advance to the first character (possibly EOS) |
181 AdvanceSkipWhitespace(); | 181 AdvanceSkipWhitespace(); |
182 Handle<Object> result = ParseJsonValue(); | 182 Handle<Object> result = ParseJsonValue(); |
183 if (result.is_null() || c0_ != kEndOfString) { | 183 if (result.is_null() || c0_ != kEndOfString) { |
184 // Parse failed. Current character is the unexpected token. | 184 // Parse failed. Current character is the unexpected token. |
185 | 185 |
186 const char* message; | 186 const char* message; |
187 Factory* factory = isolate()->factory(); | 187 Factory* factory = isolate()->factory(); |
188 Handle<JSArray> array; | 188 Handle<JSArray> array; |
189 | 189 |
190 switch (c0_) { | 190 switch (c0_) { |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 } | 591 } |
592 ASSERT_EQ('"', c0_); | 592 ASSERT_EQ('"', c0_); |
593 // Advance past the last '"'. | 593 // Advance past the last '"'. |
594 AdvanceSkipWhitespace(); | 594 AdvanceSkipWhitespace(); |
595 return result; | 595 return result; |
596 } | 596 } |
597 | 597 |
598 } } // namespace v8::internal | 598 } } // namespace v8::internal |
599 | 599 |
600 #endif // V8_JSON_PARSER_H_ | 600 #endif // V8_JSON_PARSER_H_ |
OLD | NEW |