libyaml makes every ':' in a flow collection a value indicator, so it mis-scans ':x', 'http://foo.com', '::vector', and 'omitted value:,', and drops the value after an adjacent quoted or collection key. Per the spec a ':' only ends a node when followed by whitespace, end of input, or a flow indicator, except an adjacent ':' after a JSON key (a quoted flow scalar or a flow collection used as the key). Gate the ':' value-indicator dispatch on that rule, tracking on the pending simple key whether it is a JSON node (set for quoted flow scalars and flow-collection starts). End the plain scalar at a ':' before a flow indicator instead of rejecting it as unexpected. Surpasses libyaml on 4ABK, 58MP, 5T43, DBG4, FRK4, HM87/00, with 9MMW (mixing adjacent and separated keys) still correct. Port score 292 -> 298.
25 lines
1.2 KiB
Swift
25 lines
1.2 KiB
Swift
extension PureYAML.Parsing.LibYAML {
|
|
/// Port of `yaml_simple_key_t`. A potential implicit ("simple") mapping key:
|
|
/// a node that may turn out to be a key once a `:` is seen on the same line.
|
|
/// `tokenNumber` records where its `KEY` token must be spliced into the queue.
|
|
struct SimpleKey: Equatable {
|
|
/// Whether a simple key is still possible at this flow level.
|
|
var possible: Bool
|
|
/// Whether a `:` is required (a key sitting exactly at the block indent).
|
|
var required: Bool
|
|
/// The absolute token number where the `KEY` token is inserted.
|
|
var tokenNumber: Int
|
|
/// The position the potential key started at.
|
|
var mark: PureYAML.Parsing.Mark
|
|
/// Whether this key is a JSON-style node (a quoted flow scalar). A `:`
|
|
/// adjacent to such a key is a value indicator even without a following
|
|
/// space, per the YAML flow "adjacent value" rule.
|
|
var isJSON = false
|
|
|
|
/// The empty entry pushed for a new flow level (`{ 0, 0, 0, {0,0,0} }`).
|
|
static var empty: Self {
|
|
Self(possible: false, required: false, tokenNumber: 0, mark: .start)
|
|
}
|
|
}
|
|
}
|