(quote: '"' | "'")
| 261 | } |
| 262 | |
| 263 | private parseString(quote: '"' | "'"): string { |
| 264 | this.consume(quote); |
| 265 | |
| 266 | let result = ""; |
| 267 | |
| 268 | while (!this.isAtEnd()) { |
| 269 | const char = this.consumeCharacter(); |
| 270 | |
| 271 | if (char === quote) { |
| 272 | return result; |
| 273 | } |
| 274 | |
| 275 | if (char === "\n" || char === "\r") { |
| 276 | throw new JSONishSyntaxError("Unterminated string literal."); |
| 277 | } |
| 278 | |
| 279 | if (char === "\\") { |
| 280 | result += this.parseEscapeSequence(); |
| 281 | continue; |
| 282 | } |
| 283 | |
| 284 | result += char; |
| 285 | } |
| 286 | |
| 287 | throw new JSONishSyntaxError("Unterminated string literal."); |
| 288 | } |
| 289 | |
| 290 | private parseEscapeSequence(): string { |
| 291 | const escape = this.consumeCharacter(); |
no test coverage detected