Add parseLocated / parseStreamLocated, returning a Model.LocatedValue tree parallel in shape to Value, where every node carries its source span (1-based line/column) and located children. Collections span from their opening to closing event; scalars carry a start-anchored span; aliases and merge-inherited pairs honestly point at their reference site. The plain Value, its equality, and the conformance oracle are untouched: locations are built only when the streaming composer is asked for them (tracksLocations), behind new entry points, so the default value path is byte-identical. A whole-suite test proves the located projection equals a plain parse for every passing case (402/402), including through merge keys and aliases, and the canonical-event and gap gates stay green.
23 lines
747 B
Swift
23 lines
747 B
Swift
public extension PureYAML.Parsing {
|
|
/// Pure-Swift YAML parser for block mappings, sequences, and common scalars.
|
|
struct Parser: Sendable {
|
|
public init() {}
|
|
|
|
public func parse(_ yaml: String) throws -> PureYAML.Model.Value {
|
|
try parseStreaming(yaml)
|
|
}
|
|
|
|
public func parseStream(_ yaml: String) throws -> [PureYAML.Stream.Document] {
|
|
try parseStreamStreaming(yaml)
|
|
}
|
|
|
|
public func parseLocated(_ yaml: String) throws -> PureYAML.Model.LocatedValue {
|
|
try parseLocatedStreaming(yaml)
|
|
}
|
|
|
|
public func parseStreamLocated(_ yaml: String) throws -> [PureYAML.Model.LocatedValue] {
|
|
try parseStreamLocatedStreaming(yaml)
|
|
}
|
|
}
|
|
}
|