Fix three should-parse conformance gaps: a repeated document-end marker (M7A3), a root block scalar ended by a document marker (W4TN), and an empty explicit key in a flow mapping (DFF7). Threaded the located parse end mark through the new explicit-key emit. Parse-level suite conformance reaches 318/333.
27 lines
1.2 KiB
Swift
27 lines
1.2 KiB
Swift
extension PureYAML.Parsing.TokenEventParser {
|
|
/// The key node of an explicit (`?`) mapping entry. The key may be empty: `? : v`, a trailing
|
|
/// `? }` / `? ]` / `? ,`, or `?` at stream end all denote a null key. With no node and no
|
|
/// properties to anchor, emit a null scalar rather than failing to find a node.
|
|
mutating func parseExplicitMappingKey(
|
|
properties: PureYAML.Parsing.NodeProperties,
|
|
) throws -> PureYAML.Parsing.NodeResult {
|
|
guard properties == .none, isAtEmptyExplicitKey else {
|
|
return try parseNode(properties: properties)
|
|
}
|
|
let mark = cursor.current?.mark ?? cursor.previous?.endMark ?? .start
|
|
try emit(.scalar(value: "", anchor: nil, tag: nil, style: .plain, mark: mark, endMark: mark))
|
|
return PureYAML.Parsing.NodeResult(kind: .scalar, endMark: mark)
|
|
}
|
|
|
|
/// Whether an explicit key has no key node: the next token is the value indicator, a flow
|
|
/// terminator (`}`, `]`, `,`), or the stream has ended.
|
|
var isAtEmptyExplicitKey: Bool {
|
|
switch cursor.current?.kind {
|
|
case nil, .mappingValue, .flowMappingEnd, .flowSequenceEnd, .flowEntry:
|
|
true
|
|
default:
|
|
false
|
|
}
|
|
}
|
|
}
|