mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-11 22:01:25 -07:00
Bring back enum but using iota
This commit is contained in:
+13
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user