diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-01-01 16:18:50 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-01-01 16:18:50 +0000 |
| commit | 6fef74317cdd0e403fb913ebe965dc08b3dfb22d (patch) | |
| tree | 9f25deab9276dc60847c0548d1024cfdbc3679d4 /src/parser.c | |
| parent | 0c6775ca14ced37ac58a03ccad4028e225bda7d6 (diff) | |
Bring back `enum` but using iota
Diffstat (limited to 'src/parser.c')
| -rw-r--r-- | src/parser.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/parser.c b/src/parser.c index bfed77b0b..a7d9b4282 100644 --- a/src/parser.c +++ b/src/parser.c @@ -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); |