| ... | ... | @@ -302,13 +302,13 @@ static void ast_parse_param_decl_list(ParseContext *pc, size_t *token_index, |
| 302 | 302 | |
| 303 | 303 | ast_eat_token(pc, token_index, TokenIdLParen); |
| 304 | 304 | |
| 305 | | Token *token = &pc->tokens->at(*token_index); |
| 306 | | if (token->id == TokenIdRParen) { |
| 307 | | *token_index += 1; |
| 308 | | return; |
| 309 | | } |
| 310 | | |
| 311 | 305 | for (;;) { |
| 306 | Token *token = &pc->tokens->at(*token_index); |
| 307 | if (token->id == TokenIdRParen) { |
| 308 | *token_index += 1; |
| 309 | return; |
| 310 | } |
| 311 | |
| 312 | 312 | AstNode *param_decl_node = ast_parse_param_decl(pc, token_index); |
| 313 | 313 | bool expect_end = false; |
| 314 | 314 | assert(param_decl_node); |
| ... | ... | @@ -316,31 +316,33 @@ static void ast_parse_param_decl_list(ParseContext *pc, size_t *token_index, |
| 316 | 316 | expect_end = param_decl_node->data.param_decl.is_var_args; |
| 317 | 317 | *is_var_args = expect_end; |
| 318 | 318 | |
| 319 | | Token *token = &pc->tokens->at(*token_index); |
| 319 | token = &pc->tokens->at(*token_index); |
| 320 | 320 | *token_index += 1; |
| 321 | 321 | if (token->id == TokenIdRParen) { |
| 322 | 322 | return; |
| 323 | | } else if (expect_end) { |
| 324 | | ast_invalid_token_error(pc, token); |
| 325 | 323 | } else { |
| 326 | 324 | ast_expect_token(pc, token, TokenIdComma); |
| 325 | if (expect_end) { |
| 326 | ast_eat_token(pc, token_index, TokenIdRParen); |
| 327 | return; |
| 328 | } |
| 327 | 329 | } |
| 328 | 330 | } |
| 329 | 331 | zig_unreachable(); |
| 330 | 332 | } |
| 331 | 333 | |
| 332 | 334 | static void ast_parse_fn_call_param_list(ParseContext *pc, size_t *token_index, ZigList<AstNode*> *params) { |
| 333 | | Token *token = &pc->tokens->at(*token_index); |
| 334 | | if (token->id == TokenIdRParen) { |
| 335 | | *token_index += 1; |
| 336 | | return; |
| 337 | | } |
| 338 | | |
| 339 | 335 | for (;;) { |
| 336 | Token *token = &pc->tokens->at(*token_index); |
| 337 | if (token->id == TokenIdRParen) { |
| 338 | *token_index += 1; |
| 339 | return; |
| 340 | } |
| 341 | |
| 340 | 342 | AstNode *expr = ast_parse_expression(pc, token_index, true); |
| 341 | 343 | params->append(expr); |
| 342 | 344 | |
| 343 | | Token *token = &pc->tokens->at(*token_index); |
| 345 | token = &pc->tokens->at(*token_index); |
| 344 | 346 | *token_index += 1; |
| 345 | 347 | if (token->id == TokenIdRParen) { |
| 346 | 348 | return; |
| ... | ... | @@ -482,7 +484,13 @@ static void ast_parse_asm_clobbers(ParseContext *pc, size_t *token_index, AstNod |
| 482 | 484 | |
| 483 | 485 | if (comma->id == TokenIdComma) { |
| 484 | 486 | *token_index += 1; |
| 485 | | continue; |
| 487 | |
| 488 | Token *token = &pc->tokens->at(*token_index); |
| 489 | if (token->id == TokenIdRParen) { |
| 490 | break; |
| 491 | } else { |
| 492 | continue; |
| 493 | } |
| 486 | 494 | } else { |
| 487 | 495 | break; |
| 488 | 496 | } |
| ... | ... | @@ -513,7 +521,13 @@ static void ast_parse_asm_input(ParseContext *pc, size_t *token_index, AstNode * |
| 513 | 521 | |
| 514 | 522 | if (comma->id == TokenIdComma) { |
| 515 | 523 | *token_index += 1; |
| 516 | | continue; |
| 524 | |
| 525 | Token *token = &pc->tokens->at(*token_index); |
| 526 | if (token->id == TokenIdColon || token->id == TokenIdRParen) { |
| 527 | break; |
| 528 | } else { |
| 529 | continue; |
| 530 | } |
| 517 | 531 | } else { |
| 518 | 532 | break; |
| 519 | 533 | } |
| ... | ... | @@ -546,7 +560,13 @@ static void ast_parse_asm_output(ParseContext *pc, size_t *token_index, AstNode |
| 546 | 560 | |
| 547 | 561 | if (comma->id == TokenIdComma) { |
| 548 | 562 | *token_index += 1; |
| 549 | | continue; |
| 563 | |
| 564 | Token *token = &pc->tokens->at(*token_index); |
| 565 | if (token->id == TokenIdColon || token->id == TokenIdRParen) { |
| 566 | break; |
| 567 | } else { |
| 568 | continue; |
| 569 | } |
| 550 | 570 | } else { |
| 551 | 571 | break; |
| 552 | 572 | } |
| ... | ... | @@ -1783,7 +1803,13 @@ static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, boo |
| 1783 | 1803 | Token *comma_tok = &pc->tokens->at(*token_index); |
| 1784 | 1804 | if (comma_tok->id == TokenIdComma) { |
| 1785 | 1805 | *token_index += 1; |
| 1786 | | continue; |
| 1806 | |
| 1807 | Token *token = &pc->tokens->at(*token_index); |
| 1808 | if (token->id == TokenIdFatArrow) { |
| 1809 | break; |
| 1810 | } else { |
| 1811 | continue; |
| 1812 | } |
| 1787 | 1813 | } |
| 1788 | 1814 | break; |
| 1789 | 1815 | } |
| ... | ... | @@ -1812,7 +1838,15 @@ static AstNode *ast_parse_switch_expr(ParseContext *pc, size_t *token_index, boo |
| 1812 | 1838 | } |
| 1813 | 1839 | |
| 1814 | 1840 | prong_node->data.switch_prong.expr = ast_parse_expression(pc, token_index, true); |
| 1815 | | ast_eat_token(pc, token_index, TokenIdComma); |
| 1841 | |
| 1842 | Token *trailing_token = &pc->tokens->at(*token_index); |
| 1843 | if (trailing_token->id == TokenIdRBrace) { |
| 1844 | *token_index += 1; |
| 1845 | |
| 1846 | return node; |
| 1847 | } else { |
| 1848 | ast_eat_token(pc, token_index, TokenIdComma); |
| 1849 | } |
| 1816 | 1850 | |
| 1817 | 1851 | } |
| 1818 | 1852 | } |
| ... | ... | @@ -2364,17 +2398,28 @@ static AstNode *ast_parse_container_decl(ParseContext *pc, size_t *token_index, |
| 2364 | 2398 | field_node->data.struct_field.visib_mod = visib_mod; |
| 2365 | 2399 | field_node->data.struct_field.name = token_buf(token); |
| 2366 | 2400 | |
| 2367 | | Token *expr_or_comma = &pc->tokens->at(*token_index); |
| 2368 | | if (expr_or_comma->id == TokenIdComma) { |
| 2369 | | field_node->data.struct_field.type = ast_create_void_type_node(pc, expr_or_comma); |
| 2401 | Token *token = &pc->tokens->at(*token_index); |
| 2402 | if (token->id == TokenIdComma || token->id == TokenIdRBrace) { |
| 2403 | field_node->data.struct_field.type = ast_create_void_type_node(pc, token); |
| 2370 | 2404 | *token_index += 1; |
| 2405 | node->data.container_decl.fields.append(field_node); |
| 2406 | |
| 2407 | if (token->id == TokenIdRBrace) { |
| 2408 | break; |
| 2409 | } |
| 2371 | 2410 | } else { |
| 2372 | 2411 | ast_eat_token(pc, token_index, TokenIdColon); |
| 2373 | 2412 | field_node->data.struct_field.type = ast_parse_expression(pc, token_index, true); |
| 2374 | | ast_eat_token(pc, token_index, TokenIdComma); |
| 2375 | | } |
| 2413 | node->data.container_decl.fields.append(field_node); |
| 2376 | 2414 | |
| 2377 | | node->data.container_decl.fields.append(field_node); |
| 2415 | Token *token = &pc->tokens->at(*token_index); |
| 2416 | if (token->id == TokenIdRBrace) { |
| 2417 | *token_index += 1; |
| 2418 | break; |
| 2419 | } else { |
| 2420 | ast_eat_token(pc, token_index, TokenIdComma); |
| 2421 | } |
| 2422 | } |
| 2378 | 2423 | } else { |
| 2379 | 2424 | ast_invalid_token_error(pc, token); |
| 2380 | 2425 | } |