authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-05-20 14:50:27-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-05-20 14:50:27-04:00
logbfbe26734d4167977fff0d675ff55c68d75dd3be
tree00e70f00e79175702b28b6896cf436af01c00a26
parent83a78094788038fcf487e5947945a1f5900d564a

zig fmt: add pointer deref syntax


2 files changed, 18 insertions(+), 0 deletions(-)

std/zig/parse.zig+11
......@@ -2195,6 +2195,17 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
21952195 continue;
21962196 },
21972197 Token.Id.Period => {
2198 if (eatToken(&tok_it, &tree, Token.Id.Asterisk)) |asterisk_token| {
2199 const node = try arena.construct(ast.Node.SuffixOp{
2200 .base = ast.Node{ .id = ast.Node.Id.SuffixOp },
2201 .lhs = lhs,
2202 .op = ast.Node.SuffixOp.Op.Deref,
2203 .rtoken = asterisk_token,
2204 });
2205 opt_ctx.store(&node.base);
2206 stack.append(State{ .SuffixOpExpressionEnd = opt_ctx.toRequired() }) catch unreachable;
2207 continue;
2208 }
21982209 const node = try arena.construct(ast.Node.InfixOp{
21992210 .base = ast.Node{ .id = ast.Node.Id.InfixOp },
22002211 .lhs = lhs,
std/zig/parser_test.zig+7
......@@ -1,3 +1,10 @@
1test "zig fmt: ptr deref operator" {
2 try testCanonical(
3 \\const a = b.*;
4 \\
5 );
6}
7
18test "zig fmt: comment after if before another if" {
29 try testCanonical(
310 \\test "aoeu" {