| 200 | }, |
| 201 | |
| 202 | string = function () { |
| 203 | |
| 204 | // Parse a string value. |
| 205 | |
| 206 | var hex, |
| 207 | i, |
| 208 | string = '', |
| 209 | delim, // double quote or single quote |
| 210 | uffff; |
| 211 | |
| 212 | // When parsing for string values, we must look for ' or " and \ characters. |
| 213 | |
| 214 | if (ch === '"' || ch === "'") { |
| 215 | delim = ch; |
| 216 | while (next()) { |
| 217 | if (ch === delim) { |
| 218 | next(); |
| 219 | return string; |
| 220 | } else if (ch === '\\') { |
| 221 | next(); |
| 222 | if (ch === 'u') { |
| 223 | uffff = 0; |
| 224 | for (i = 0; i < 4; i += 1) { |
| 225 | hex = parseInt(next(), 16); |
| 226 | if (!isFinite(hex)) { |
| 227 | break; |
| 228 | } |
| 229 | uffff = uffff * 16 + hex; |
| 230 | } |
| 231 | string += String.fromCharCode(uffff); |
| 232 | } else if (ch === '\r') { |
| 233 | if (peek() === '\n') { |
| 234 | next(); |
| 235 | } |
| 236 | } else if (typeof escapee[ch] === 'string') { |
| 237 | string += escapee[ch]; |
| 238 | } else { |
| 239 | break; |
| 240 | } |
| 241 | } else if (ch === '\n') { |
| 242 | // unescaped newlines are invalid; see: |
| 243 | // https://github.com/aseemk/json5/issues/24 |
| 244 | // invalid unescaped chars? |
| 245 | break; |
| 246 | } else { |
| 247 | string += ch; |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | error("Bad string"); |
| 252 | }, |
| 253 | |
| 254 | inlineComment = function () { |
| 255 | |