()
| 219 | } |
| 220 | |
| 221 | private parseValue(): unknown { |
| 222 | const character = this.peek() |
| 223 | if (character === "\"") { |
| 224 | return this.parseBasicString(this.input.startsWith("\"\"\"", this.index)) |
| 225 | } |
| 226 | if (character === "'") { |
| 227 | return this.parseLiteralString(this.input.startsWith("'''", this.index)) |
| 228 | } |
| 229 | if (character === "[") { |
| 230 | const array = this.parseArray() |
| 231 | this.inlineValues.add(array) |
| 232 | return array |
| 233 | } |
| 234 | if (character === "{") { |
| 235 | const table = this.parseInlineTable() |
| 236 | this.inlineValues.add(table) |
| 237 | return table |
| 238 | } |
| 239 | |
| 240 | const spaceSeparatedDateTime = /^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:[Zz]|[+-]\d{2}:\d{2})?)/ |
| 241 | .exec(this.input.slice(this.index)) |
| 242 | if (spaceSeparatedDateTime !== null) { |
| 243 | this.advance(spaceSeparatedDateTime[0].length) |
| 244 | return this.parseDate(`${spaceSeparatedDateTime[1]}T${spaceSeparatedDateTime[2]}`)! |
| 245 | } |
| 246 | |
| 247 | const start = this.index |
| 248 | while (!this.done && !/[\s,#\]}]/.test(this.peek())) { |
| 249 | this.advance() |
| 250 | } |
| 251 | const token = this.input.slice(start, this.index) |
| 252 | if (token === "true") return true |
| 253 | if (token === "false") return false |
| 254 | if (token.length === 0) this.fail("Expected a value") |
| 255 | |
| 256 | const date = this.parseDate(token) |
| 257 | if (date !== undefined) { |
| 258 | return date |
| 259 | } |
| 260 | |
| 261 | const number = this.parseNumber(token) |
| 262 | if (number !== undefined) { |
| 263 | return number |
| 264 | } |
| 265 | this.fail(`Invalid value '${token}'`) |
| 266 | } |
| 267 | |
| 268 | private parseDate(token: string): Date | string | undefined { |
| 269 | const dateTime = dateTimePattern.exec(token) |
no test coverage detected