mirror of
https://github.com/ziglang/zig.git
synced 2026-02-04 05:33:39 +00:00
zig fmt: add pointer deref syntax
This commit is contained in:
parent
83a7809478
commit
bfbe26734d
@ -2195,6 +2195,17 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree {
|
||||
continue;
|
||||
},
|
||||
Token.Id.Period => {
|
||||
if (eatToken(&tok_it, &tree, Token.Id.Asterisk)) |asterisk_token| {
|
||||
const node = try arena.construct(ast.Node.SuffixOp{
|
||||
.base = ast.Node{ .id = ast.Node.Id.SuffixOp },
|
||||
.lhs = lhs,
|
||||
.op = ast.Node.SuffixOp.Op.Deref,
|
||||
.rtoken = asterisk_token,
|
||||
});
|
||||
opt_ctx.store(&node.base);
|
||||
stack.append(State{ .SuffixOpExpressionEnd = opt_ctx.toRequired() }) catch unreachable;
|
||||
continue;
|
||||
}
|
||||
const node = try arena.construct(ast.Node.InfixOp{
|
||||
.base = ast.Node{ .id = ast.Node.Id.InfixOp },
|
||||
.lhs = lhs,
|
||||
|
||||
@ -1,3 +1,10 @@
|
||||
test "zig fmt: ptr deref operator" {
|
||||
try testCanonical(
|
||||
\\const a = b.*;
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: comment after if before another if" {
|
||||
try testCanonical(
|
||||
\\test "aoeu" {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user