summaryrefslogtreecommitdiff
path: root/compiler/parser
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/parser')
-rw-r--r--compiler/parser/type.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/compiler/parser/type.c b/compiler/parser/type.c
index 4b961f0..b86ba9c 100644
--- a/compiler/parser/type.c
+++ b/compiler/parser/type.c
@@ -261,17 +261,20 @@ parse_type(struct parser *ctx)
return;
}
- next_token(ctx);
- if (ctx->tok.kind == TK_IDENTIFIER) {
+ switch (next_token(ctx)->kind) {
+ case TK_IDENTIFIER:
success = parse_alias(ctx, typ);
- } else if (ctx->tok.kind == TK_ENUM) {
+ break;
+ case TK_ENUM:
success = parse_enum(ctx, typ);
- } else if (ctx->tok.kind == TK_STRUCT) {
+ break;
+ case TK_STRUCT:
success = parse_struct(ctx, typ);
- } else {
- tok_error(&ctx->tok, "expected type name or \"enum\" after \":\"\n");
- free(typ);
- return;
+ break;
+ default:
+ tok_error(&ctx->tok, "expected identifier, \"enum\", or \"struct\" after \":\"\n");
+ success = false;
+ break;
}
if (!success) {