Stage 3 of the faithful libyaml scanner port, continued. Translates fetch_tag, scan_tag, scan_tag_handle, scan_tag_uri, and scan_uri_escapes: verbatim (!<uri>), shorthand (!handle!suffix), and local (!suffix) tags, producing the handle and suffix for the parser to resolve. URI %-escapes are decoded by collecting the UTF-8 octets and decoding them as a unit. Unit-tested for a secondary-handle shorthand tag, a local tag, and a verbatim tag. Only directives (%YAML/%TAG) remain unported in the scanner. 317 tests, no regression.
27 lines
871 B
Swift
27 lines
871 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 anchor(name: String)
|
|
case alias(name: String)
|
|
case tag(handle: String, suffix: String)
|
|
case scalar(value: String, style: PureYAML.Parsing.ScalarStyle)
|
|
}
|
|
}
|