diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-07-30 13:42:26 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-30 13:42:26 -0400 |
| commit | 5d4a02c350a18a70cf1f92f6638b5d26689c16b4 (patch) | |
| tree | 30c9da2e8dc9a0aaef2ac59c9694291ec0f5c9ab /src/parser.cpp | |
| parent | 608ff52dc3ea356b23fb6ae92fbca9fbb18c7892 (diff) | |
| parent | cfe03c764de0d2edfbad74a71d7c18f0fd68b506 (diff) | |
| download | zig-5d4a02c350a18a70cf1f92f6638b5d26689c16b4.tar.gz zig-5d4a02c350a18a70cf1f92f6638b5d26689c16b4.zip | |
Merge pull request #1307 from ziglang/cancel-semantics
improved coroutine cancel semantics
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 25 |
1 files changed, 2 insertions, 23 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index adb1633f5d..a93d8de830 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -648,30 +648,12 @@ static AstNode *ast_parse_asm_expr(ParseContext *pc, size_t *token_index, bool m } /* -SuspendExpression(body) = option(Symbol ":") "suspend" option(("|" Symbol "|" body)) +SuspendExpression(body) = "suspend" option(("|" Symbol "|" body)) */ static AstNode *ast_parse_suspend_block(ParseContext *pc, size_t *token_index, bool mandatory) { size_t orig_token_index = *token_index; - Token *name_token = nullptr; - Token *token = &pc->tokens->at(*token_index); - if (token->id == TokenIdSymbol) { - *token_index += 1; - Token *colon_token = &pc->tokens->at(*token_index); - if (colon_token->id == TokenIdColon) { - *token_index += 1; - name_token = token; - token = &pc->tokens->at(*token_index); - } else if (mandatory) { - ast_expect_token(pc, colon_token, TokenIdColon); - zig_unreachable(); - } else { - *token_index = orig_token_index; - return nullptr; - } - } - - Token *suspend_token = token; + Token *suspend_token = &pc->tokens->at(*token_index); if (suspend_token->id == TokenIdKeywordSuspend) { *token_index += 1; } else if (mandatory) { @@ -693,9 +675,6 @@ static AstNode *ast_parse_suspend_block(ParseContext *pc, size_t *token_index, b } AstNode *node = ast_create_node(pc, NodeTypeSuspend, suspend_token); - if (name_token != nullptr) { - node->data.suspend.name = token_buf(name_token); - } node->data.suspend.promise_symbol = ast_parse_symbol(pc, token_index); ast_eat_token(pc, token_index, TokenIdBinOr); node->data.suspend.block = ast_parse_block(pc, token_index, true); |
