Bring back enum but using iota

This commit is contained in:
Ginger Bill
2017-01-01 16:18:50 +00:00
parent 0c6775ca14
commit 6fef74317c
13 changed files with 315 additions and 47 deletions
+13 -1
View File
@@ -347,7 +347,7 @@ AST_NODE_KIND(_TypeBegin, "", i32) \
AST_NODE_KIND(EnumType, "enum type", struct { \
Token token; \
AstNode *base_type; \
AstNodeArray fields; \
AstNodeArray fields; /* FieldValue */ \
}) \
AST_NODE_KIND(_TypeEnd, "", i32)
@@ -2548,6 +2548,18 @@ AstNode *parse_identifier_or_type(AstFile *f) {
return make_raw_union_type(f, token, decls, decl_count);
}
case Token_enum: {
Token token = expect_token(f, Token_enum);
AstNode *base_type = NULL;
if (f->curr_token.kind != Token_OpenBrace) {
base_type = parse_type(f);
}
Token open = expect_token(f, Token_OpenBrace);
AstNodeArray fields = parse_element_list(f);
Token close = expect_token(f, Token_CloseBrace);
return make_enum_type(f, token, base_type, fields);
}
case Token_proc: {
Token token = f->curr_token;
AstNode *pt = parse_proc_type(f, NULL, NULL);