| 50107 | } |
| 50108 | }, |
| 50109 | string = function string() { |
| 50110 | |
| 50111 | // Parse a string value. |
| 50112 | |
| 50113 | var hex, |
| 50114 | i, |
| 50115 | string = '', |
| 50116 | delim, |
| 50117 | // double quote or single quote |
| 50118 | uffff; |
| 50119 | |
| 50120 | // When parsing for string values, we must look for ' or " and \ characters. |
| 50121 | |
| 50122 | if (ch === '"' || ch === "'") { |
| 50123 | delim = ch; |
| 50124 | while (next()) { |
| 50125 | if (ch === delim) { |
| 50126 | next(); |
| 50127 | return string; |
| 50128 | } else if (ch === '\\') { |
| 50129 | next(); |
| 50130 | if (ch === 'u') { |
| 50131 | uffff = 0; |
| 50132 | for (i = 0; i < 4; i += 1) { |
| 50133 | hex = parseInt(next(), 16); |
| 50134 | if (!isFinite(hex)) { |
| 50135 | break; |
| 50136 | } |
| 50137 | uffff = uffff * 16 + hex; |
| 50138 | } |
| 50139 | string += String.fromCharCode(uffff); |
| 50140 | } else if (ch === '\r') { |
| 50141 | if (peek() === '\n') { |
| 50142 | next(); |
| 50143 | } |
| 50144 | } else if (typeof escapee[ch] === 'string') { |
| 50145 | string += escapee[ch]; |
| 50146 | } else { |
| 50147 | break; |
| 50148 | } |
| 50149 | } else if (ch === '\n') { |
| 50150 | // unescaped newlines are invalid; see: |
| 50151 | // https://github.com/aseemk/json5/issues/24 |
| 50152 | // TODO this feels special-cased; are there other |
| 50153 | // invalid unescaped chars? |
| 50154 | break; |
| 50155 | } else { |
| 50156 | string += ch; |
| 50157 | } |
| 50158 | } |
| 50159 | } |
| 50160 | error("Bad string"); |
| 50161 | }, |
| 50162 | inlineComment = function inlineComment() { |
| 50163 | |
| 50164 | // Skip an inline comment, assuming this is one. The current character should |