authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-06-24 14:52:12+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-06-24 15:01:14+02:00
logcea8a2f5008bdda8bfd85af58537d148edde75ba
treeb37a5a6f78901337e6683378ad6becf5dffae6f7
parentb55a3cefa49549e62dbd40f385cc0a5b4b6433b3

tapi: apply ast fixes


2 files changed, 12 insertions(+), 5 deletions(-)

src/link/tapi/parse.zig+12-4
...@@ -82,6 +82,8 @@ pub const Node = struct {...@@ -82,6 +82,8 @@ pub const Node = struct {
82 options: std.fmt.FormatOptions,82 options: std.fmt.FormatOptions,
83 writer: anytype,83 writer: anytype,
84 ) !void {84 ) !void {
85 _ = fmt;
86 _ = options;
85 if (self.directive) |id| {87 if (self.directive) |id| {
86 try std.fmt.format(writer, "{{ ", .{});88 try std.fmt.format(writer, "{{ ", .{});
87 const directive = self.base.tree.tokens[id];89 const directive = self.base.tree.tokens[id];
...@@ -125,6 +127,8 @@ pub const Node = struct {...@@ -125,6 +127,8 @@ pub const Node = struct {
125 options: std.fmt.FormatOptions,127 options: std.fmt.FormatOptions,
126 writer: anytype,128 writer: anytype,
127 ) !void {129 ) !void {
130 _ = fmt;
131 _ = options;
128 try std.fmt.format(writer, "{{ ", .{});132 try std.fmt.format(writer, "{{ ", .{});
129 for (self.values.items) |entry| {133 for (self.values.items) |entry| {
130 const key = self.base.tree.tokens[entry.key];134 const key = self.base.tree.tokens[entry.key];
...@@ -159,6 +163,8 @@ pub const Node = struct {...@@ -159,6 +163,8 @@ pub const Node = struct {
159 options: std.fmt.FormatOptions,163 options: std.fmt.FormatOptions,
160 writer: anytype,164 writer: anytype,
161 ) !void {165 ) !void {
166 _ = fmt;
167 _ = options;
162 try std.fmt.format(writer, "[ ", .{});168 try std.fmt.format(writer, "[ ", .{});
163 for (self.values.items) |node| {169 for (self.values.items) |node| {
164 try std.fmt.format(writer, "{}, ", .{node});170 try std.fmt.format(writer, "{}, ", .{node});
...@@ -174,7 +180,10 @@ pub const Node = struct {...@@ -174,7 +180,10 @@ pub const Node = struct {
174180
175 pub const base_tag: Node.Tag = .value;181 pub const base_tag: Node.Tag = .value;
176182
177 pub fn deinit(self: *Value, allocator: *Allocator) void {}183 pub fn deinit(self: *Value, allocator: *Allocator) void {
184 _ = self;
185 _ = allocator;
186 }
178187
179 pub fn format(188 pub fn format(
180 self: *const Value,189 self: *const Value,
...@@ -182,6 +191,8 @@ pub const Node = struct {...@@ -182,6 +191,8 @@ pub const Node = struct {
182 options: std.fmt.FormatOptions,191 options: std.fmt.FormatOptions,
183 writer: anytype,192 writer: anytype,
184 ) !void {193 ) !void {
194 _ = fmt;
195 _ = options;
185 const start = self.base.tree.tokens[self.start.?];196 const start = self.base.tree.tokens[self.start.?];
186 const end = self.base.tree.tokens[self.end.?];197 const end = self.base.tree.tokens[self.end.?];
187 return std.fmt.format(writer, "{s}", .{198 return std.fmt.format(writer, "{s}", .{
...@@ -563,7 +574,6 @@ const Parser = struct {...@@ -563,7 +574,6 @@ const Parser = struct {
563 if (self.eatToken(.SingleQuote)) |_| {574 if (self.eatToken(.SingleQuote)) |_| {
564 node.start = node.start.? + 1;575 node.start = node.start.? + 1;
565 while (true) {576 while (true) {
566 const pos = self.token_it.pos;
567 const tok = self.token_it.next();577 const tok = self.token_it.next();
568 switch (tok.id) {578 switch (tok.id) {
569 .SingleQuote => {579 .SingleQuote => {
...@@ -579,7 +589,6 @@ const Parser = struct {...@@ -579,7 +589,6 @@ const Parser = struct {
579 if (self.eatToken(.DoubleQuote)) |_| {589 if (self.eatToken(.DoubleQuote)) |_| {
580 node.start = node.start.? + 1;590 node.start = node.start.? + 1;
581 while (true) {591 while (true) {
582 const pos = self.token_it.pos;
583 const tok = self.token_it.next();592 const tok = self.token_it.next();
584 switch (tok.id) {593 switch (tok.id) {
585 .DoubleQuote => {594 .DoubleQuote => {
...@@ -594,7 +603,6 @@ const Parser = struct {...@@ -594,7 +603,6 @@ const Parser = struct {
594603
595 // TODO handle multiline strings in new block scope604 // TODO handle multiline strings in new block scope
596 while (true) {605 while (true) {
597 const pos = self.token_it.pos;
598 const tok = self.token_it.next();606 const tok = self.token_it.next();
599 switch (tok.id) {607 switch (tok.id) {
600 .Literal => {},608 .Literal => {},
src/link/tapi/yaml.zig-1
...@@ -175,7 +175,6 @@ pub const Value = union(ValueType) {...@@ -175,7 +175,6 @@ pub const Value = union(ValueType) {
175175
176 if (list.values.items.len > 0) {176 if (list.values.items.len > 0) {
177 const hint = if (list.values.items[0].cast(Node.Value)) |value| hint: {177 const hint = if (list.values.items[0].cast(Node.Value)) |value| hint: {
178 const elem = list.values.items[0];
179 const start = tree.tokens[value.start.?];178 const start = tree.tokens[value.start.?];
180 const end = tree.tokens[value.end.?];179 const end = tree.tokens[value.end.?];
181 const raw = tree.source[start.start..end.end];180 const raw = tree.source[start.start..end.end];