@std/yaml.ms#
Import each required symbol with import Name from "@std/yaml.ms".
YamlError Alternative#
Errors returned for malformed YAML, unsupported features, or exceeded resource limits.
type YamlError:
case InvalidInput
case InvalidData(line: Int, column: Int, reason: String)
case UnsupportedFeature(line: Int, reason: String)
case LimitExceededimpl Error for YamlError:
fn message() -> String:YamlError.InvalidData#
Malformed YAML or a form outside the supported parser’s accepted grammar.
case InvalidData(line: Int, column: Int, reason: String)YamlError.InvalidInput#
A supplied limit is negative, or stringify received a number whose text is not a YAML number.
case InvalidInputYamlError.LimitExceeded#
Parsing or validating the returned alias-expanded tree exceeds a supplied budget.
case LimitExceededYamlError.UnsupportedFeature#
An explicit tag, complex key or directive unsupported by this configuration parser.
case UnsupportedFeature(line: Int, reason: String)YamlError.InvalidData.column#
One-based Unicode scalar column within that source line.
column: IntYamlError.InvalidData.line#
One-based source line of the offending token or construct.
line: IntYamlError.InvalidData.reason#
Parser diagnostic describing the malformed construct.
reason: StringYamlError.UnsupportedFeature.line#
One-based source line where the unsupported construct appears.
line: IntYamlError.UnsupportedFeature.reason#
Diagnostic identifying the unsupported syntax or feature.
reason: StringYamlError.Error.message#
Formats parser positions and reason text; match the typed fields for programmatic handling.
fn message() -> String:YamlLimits Record#
Optional input-byte, nesting-depth, and parsed-value limits for YAML parsing.
type YamlLimits:
max_bytes: Optional[Int] = none
max_depth: Optional[Int] = none
max_values: Optional[Int] = noneYamlLimits.max_bytes#
Maximum UTF-8 input bytes before line-ending normalization; none adds no budget.
max_bytes: Optional[Int] = noneYamlLimits.max_depth#
Maximum value depth, including scalar leaves, with the root at one.
max_depth: Optional[Int] = noneYamlLimits.max_values#
Maximum containers and leaves, excluding keys; aliases count at each checked occurrence.
max_values: Optional[Int] = noneYamlValue Alternative#
A YAML value represented as null, boolean, number text, string, array, or object.
type YamlValue:
case Null
case BoolValue(value: Bool)
case NumberValue(text: String)
case StringValue(value: String)
case ArrayValue(values: List[YamlValue])
case ObjectValue(values: Map[String, YamlValue])YamlValue.ArrayValue#
An ordered YAML sequence with ordinary mutable list storage.
case ArrayValue(values: List[YamlValue])YamlValue.BoolValue#
A core-schema true or false value; yes and no remain strings.
case BoolValue(value: Bool)YamlValue.Null#
YAML null, including an empty document or a plain null spelling.
case NullYamlValue.NumberValue#
Numeric token text retained exactly instead of being coerced into Float.
case NumberValue(text: String)YamlValue.ObjectValue#
A textual-key mapping, with insertion order and duplicate-key checks.
case ObjectValue(values: Map[String, YamlValue])YamlValue.StringValue#
Text decoded from a quoted, plain or block scalar.
case StringValue(value: String)YamlValue.ArrayValue.values#
Sequence entries in document order, retaining nested references.
values: List[YamlValue]YamlValue.BoolValue.value#
The decoded boolean selected from YAML core-schema spellings.
value: BoolYamlValue.NumberValue.text#
Original numeric spelling, including supported base prefixes and nonfinite spellings.
text: StringYamlValue.ObjectValue.values#
Decoded string keys and their values; aliases may share nested payloads.
values: Map[String, YamlValue]YamlValue.StringValue.value#
Resulting Unicode text after escape decoding, folding and chomping.
value: Stringparse Function#
Parses a YAML document. Unsupported YAML features and invalid input include source locations.
fn parse(text: String, limits: Optional[YamlLimits] = none) -> Result[YamlValue, YamlError]:stringify Function#
Serializes a YAML value in block style with double-quoted strings.
fn stringify(value: YamlValue, max_bytes: Optional[Int] = none) -> Result[String, YamlError]: