| ... | ... | @@ -18,6 +18,7 @@ pub const Item = union(enum) { |
| 18 | 18 | mapping: Mapping, |
| 19 | 19 | sequence: []Item, |
| 20 | 20 | document: Document, |
| 21 | string: []const u8, |
| 21 | 22 | }; |
| 22 | 23 | |
| 23 | 24 | pub const Key = struct { |
| ... | ... | @@ -190,20 +191,27 @@ fn condense_event_list_sequence(from: []Item, at: usize, to: *std.ArrayList(Item |
| 190 | 191 | var i: usize = 1; |
| 191 | 192 | while (true) : (i += 1) { |
| 192 | 193 | const ele = from[at+i]; |
| 193 | | if (ele == .event and @enumToInt(ele.event.type) == c.YAML_SEQUENCE_END_EVENT) { |
| 194 | | break; |
| 195 | | } |
| 196 | 194 | if (ele == .event) { |
| 195 | if (@enumToInt(ele.event.type) == c.YAML_SEQUENCE_END_EVENT) { |
| 196 | break; |
| 197 | } |
| 198 | if (@enumToInt(ele.event.type) == c.YAML_SCALAR_EVENT) { |
| 199 | continue; |
| 200 | } |
| 197 | 201 | return null; |
| 198 | 202 | } |
| 199 | 203 | } |
| 200 | 204 | |
| 201 | | const result = from[at+1..at+i]; |
| 202 | | for (result) |item| { |
| 203 | | std.debug.assert(item == .mapping); |
| 205 | const result = &std.ArrayList(Item).init(to.allocator); |
| 206 | for (from[at+1..at+i]) |item| { |
| 207 | try result.append(switch (item) { |
| 208 | .mapping => item, |
| 209 | .event => Item{ .string = get_event_string(item.event, lines) }, |
| 210 | else => unreachable, |
| 211 | }); |
| 204 | 212 | } |
| 205 | 213 | try to.append(Item{ |
| 206 | | .sequence = result, |
| 214 | .sequence = result.items, |
| 207 | 215 | }); |
| 208 | 216 | return 0+i; |
| 209 | 217 | } |