()
| 48415 | } |
| 48416 | }, |
| 48417 | string = function string() { |
| 48418 | |
| 48419 | // Parse a string value. |
| 48420 | |
| 48421 | var hex, |
| 48422 | i, |
| 48423 | string = '', |
| 48424 | delim, |
| 48425 | // double quote or single quote |
| 48426 | uffff; |
| 48427 | |
| 48428 | // When parsing for string values, we must look for ' or " and \ characters. |
| 48429 | |
| 48430 | if (ch === '"' || ch === "'") { |
| 48431 | delim = ch; |
| 48432 | while (next()) { |
| 48433 | if (ch === delim) { |
| 48434 | next(); |
| 48435 | return string; |
| 48436 | } else if (ch === '\\') { |
| 48437 | next(); |
| 48438 | if (ch === 'u') { |
| 48439 | uffff = 0; |
| 48440 | for (i = 0; i < 4; i += 1) { |
| 48441 | hex = parseInt(next(), 16); |
| 48442 | if (!isFinite(hex)) { |
| 48443 | break; |
| 48444 | } |
| 48445 | uffff = uffff * 16 + hex; |
| 48446 | } |
| 48447 | string += String.fromCharCode(uffff); |
| 48448 | } else if (ch === '\r') { |
| 48449 | if (peek() === '\n') { |
| 48450 | next(); |
| 48451 | } |
| 48452 | } else if (typeof escapee[ch] === 'string') { |
| 48453 | string += escapee[ch]; |
| 48454 | } else { |
| 48455 | break; |
| 48456 | } |
| 48457 | } else if (ch === '\n') { |
| 48458 | // unescaped newlines are invalid; see: |
| 48459 | // https://github.com/aseemk/json5/issues/24 |
| 48460 | // TODO this feels special-cased; are there other |
| 48461 | // invalid unescaped chars? |
| 48462 | break; |
| 48463 | } else { |
| 48464 | string += ch; |
| 48465 | } |
| 48466 | } |
| 48467 | } |
| 48468 | error("Bad string"); |
| 48469 | }, |
| 48470 | inlineComment = function inlineComment() { |
| 48471 | |
| 48472 | // Skip an inline comment, assuming this is one. The current character should |
no test coverage detected