()
| 229 | } |
| 230 | |
| 231 | private parseObjectKey(): string { |
| 232 | this.skipWhitespace(); |
| 233 | |
| 234 | const char = this.peek(); |
| 235 | |
| 236 | if (!char) { |
| 237 | throw new JSONishSyntaxError("Expected an object key."); |
| 238 | } |
| 239 | |
| 240 | if (char === '"' || char === "'") { |
| 241 | return this.parseString(char); |
| 242 | } |
| 243 | |
| 244 | if (char === "[") { |
| 245 | throw new JSONishSyntaxError("Computed keys are not supported."); |
| 246 | } |
| 247 | |
| 248 | if (char === "/") { |
| 249 | throw new JSONishSyntaxError("Comments are not supported."); |
| 250 | } |
| 251 | |
| 252 | if (char === "`") { |
| 253 | throw new JSONishSyntaxError("Template literals are not supported."); |
| 254 | } |
| 255 | |
| 256 | if (!this.isIdentifierStart(char)) { |
| 257 | throw new JSONishSyntaxError("Expected a quoted string or bare key."); |
| 258 | } |
| 259 | |
| 260 | return this.parseIdentifier(); |
| 261 | } |
| 262 | |
| 263 | private parseString(quote: '"' | "'"): string { |
| 264 | this.consume(quote); |
no test coverage detected