From 3868a9a0f00185b6f8f587f67a62cbd12a215336 Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Mon, 10 Jul 2017 23:15:41 +0100 Subject: Clean up _preload.odin types --- src/parser.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index ef4c9809b..8a55a31ea 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -4134,20 +4134,29 @@ AstNode *parse_match_stmt(AstFile *f) { if (f->curr_token.kind != Token_OpenBrace) { isize prev_level = f->expr_level; f->expr_level = -1; + defer (f->expr_level = prev_level); + + if (allow_token(f, Token_in)) { + Array lhs = {}; + Array rhs = make_ast_node_array(f, 1); + array_add(&rhs, parse_expr(f, false)); - tag = parse_simple_stmt(f, StmtAllowFlag_In); - if (tag->kind == AstNode_AssignStmt && tag->AssignStmt.op.kind == Token_in) { + tag = ast_assign_stmt(f, token, lhs, rhs); is_type_match = true; } else { - if (allow_token(f, Token_Semicolon)) { - init = tag; - tag = nullptr; - if (f->curr_token.kind != Token_OpenBrace) { - tag = parse_simple_stmt(f, StmtAllowFlag_None); + tag = parse_simple_stmt(f, StmtAllowFlag_In); + if (tag->kind == AstNode_AssignStmt && tag->AssignStmt.op.kind == Token_in) { + is_type_match = true; + } else { + if (allow_token(f, Token_Semicolon)) { + init = tag; + tag = nullptr; + if (f->curr_token.kind != Token_OpenBrace) { + tag = parse_simple_stmt(f, StmtAllowFlag_None); + } } } } - f->expr_level = prev_level; } open = expect_token(f, Token_OpenBrace); -- cgit v1.2.3