| 1267 | } |
| 1268 | |
| 1269 | function string(x) { |
| 1270 | var c, pos = 0, r = '', result; |
| 1271 | |
| 1272 | function hex(n) { |
| 1273 | var i = parseInt(source_row.substr(pos + 1, n), 16); |
| 1274 | pos += n; |
| 1275 | if (i >= 32 && i <= 126 && |
| 1276 | i !== 34 && i !== 92 && i !== 39) { |
| 1277 | warn_at('unexpected_a', line, character, '\\'); |
| 1278 | } |
| 1279 | character += n; |
| 1280 | c = String.fromCharCode(i); |
| 1281 | } |
| 1282 | |
| 1283 | if (json_mode && x !== '"') { |
| 1284 | warn_at('expected_a', line, character, '"'); |
| 1285 | } |
| 1286 | |
| 1287 | if (xquote === x || (xmode === 'scriptstring' && !xquote)) { |
| 1288 | return it('(punctuator)', x); |
| 1289 | } |
| 1290 | |
| 1291 | for (;;) { |
| 1292 | while (pos >= source_row.length) { |
| 1293 | pos = 0; |
| 1294 | if (xmode !== 'html' || !next_line()) { |
| 1295 | stop_at('unclosed', line, from); |
| 1296 | } |
| 1297 | } |
| 1298 | c = source_row.charAt(pos); |
| 1299 | if (c === x) { |
| 1300 | character += 1; |
| 1301 | source_row = source_row.slice(pos + 1); |
| 1302 | result = it('(string)', r); |
| 1303 | result.quote = x; |
| 1304 | return result; |
| 1305 | } |
| 1306 | if (c < ' ') { |
| 1307 | if (c === '\n' || c === '\r') { |
| 1308 | break; |
| 1309 | } |
| 1310 | warn_at('control_a', line, character + pos, |
| 1311 | source_row.slice(0, pos)); |
| 1312 | } else if (c === xquote) { |
| 1313 | warn_at('bad_html', line, character + pos); |
| 1314 | } else if (c === '<') { |
| 1315 | if (option.safe && xmode === 'html') { |
| 1316 | warn_at('adsafe_a', line, character + pos, c); |
| 1317 | } else if (source_row.charAt(pos + 1) === '/' && (xmode || option.safe)) { |
| 1318 | warn_at('expected_a_b', line, character, |
| 1319 | '<\\/', '</'); |
| 1320 | } else if (source_row.charAt(pos + 1) === '!' && (xmode || option.safe)) { |
| 1321 | warn_at('unexpected_a', line, character, '<!'); |
| 1322 | } |
| 1323 | } else if (c === '\\') { |
| 1324 | if (xmode === 'html') { |
| 1325 | if (option.safe) { |
| 1326 | warn_at('adsafe_a', line, character + pos, c); |