PureYAML/Sources/Parsing/LibYAML.TokenType.swift
Mihaela Mihaljevic ab05580518 feat(parsing): port libyaml directive scanner to Swift
Adds the %YAML and %TAG directive scanner, the final scanner piece.
Ports fetch_directive, scan_directive, scan_directive_name,
scan_version_directive_value/number, and scan_tag_directive_value,
reusing the already-ported tag handle/URI scanners. Adds
versionDirective and tagDirective token kinds.

The libyaml scanner is now fully ported: stream, document markers,
directives, block + flow structure, plain/quoted/block scalars,
anchors, aliases, and tags. 319 tests, no regression.
2026-06-24 16:54:04 +02:00

29 lines
983 B
Swift

extension PureYAML.Parsing.LibYAML {
/// A scanner token kind, mirroring `yaml_token_type_t`. The flow-collection,
/// anchor, tag, alias, and directive kinds are added as their fetchers are
/// ported; the block + plain-scalar core is present.
enum TokenType: Equatable {
case streamStart
case streamEnd
case documentStart
case documentEnd
case blockSequenceStart
case blockMappingStart
case blockEnd
case blockEntry
case flowSequenceStart
case flowMappingStart
case flowSequenceEnd
case flowMappingEnd
case flowEntry
case key
case value
case versionDirective(major: Int, minor: Int)
case tagDirective(handle: String, prefix: String)
case anchor(name: String)
case alias(name: String)
case tag(handle: String, suffix: String)
case scalar(value: String, style: PureYAML.Parsing.ScalarStyle)
}
}