MCPcopy Create free account
hub / github.com/Effect-TS/effect / parseTaggedValue

Method parseTaggedValue

packages/effect/src/encoding/Yaml.ts:634–654  ·  view source on GitHub ↗
(anchored: boolean)

Source from the content-addressed store, hash-verified

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.
634 private parseTaggedValue(anchored: boolean): unknown {
635 const fail = (message: string) => this.fail(message)
636 const tag = this.readFlowTag(fail)
637 this.skipWhitespace()
638 let anchor: string | undefined
639 if (this.peek() === "&") {
640 if (anchored) this.fail("Multiple anchors on one node")
641 this.index++
642 anchor = this.readUntil(isFlowNameEnd)
643 if (anchor === "") this.fail("Invalid anchor")
644 this.skipWhitespace()
645 }
646 if (this.peek() === "&") this.fail("Multiple anchors on one node")
647 if (this.peek() === "!") this.fail("Multiple tags on one node")
648 if (this.peek() === "*") this.fail("An alias cannot have a tag")
649 this.plainText = undefined
650 const node = this.parseValue()
651 const value = resolveTag(tag, node, this.plainText, fail)
652 if (anchor !== undefined) this.anchors.set(anchor, value)
653 return value
654 }
655
656 // Reads a plain scalar up to `stop`, rejecting directive, tag, explicit key and
657 // block sequence indicators.

Callers 1

parseValueMethod · 0.95

Calls 8

readFlowTagMethod · 0.95
skipWhitespaceMethod · 0.95
peekMethod · 0.95
failMethod · 0.95
readUntilMethod · 0.95
parseValueMethod · 0.95
resolveTagFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected