| ... | ... | @@ -1517,8 +1517,15 @@ pub const Parser = struct { |
| 1517 | 1517 | continue; |
| 1518 | 1518 | } |
| 1519 | 1519 | |
| 1520 | | stack.append(State { .IdentifierListCommaOrEnd = list_state }) catch unreachable; |
| 1521 | | try stack.append(State { .Identifier = OptionalCtx { .Required = try list_state.list.addOne() } }); |
| 1520 | const comments = try self.eatComments(arena); |
| 1521 | const node_ptr = try list_state.list.addOne(); |
| 1522 | |
| 1523 | try stack.append(State { .AddComments = AddCommentsCtx { |
| 1524 | .node_ptr = node_ptr, |
| 1525 | .comments = comments, |
| 1526 | }}); |
| 1527 | try stack.append(State { .IdentifierListCommaOrEnd = list_state }); |
| 1528 | try stack.append(State { .Identifier = OptionalCtx { .Required = node_ptr } }); |
| 1522 | 1529 | continue; |
| 1523 | 1530 | }, |
| 1524 | 1531 | State.IdentifierListCommaOrEnd => |list_state| { |
| ... | ... | @@ -2739,14 +2746,17 @@ pub const Parser = struct { |
| 2739 | 2746 | continue; |
| 2740 | 2747 | } |
| 2741 | 2748 | |
| 2742 | | const node = try self.createToCtxNode(arena, ctx.opt_ctx, ast.Node.ErrorSetDecl, |
| 2743 | | ast.Node.ErrorSetDecl { |
| 2744 | | .base = undefined, |
| 2745 | | .error_token = ctx.error_token, |
| 2746 | | .decls = ArrayList(&ast.Node).init(arena), |
| 2747 | | .rbrace_token = undefined, |
| 2748 | | } |
| 2749 | | ); |
| 2749 | const node = try arena.construct(ast.Node.ErrorSetDecl { |
| 2750 | .base = ast.Node { |
| 2751 | .id = ast.Node.Id.ErrorSetDecl, |
| 2752 | .before_comments = null, |
| 2753 | .same_line_comment = null, |
| 2754 | }, |
| 2755 | .error_token = ctx.error_token, |
| 2756 | .decls = ArrayList(&ast.Node).init(arena), |
| 2757 | .rbrace_token = undefined, |
| 2758 | }); |
| 2759 | ctx.opt_ctx.store(&node.base); |
| 2750 | 2760 | |
| 2751 | 2761 | stack.append(State { |
| 2752 | 2762 | .IdentifierListItemOrEnd = ListSave(&ast.Node) { |
| ... | ... | @@ -3337,6 +3347,7 @@ pub const Parser = struct { |
| 3337 | 3347 | PrintIndent, |
| 3338 | 3348 | Indent: usize, |
| 3339 | 3349 | PrintSameLineComment: ?&Token, |
| 3350 | PrintComments: &ast.Node, |
| 3340 | 3351 | }; |
| 3341 | 3352 | |
| 3342 | 3353 | pub fn renderSource(self: &Parser, stream: var, root_node: &ast.Node.Root) !void { |
| ... | ... | @@ -3978,6 +3989,7 @@ pub const Parser = struct { |
| 3978 | 3989 | const node = decls[i]; |
| 3979 | 3990 | try stack.append(RenderState { .Text = "," }); |
| 3980 | 3991 | try stack.append(RenderState { .Expression = node }); |
| 3992 | try stack.append(RenderState { .PrintComments = node }); |
| 3981 | 3993 | try stack.append(RenderState.PrintIndent); |
| 3982 | 3994 | try stack.append(RenderState { |
| 3983 | 3995 | .Text = blk: { |
| ... | ... | @@ -4466,6 +4478,10 @@ pub const Parser = struct { |
| 4466 | 4478 | const comment_token = maybe_comment ?? break :blk; |
| 4467 | 4479 | try stream.print(" {}", self.tokenizer.getTokenSlice(comment_token)); |
| 4468 | 4480 | }, |
| 4481 | |
| 4482 | RenderState.PrintComments => |node| blk: { |
| 4483 | try self.renderComments(stream, node, indent); |
| 4484 | }, |
| 4469 | 4485 | } |
| 4470 | 4486 | } |
| 4471 | 4487 | } |