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 } } }