aboutsummaryrefslogtreecommitdiff
path: root/src/parser.c
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-03-19 20:55:39 +0000
committerGinger Bill <bill@gingerbill.org>2017-03-19 20:55:39 +0000
commitc26990c22daf6d2e09948b38366f457496f16cfe (patch)
treeec7ffec4193ffb90fe4e18b3b2bcc41eec537770 /src/parser.c
parentc34d839f9ffd110762270f071d7abbefaa41bc20 (diff)
Multiple type cases for `match in`
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/parser.c b/src/parser.c
index 9fab3725e..a41fc5c06 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -2162,7 +2162,7 @@ AstNode *parse_expr(AstFile *f, bool lhs) {
AstNodeArray parse_expr_list(AstFile *f, bool lhs) {
AstNodeArray list = make_ast_node_array(f);
- do {
+ for (;;) {
AstNode *e = parse_expr(f, lhs);
array_add(&list, e);
if (f->curr_token.kind != Token_Comma ||
@@ -2170,7 +2170,7 @@ AstNodeArray parse_expr_list(AstFile *f, bool lhs) {
break;
}
next_token(f);
- } while (true);
+ }
return list;
}
@@ -3099,9 +3099,17 @@ AstNode *parse_case_clause(AstFile *f) {
AstNode *parse_type_case_clause(AstFile *f) {
Token token = f->curr_token;
- AstNodeArray clause = make_ast_node_array(f);
+ AstNodeArray list = make_ast_node_array(f);
if (allow_token(f, Token_case)) {
- array_add(&clause, parse_type(f));
+ for (;;) {
+ AstNode *t = parse_type(f);
+ array_add(&list, t);
+ if (f->curr_token.kind != Token_Comma ||
+ f->curr_token.kind == Token_EOF) {
+ break;
+ }
+ next_token(f);
+ }
} else {
expect_token(f, Token_default);
}
@@ -3109,7 +3117,7 @@ AstNode *parse_type_case_clause(AstFile *f) {
// expect_token(f, Token_ArrowRight); // TODO(bill): Is this the best syntax?
AstNodeArray stmts = parse_stmt_list(f);
- return ast_case_clause(f, token, clause, stmts);
+ return ast_case_clause(f, token, list, stmts);
}