diff options
| author | 2022-08-08 12:09:36 +0200 | |
|---|---|---|
| committer | 2022-08-08 12:09:50 +0200 | |
| commit | dd29ff7e1ea2528c83fdfeda070ea7398eaae8ce (patch) | |
| tree | 68d741528f2a8eb9c34351186f4867cee9f3cfd4 /bootstrap | |
| parent | 51c55c2bda86105419f62d16396c2adfc4a0616b (diff) | |
anon union/struct
Diffstat (limited to 'bootstrap')
| -rw-r--r-- | bootstrap/parse.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/bootstrap/parse.c b/bootstrap/parse.c index 427f0f2..ebfd7d7 100644 --- a/bootstrap/parse.c +++ b/bootstrap/parse.c @@ -621,6 +621,7 @@ exprdup(struct expr ex) { } static const struct type *parseagg(struct parser *P, const char *name, int kind, struct decl **retdecl); +static const struct type *parseenum(struct parser *P, const char *name); static const struct type * parseexpandtepl(struct parser *P, struct tepl *tepl) { @@ -755,6 +756,14 @@ parsetype(struct parser *P) { }); } else if (lexmatch(P, &tok, TKkw_const)) { return constify(parsetype(P)); + } else if (lexmatch(P, &tok, TKkw_struct)) { + struct decl *_decl; + return parseagg(P, NULL, TYstruct, &_decl); + } else if (lexmatch(P, &tok, TKkw_union)) { + struct decl *_decl; + return parseagg(P, NULL, TYunion, &_decl); + } else if (lexmatch(P, &tok, TKkw_enum)) { + return parseenum(P, NULL); } else if (lexmatch(P, &tok, TKkw_typeof)) { const struct type *ty = NULL, *ty2, *ty0; lexexpect(P, '('); @@ -2631,10 +2640,14 @@ parseagg(struct parser *P, const char *name, int kind, struct decl **retdecl) { else iid = id++; pty = interntype((struct type) { - kind, .agg.name = name, .agg.id = iid + kind, .agg.name = name, .agg.id = iid }); *retdecl = decl = putdecl(P, P->tokspan, &(struct decl) { Dtype, name, .span = P->tokspan, .ty = pty }); + } else { + pty = interntype((struct type) { + kind, .agg.name = name, .agg.id = id++ + }); } tok = lexexpect(P, '{'); while (!lexmatch(P, &tok, '}')) { |