authorgravatar for kt@connectfree.co.jpkristopher tate <kt@connectfree.co.jp> 2018-07-29 17:11:43+09:00
committergravatar for kt@connectfree.co.jpkristopher tate <kt@connectfree.co.jp> 2018-08-02 16:59:11+09:00
logd3f628907a6b9e5b863c9d5235e6dadf57f42ca2
tree684f3e69c1f99e761998e80c33bf8c83ae59845f
parentb3cd65d56e2efc3e0f67461dbad75747b2db3aa7

src/parser.cpp: remove promise_symbol from suspend;

Tracking Issue #1296 ;

1 files changed, 16 insertions(+), 15 deletions(-)

src/parser.cpp+16-15
......@@ -648,35 +648,37 @@ static AstNode *ast_parse_asm_expr(ParseContext *pc, size_t *token_index, bool m
648648}
649649
650650/*
651SuspendExpression(body) = "suspend" option(("|" Symbol "|" body))
651SuspendExpression(body) = "suspend" option( body )
652652*/
653653static AstNode *ast_parse_suspend_block(ParseContext *pc, size_t *token_index, bool mandatory) {
654654 size_t orig_token_index = *token_index;
655 Token *token = &pc->tokens->at(*token_index);
656 Token *suspend_token = nullptr;
655657
656 Token *suspend_token = &pc->tokens->at(*token_index);
657658 if (suspend_token->id == TokenIdKeywordSuspend) {
658659 *token_index += 1;
660 suspend_token = token;
661 token = &pc->tokens->at(*token_index);
659662 } else if (mandatory) {
660 ast_expect_token(pc, suspend_token, TokenIdKeywordSuspend);
663 ast_expect_token(pc, token, TokenIdKeywordSuspend);
661664 zig_unreachable();
662665 } else {
663666 return nullptr;
664667 }
665668
666 Token *bar_token = &pc->tokens->at(*token_index);
667 if (bar_token->id == TokenIdBinOr) {
668 *token_index += 1;
669 } else if (mandatory) {
670 ast_expect_token(pc, suspend_token, TokenIdBinOr);
671 zig_unreachable();
672 } else {
673 *token_index = orig_token_index;
674 return nullptr;
669 //guessing that semicolon is checked elsewhere?
670 if (token->id != TokenIdLBrace) {
671 if (mandatory) {
672 ast_expect_token(pc, token, TokenIdLBrace);
673 zig_unreachable();
674 } else {
675 *token_index = orig_token_index;
676 return nullptr;
677 }
675678 }
676679
680 //Expect that we have a block;
677681 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);
680682 node->data.suspend.block = ast_parse_block(pc, token_index, true);
681683
682684 return node;
......@@ -3134,7 +3136,6 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont
31343136 visit_field(&node->data.await_expr.expr, visit, context);
31353137 break;
31363138 case NodeTypeSuspend:
3137 visit_field(&node->data.suspend.promise_symbol, visit, context);
31383139 visit_field(&node->data.suspend.block, visit, context);
31393140 break;
31403141 }