Ports parser.c: the one-event-at-a-time state machine that turns the scanner's token stream into the YAML event stream. Covers stream and document framing, directive processing with %TAG handle resolution and default handles, the node property/tag/anchor production, block and indentless sequences, block mappings, and flow sequences and mappings including the single-pair `?` mapping forms. Output verified against the libyaml reference event dumper: the empty mapping value, %TAG resolution, and shorthand tags all match byte for byte. 331 tests, no regression.
31 lines
992 B
Swift
31 lines
992 B
Swift
extension PureYAML.Parsing.LibYAML {
|
|
/// The parser state, mirroring `yaml_parser_state_e`. Each case names the
|
|
/// production the state machine is in the middle of recognizing.
|
|
enum ParserState: Equatable {
|
|
case streamStart
|
|
case implicitDocumentStart
|
|
case documentStart
|
|
case documentContent
|
|
case documentEnd
|
|
case blockNode
|
|
case blockNodeOrIndentlessSequence
|
|
case flowNode
|
|
case blockSequenceFirstEntry
|
|
case blockSequenceEntry
|
|
case indentlessSequenceEntry
|
|
case blockMappingFirstKey
|
|
case blockMappingKey
|
|
case blockMappingValue
|
|
case flowSequenceFirstEntry
|
|
case flowSequenceEntry
|
|
case flowSequenceEntryMappingKey
|
|
case flowSequenceEntryMappingValue
|
|
case flowSequenceEntryMappingEnd
|
|
case flowMappingFirstKey
|
|
case flowMappingKey
|
|
case flowMappingValue
|
|
case flowMappingEmptyValue
|
|
case end
|
|
}
|
|
}
|