| ... | @@ -648,35 +648,37 @@ static AstNode *ast_parse_asm_expr(ParseContext *pc, size_t *token_index, bool m | ... | @@ -648,35 +648,37 @@ static AstNode *ast_parse_asm_expr(ParseContext *pc, size_t *token_index, bool m |
| 648 | } | 648 | } |
| 649 | | 649 | |
| 650 | /* | 650 | /* |
| 651 | SuspendExpression(body) = "suspend" option(("|" Symbol "|" body)) | 651 | SuspendExpression(body) = "suspend" option( body ) |
| 652 | */ | 652 | */ |
| 653 | static AstNode *ast_parse_suspend_block(ParseContext *pc, size_t *token_index, bool mandatory) { | 653 | static AstNode *ast_parse_suspend_block(ParseContext *pc, size_t *token_index, bool mandatory) { |
| 654 | size_t orig_token_index = *token_index; | 654 | size_t orig_token_index = *token_index; |
| | 655 | Token *token = &pc->tokens->at(*token_index); |
| | 656 | Token *suspend_token = nullptr; |
| 655 | | 657 | |
| 656 | Token *suspend_token = &pc->tokens->at(*token_index); | | |
| 657 | if (suspend_token->id == TokenIdKeywordSuspend) { | 658 | if (suspend_token->id == TokenIdKeywordSuspend) { |
| 658 | *token_index += 1; | 659 | *token_index += 1; |
| | 660 | suspend_token = token; |
| | 661 | token = &pc->tokens->at(*token_index); |
| 659 | } else if (mandatory) { | 662 | } else if (mandatory) { |
| 660 | ast_expect_token(pc, suspend_token, TokenIdKeywordSuspend); | 663 | ast_expect_token(pc, token, TokenIdKeywordSuspend); |
| 661 | zig_unreachable(); | 664 | zig_unreachable(); |
| 662 | } else { | 665 | } else { |
| 663 | return nullptr; | 666 | return nullptr; |
| 664 | } | 667 | } |
| 665 | | 668 | |
| 666 | Token *bar_token = &pc->tokens->at(*token_index); | 669 | //guessing that semicolon is checked elsewhere? |
| 667 | if (bar_token->id == TokenIdBinOr) { | 670 | if (token->id != TokenIdLBrace) { |
| 668 | *token_index += 1; | 671 | if (mandatory) { |
| 669 | } else if (mandatory) { | 672 | ast_expect_token(pc, token, TokenIdLBrace); |
| 670 | ast_expect_token(pc, suspend_token, TokenIdBinOr); | 673 | zig_unreachable(); |
| 671 | zig_unreachable(); | 674 | } else { |
| 672 | } else { | 675 | *token_index = orig_token_index; |
| 673 | *token_index = orig_token_index; | 676 | return nullptr; |
| 674 | return nullptr; | 677 | } |
| 675 | } | 678 | } |
| 676 | | 679 | |
| | 680 | //Expect that we have a block; |
| 677 | AstNode *node = ast_create_node(pc, NodeTypeSuspend, suspend_token); | 681 | AstNode *node = ast_create_node(pc, NodeTypeSuspend, suspend_token); |
| 678 | node->data.suspend.promise_symbol = ast_parse_symbol(pc, token_index); | | |
| 679 | ast_eat_token(pc, token_index, TokenIdBinOr); | | |
| 680 | node->data.suspend.block = ast_parse_block(pc, token_index, true); | 682 | node->data.suspend.block = ast_parse_block(pc, token_index, true); |
| 681 | | 683 | |
| 682 | return node; | 684 | return node; |
| ... | @@ -3134,7 +3136,6 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont | ... | @@ -3134,7 +3136,6 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont |
| 3134 | visit_field(&node->data.await_expr.expr, visit, context); | 3136 | visit_field(&node->data.await_expr.expr, visit, context); |
| 3135 | break; | 3137 | break; |
| 3136 | case NodeTypeSuspend: | 3138 | case NodeTypeSuspend: |
| 3137 | visit_field(&node->data.suspend.promise_symbol, visit, context); | | |
| 3138 | visit_field(&node->data.suspend.block, visit, context); | 3139 | visit_field(&node->data.suspend.block, visit, context); |
| 3139 | break; | 3140 | break; |
| 3140 | } | 3141 | } |