aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorkristopher tate <kt@connectfree.co.jp>2018-07-29 17:11:43 +0900
committerkristopher tate <kt@connectfree.co.jp>2018-08-02 16:59:11 +0900
commitd3f628907a6b9e5b863c9d5235e6dadf57f42ca2 (patch)
tree684f3e69c1f99e761998e80c33bf8c83ae59845f /src/parser.cpp
parentb3cd65d56e2efc3e0f67461dbad75747b2db3aa7 (diff)
downloadzig-d3f628907a6b9e5b863c9d5235e6dadf57f42ca2.tar.gz
zig-d3f628907a6b9e5b863c9d5235e6dadf57f42ca2.zip
src/parser.cpp: remove promise_symbol from suspend;
Tracking Issue #1296 ;
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index a93d8de830..e2a818a56c 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -648,35 +648,37 @@ static AstNode *ast_parse_asm_expr(ParseContext *pc, size_t *token_index, bool m
}
/*
-SuspendExpression(body) = "suspend" option(("|" Symbol "|" body))
+SuspendExpression(body) = "suspend" option( body )
*/
static AstNode *ast_parse_suspend_block(ParseContext *pc, size_t *token_index, bool mandatory) {
size_t orig_token_index = *token_index;
+ Token *token = &pc->tokens->at(*token_index);
+ Token *suspend_token = nullptr;
- Token *suspend_token = &pc->tokens->at(*token_index);
if (suspend_token->id == TokenIdKeywordSuspend) {
*token_index += 1;
+ suspend_token = token;
+ token = &pc->tokens->at(*token_index);
} else if (mandatory) {
- ast_expect_token(pc, suspend_token, TokenIdKeywordSuspend);
+ ast_expect_token(pc, token, TokenIdKeywordSuspend);
zig_unreachable();
} else {
return nullptr;
}
- Token *bar_token = &pc->tokens->at(*token_index);
- if (bar_token->id == TokenIdBinOr) {
- *token_index += 1;
- } else if (mandatory) {
- ast_expect_token(pc, suspend_token, TokenIdBinOr);
- zig_unreachable();
- } else {
- *token_index = orig_token_index;
- return nullptr;
+ //guessing that semicolon is checked elsewhere?
+ if (token->id != TokenIdLBrace) {
+ if (mandatory) {
+ ast_expect_token(pc, token, TokenIdLBrace);
+ zig_unreachable();
+ } else {
+ *token_index = orig_token_index;
+ return nullptr;
+ }
}
+ //Expect that we have a block;
AstNode *node = ast_create_node(pc, NodeTypeSuspend, suspend_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);
return node;
@@ -3134,7 +3136,6 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont
visit_field(&node->data.await_expr.expr, visit, context);
break;
case NodeTypeSuspend:
- visit_field(&node->data.suspend.promise_symbol, visit, context);
visit_field(&node->data.suspend.block, visit, context);
break;
}