commit b0a25c424ad652c2e5f8270b85a4e4fd14450d15
parent 47184d96bec4d1321339c4b8732c217fe944dfd8
Author: Drew DeVault <sir@cmpwn.com>
Date: Sun, 24 Jan 2021 08:54:27 -0500
parse: fix match with pointer types
Diffstat:
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/parse.c b/src/parse.c
@@ -359,6 +359,9 @@ parse_primitive_type(struct lexer *lexer)
case T_VOID:
type->storage = TYPE_STORAGE_VOID;
break;
+ case T_NULL:
+ type->storage = TYPE_STORAGE_NULL;
+ break;
default:
assert(0);
}
@@ -570,6 +573,7 @@ parse_type(struct lexer *lexer)
case T_F64:
case T_BOOL:
case T_VOID:
+ case T_NULL:
unlex(lexer, &tok);
type = parse_primitive_type(lexer);
break;
@@ -1741,7 +1745,19 @@ parse_match_expression(struct lexer *lexer)
}
break;
case T_TIMES:
- // (default case)
+ switch (lex(lexer, &tok2)) {
+ case T_CASE: // Default case
+ unlex(lexer, &tok2);
+ break;
+ default:
+ unlex(lexer, &tok2);
+ _case->type = parse_type(lexer);
+ struct ast_type *ptr = mktype(&tok.loc);
+ ptr->storage = TYPE_STORAGE_POINTER;
+ ptr->pointer.referent = _case->type;
+ _case->type = ptr;
+ break;
+ }
break;
default:
unlex(lexer, &tok);