diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -579,20 +579,22 @@ parse_keyword(Parser *parser) { | |||
579 | if (!node) return; | 579 | if (!node) return; |
580 | parse_expr(parser, PREC_LOW); | 580 | parse_expr(parser, PREC_LOW); |
581 | node->match_expr = array_pop(parser->nodes); | 581 | node->match_expr = array_pop(parser->nodes); |
582 | parse_consume(parser, TOK_ASSIGN, | ||
583 | cstr("malformed match statement")); | ||
582 | parse_consume(parser, TOK_LCURLY, | 584 | parse_consume(parser, TOK_LCURLY, |
583 | cstr("expected block of match cases")); | 585 | cstr("expected block of match cases")); |
584 | while (!parse_match(parser, TOK_RCURLY) && !parser->panic) { | 586 | while (!parse_match(parser, TOK_RCURLY) && !parser->panic) { |
585 | parse_consume(parser, TOK_CASE, | ||
586 | cstr("expected case statement")); | ||
587 | Node *tmp = node_alloc(parser, NODE_CASE, parser->previous); | 587 | Node *tmp = node_alloc(parser, NODE_CASE, parser->previous); |
588 | if (!tmp) return; | 588 | if (!tmp) return; |
589 | // Are we on the default case. | 589 | // Are we on the default case. |
590 | if (!parse_match(parser, TOK_ASSIGN)) { | 590 | if (!parse_match(parser, TOK_ELSE)) { |
591 | parse_consume(parser, TOK_CASE, | ||
592 | cstr("expected case statement")); | ||
591 | parse_expr(parser, PREC_LOW); | 593 | parse_expr(parser, PREC_LOW); |
592 | tmp->case_value = array_pop(parser->nodes); | 594 | tmp->case_value = array_pop(parser->nodes); |
593 | parse_consume(parser, TOK_ASSIGN, | ||
594 | cstr("malformed case statement")); | ||
595 | } | 595 | } |
596 | parse_consume(parser, TOK_ASSIGN, | ||
597 | cstr("malformed case statement")); | ||
596 | parse_expr(parser, PREC_LOW); | 598 | parse_expr(parser, PREC_LOW); |
597 | tmp->case_expr = array_pop(parser->nodes); | 599 | tmp->case_expr = array_pop(parser->nodes); |
598 | array_push(node->match_cases, tmp, parser->storage); | 600 | array_push(node->match_cases, tmp, parser->storage); |