Parsing union

This commit is contained in:
Krzosa Karol
2023-03-29 09:34:33 +02:00
parent fa26e9d218
commit b572f4ef7c
4 changed files with 18 additions and 10 deletions

View File

@@ -692,7 +692,7 @@ parse_assign_expr() {
}
CORE_Static Ast_Decl *
parse_struct(Token *pos) {
parse_struct(Token *pos, Ast_Kind kind) {
Scratch_Scope scratch(pctx->scratch);
token_match(OPEN_SCOPE);
@@ -711,7 +711,7 @@ parse_struct(Token *pos) {
token_expect(CLOSE_SCOPE);
finalize_decl_scope(scope);
Ast_Decl *result = ast_struct(pos, scope);
Ast_Decl *result = ast_struct(pos, scope, kind);
return result;
}
@@ -853,9 +853,12 @@ parse_decl(B32 is_global) {
set_flag(flags, AST_STRICT);
}
// @note parse struct binding
if (token_match_keyword(pctx->keyword_struct)) {
result = parse_struct(tname);
result = parse_struct(tname, AST_STRUCT);
}
else if (token_match_keyword(pctx->keyword_union)) {
result = parse_struct(tname, AST_UNION);
}
else if (token_match_keyword(pctx->keyword_enum)) {