()
| 595 | } |
| 596 | |
| 597 | private parseValue(): unknown { |
| 598 | this.skipWhitespace() |
| 599 | const character = this.peek() |
| 600 | if (character === "[" || character === "{") { |
| 601 | if (this.blockDepth + ++this.depth > maxDepth) this.fail(depthError) |
| 602 | const collection = character === "[" ? this.parseSequence() : this.parseMapping() |
| 603 | this.depth-- |
| 604 | this.afterJsonNode = true |
| 605 | return collection |
| 606 | } |
| 607 | if (character === "\"" || character === "'") return parseScalar(this.readQuoted(character)) |
| 608 | if (character === "*") { |
| 609 | this.index++ |
| 610 | const name = this.readUntil(isFlowAliasEnd) |
| 611 | if (!this.anchors.has(name)) this.fail(`Unknown alias '*${name}'`) |
| 612 | return this.anchors.get(name) |
| 613 | } |
| 614 | if (character === "&") { |
| 615 | this.index++ |
| 616 | const name = this.readUntil(isFlowNameEnd) |
| 617 | const next = this.peek() |
| 618 | if (name === "" || next === "[" || next === "{") this.fail("Invalid anchor") |
| 619 | this.skipWhitespace() |
| 620 | if (this.peek() === "&") this.fail("Multiple anchors on one node") |
| 621 | if (this.peek() === "*") this.fail("An alias cannot have an anchor") |
| 622 | const value = this.peek() === "!" ? this.parseTaggedValue(true) : this.parseValue() |
| 623 | this.anchors.set(name, value) |
| 624 | return value |
| 625 | } |
| 626 | if (character === "!") return this.parseTaggedValue(false) |
| 627 | const text = this.readPlain(isFlowPlainEnd) |
| 628 | this.plainText = text |
| 629 | return parseScalar(text) |
| 630 | } |
| 631 | |
| 632 | // A tag, optionally followed by an anchor, then the node it applies to. |
| 633 | // `anchored` is true when an anchor before the tag belongs to the same node. |
no test coverage detected