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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 AdvanceSkipWhitespace(); | 85 AdvanceSkipWhitespace(); |
86 return true; | 86 return true; |
87 } | 87 } |
88 return false; | 88 return false; |
89 } | 89 } |
90 | 90 |
91 // A JSON string (production JSONString) is subset of valid JavaScript string | 91 // A JSON string (production JSONString) is subset of valid JavaScript string |
92 // literals. The string must only be double-quoted (not single-quoted), and | 92 // literals. The string must only be double-quoted (not single-quoted), and |
93 // the only allowed backslash-escapes are ", /, \, b, f, n, r, t and | 93 // the only allowed backslash-escapes are ", /, \, b, f, n, r, t and |
94 // four-digit hex escapes (uXXXX). Any other use of backslashes is invalid. | 94 // four-digit hex escapes (uXXXX). Any other use of backslashes is invalid. |
95 Handle<Object> ParseJsonString() { | 95 Handle<String> ParseJsonString() { |
96 return ScanJsonString<false>(); | 96 return ScanJsonString<false>(); |
97 } | 97 } |
98 Handle<Object> ParseJsonSymbol() { | 98 Handle<String> ParseJsonSymbol() { |
99 return ScanJsonString<true>(); | 99 return ScanJsonString<true>(); |
100 } | 100 } |
101 template <bool is_symbol> | 101 template <bool is_symbol> |
102 Handle<Object> ScanJsonString(); | 102 Handle<String> ScanJsonString(); |
103 // Slow version for unicode support, uses the first ascii_count characters, | 103 // Slow version for unicode support, uses the first ascii_count characters, |
104 // as first part of a ConsString | 104 // as first part of a ConsString |
105 Handle<Object> SlowScanJsonString(); | 105 Handle<String> SlowScanJsonString(); |
106 | 106 |
107 // A JSON number (production JSONNumber) is a subset of the valid JavaScript | 107 // A JSON number (production JSONNumber) is a subset of the valid JavaScript |
108 // decimal number literals. | 108 // decimal number literals. |
109 // It includes an optional minus sign, must have at least one | 109 // It includes an optional minus sign, must have at least one |
110 // digit before and after a decimal point, may not have prefixed zeros (unless | 110 // digit before and after a decimal point, may not have prefixed zeros (unless |
111 // the integer part is zero), and may include an exponent part (e.g., "e-10"). | 111 // the integer part is zero), and may include an exponent part (e.g., "e-10"). |
112 // Hexadecimal and octal numbers are not allowed. | 112 // Hexadecimal and octal numbers are not allowed. |
113 Handle<Object> ParseJsonNumber(); | 113 Handle<Object> ParseJsonNumber(); |
114 | 114 |
115 // Parse a single JSON value from input (grammar production JSONValue). | 115 // Parse a single JSON value from input (grammar production JSONValue). |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 Isolate* isolate_; | 157 Isolate* isolate_; |
158 uc32 c0_; | 158 uc32 c0_; |
159 int position_; | 159 int position_; |
160 | 160 |
161 double number_; | 161 double number_; |
162 }; | 162 }; |
163 | 163 |
164 } } // namespace v8::internal | 164 } } // namespace v8::internal |
165 | 165 |
166 #endif // V8_JSON_PARSER_H_ | 166 #endif // V8_JSON_PARSER_H_ |
OLD | NEW |