| ... | @@ -39,6 +39,7 @@ pub const Item = union(enum) { | ... | @@ -39,6 +39,7 @@ pub const Item = union(enum) { |
| 39 | sequence: Sequence, | 39 | sequence: Sequence, |
| 40 | string: [:0]const u8, | 40 | string: [:0]const u8, |
| 41 | stream: Stream, | 41 | stream: Stream, |
| | 42 | anchor: [:0]const u8, |
| 42 | | 43 | |
| 43 | pub fn deinit(self: *const Item, alloc: std.mem.Allocator) void { | 44 | pub fn deinit(self: *const Item, alloc: std.mem.Allocator) void { |
| 44 | switch (self.*) { | 45 | switch (self.*) { |
| ... | @@ -51,6 +52,7 @@ pub const Item = union(enum) { | ... | @@ -51,6 +52,7 @@ pub const Item = union(enum) { |
| 51 | }, | 52 | }, |
| 52 | .string => |s| alloc.free(s), | 53 | .string => |s| alloc.free(s), |
| 53 | .stream => |s| s.deinit(alloc), | 54 | .stream => |s| s.deinit(alloc), |
| | 55 | .anchor => {}, |
| 54 | } | 56 | } |
| 55 | } | 57 | } |
| 56 | | 58 | |
| ... | @@ -76,6 +78,9 @@ pub const Item = union(enum) { | ... | @@ -76,6 +78,9 @@ pub const Item = union(enum) { |
| 76 | .string => { | 78 | .string => { |
| 77 | try writer.print("{s}", .{self.string}); | 79 | try writer.print("{s}", .{self.string}); |
| 78 | }, | 80 | }, |
| | 81 | .anchor => { |
| | 82 | // |
| | 83 | }, |
| 79 | } | 84 | } |
| 80 | try writer.writeAll("}"); | 85 | try writer.writeAll("}"); |
| 81 | } | 86 | } |
| ... | @@ -97,6 +102,7 @@ pub const Value = union(enum) { | ... | @@ -97,6 +102,7 @@ pub const Value = union(enum) { |
| 97 | string: [:0]const u8, | 102 | string: [:0]const u8, |
| 98 | mapping: Mapping, | 103 | mapping: Mapping, |
| 99 | sequence: Sequence, | 104 | sequence: Sequence, |
| | 105 | anchor: [:0]const u8, |
| 100 | | 106 | |
| 101 | pub fn deinit(self: *const Value, alloc: std.mem.Allocator) void { | 107 | pub fn deinit(self: *const Value, alloc: std.mem.Allocator) void { |
| 102 | switch (self.*) { | 108 | switch (self.*) { |
| ... | @@ -108,6 +114,7 @@ pub const Value = union(enum) { | ... | @@ -108,6 +114,7 @@ pub const Value = union(enum) { |
| 108 | for (s) |*item| item.deinit(alloc); | 114 | for (s) |*item| item.deinit(alloc); |
| 109 | alloc.free(s); | 115 | alloc.free(s); |
| 110 | }, | 116 | }, |
| | 117 | .anchor => {}, |
| 111 | } | 118 | } |
| 112 | } | 119 | } |
| 113 | | 120 | |
| ... | @@ -268,6 +275,7 @@ fn parse_item(p: *Parser, start: ?Token) Error!Item { | ... | @@ -268,6 +275,7 @@ fn parse_item(p: *Parser, start: ?Token) Error!Item { |
| 268 | c.YAML_MAPPING_START_EVENT => Item{ .mapping = try parse_mapping(p) }, | 275 | c.YAML_MAPPING_START_EVENT => Item{ .mapping = try parse_mapping(p) }, |
| 269 | c.YAML_SEQUENCE_START_EVENT => Item{ .sequence = try parse_sequence(p) }, | 276 | c.YAML_SEQUENCE_START_EVENT => Item{ .sequence = try parse_sequence(p) }, |
| 270 | c.YAML_SCALAR_EVENT => Item{ .string = try get_event_string(tok, p) }, | 277 | c.YAML_SCALAR_EVENT => Item{ .string = try get_event_string(tok, p) }, |
| | 278 | c.YAML_ALIAS_EVENT => .{ .anchor = std.mem.sliceTo(tok.data.alias.anchor, 0) }, |
| 271 | else => unreachable, | 279 | else => unreachable, |
| 272 | }; | 280 | }; |
| 273 | } | 281 | } |
| ... | @@ -344,6 +352,7 @@ fn parse_value(p: *Parser) Error!Value { | ... | @@ -344,6 +352,7 @@ fn parse_value(p: *Parser) Error!Value { |
| 344 | .mapping => |x| Value{ .mapping = x }, | 352 | .mapping => |x| Value{ .mapping = x }, |
| 345 | .sequence => |x| Value{ .sequence = x }, | 353 | .sequence => |x| Value{ .sequence = x }, |
| 346 | .string => |x| Value{ .string = x }, | 354 | .string => |x| Value{ .string = x }, |
| | 355 | .anchor => |x| Value{ .anchor = x }, |
| 347 | else => unreachable, | 356 | else => unreachable, |
| 348 | }; | 357 | }; |
| 349 | } | 358 | } |