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

Method parseValue

packages/effect/src/encoding/Yaml.ts:597–630  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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.

Callers 4

parseMethod · 0.95
parseTaggedValueMethod · 0.95
parseSequenceEntryMethod · 0.95
parseMappingEntryMethod · 0.95

Calls 13

skipWhitespaceMethod · 0.95
peekMethod · 0.95
failMethod · 0.95
parseSequenceMethod · 0.95
parseMappingMethod · 0.95
readQuotedMethod · 0.95
readUntilMethod · 0.95
parseTaggedValueMethod · 0.95
readPlainMethod · 0.95
parseScalarFunction · 0.85
hasMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected