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