authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2019-09-25 18:15:50+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-09-25 12:44:11-04:00
log29e6541db1ad79656a3a7743de65bd452ea64bce
tree58c54e757cbff429a3663fb73654d45396ed2db7
parent3907e3b675daaa9869732aca6851bd2e0000000a

add noasync to zig fmt


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

std/zig/parse.zig+8-5
......@@ -1096,16 +1096,19 @@ fn parseErrorUnionExpr(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*No
10961096
10971097/// SuffixExpr
10981098/// <- KEYWORD_async PrimaryTypeExpr SuffixOp* FnCallArguments
1099/// / KEYWORD_noasync PrimaryTypeExpr SuffixOp* FnCallArguments
10991100/// / PrimaryTypeExpr (SuffixOp / FnCallArguments)*
11001101fn parseSuffixExpr(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
1101 if (eatToken(it, .Keyword_async)) |async_token| {
1102 if (eatToken(it, .Keyword_fn)) |token_fn| {
1102 var maybe_async = eatAnnotatedToken(it, .Keyword_async) orelse eatAnnotatedToken(it, .Keyword_noasync);
1103 if (maybe_async) |async_token| {
1104 const token_fn = eatToken(it, .Keyword_fn);
1105 if (async_token.ptr.id == .Keyword_async and token_fn != null) {
11031106 // HACK: If we see the keyword `fn`, then we assume that
11041107 // we are parsing an async fn proto, and not a call.
11051108 // We therefore put back all tokens consumed by the async
11061109 // prefix...
1107 putBackToken(it, token_fn);
1108 putBackToken(it, async_token);
1110 putBackToken(it, token_fn.?);
1111 putBackToken(it, async_token.index);
11091112 return parsePrimaryTypeExpr(arena, it, tree);
11101113 }
11111114 // TODO: Implement hack for parsing `async fn ...` in ast_parse_suffix_expr
......@@ -1135,7 +1138,7 @@ fn parseSuffixExpr(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
11351138 .op = Node.SuffixOp.Op{
11361139 .Call = Node.SuffixOp.Op.Call{
11371140 .params = params.list,
1138 .async_token = async_token,
1141 .async_token = async_token.index,
11391142 },
11401143 },
11411144 .rtoken = params.rparen,
std/zig/parser_test.zig+7
......@@ -2266,6 +2266,13 @@ test "zig fmt: async functions" {
22662266 );
22672267}
22682268
2269test "zig fmt: noasync" {
2270 try testCanonical(
2271 \\const a = noasync foo();
2272 \\
2273 );
2274}
2275
22692276test "zig fmt: Block after if" {
22702277 try testCanonical(
22712278 \\test "Block after if" {