From 2ca159fb5c2a52f33c499eef1fa50a98a863b0f0 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Mon, 3 Apr 2023 16:00:34 +0300 Subject: initial union testing --- src/parser.y | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/parser.y') diff --git a/src/parser.y b/src/parser.y index 329e072..64f9ef1 100644 --- a/src/parser.y +++ b/src/parser.y @@ -448,7 +448,7 @@ type: id { $$ = gen_type(AST_TYPE_ID, $1, NULL, NULL); } $$->_type.next = $2; } | id "(" type_list ")" { - $$ = gen_type(AST_TYPE_STRUCT, $1, $3, NULL); + $$ = gen_type(AST_TYPE_GENERIC, $1, $3, NULL); } | "'" type { $$ = gen_type(AST_TYPE_POINTER, NULL, NULL, NULL); @@ -596,6 +596,7 @@ top: ";" { $$ = gen_empty(); } | enum { $$ = $1; } | proc { $$ = $1; } | struct { $$ = $1; } + | union { $$ = $1; } | macro { $$ = $1; } | "const" top_if { $$ = $2; ast_set_flags($$, AST_FLAG_CONST); } | import ";" { $$ = $1; } @@ -603,6 +604,7 @@ top: ";" { $$ = gen_empty(); } | type_template { $$ = $1; } | "pub" enum { $$ = $2; ast_set_flags($2, AST_FLAG_PUBLIC); } | "pub" struct { $$ = $2; ast_set_flags($2, AST_FLAG_PUBLIC); } + | "pub" union { $$ = $2; ast_set_flags($2, AST_FLAG_PUBLIC); } | "pub" proc { $$ = $2; ast_set_flags($2, AST_FLAG_PUBLIC); } | "pub" macro { $$ = $2; ast_set_flags($2, AST_FLAG_PUBLIC); } | "pub" import ";" { $$ = $2; ast_set_flags($2, AST_FLAG_PUBLIC); } -- cgit v1.3