aboutsummaryrefslogtreecommitdiff
path: root/src/parser.y
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-08-11 23:23:12 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-08-11 23:23:12 +0300
commitd23d03829e5baf947d347f49cc1d7807be6c070b (patch)
treef611d1105868f1d253cf15070b55793ed694861b /src/parser.y
parent3065334aec0f357c88eab144628a798db4a3e5ea (diff)
downloadek-d23d03829e5baf947d347f49cc1d7807be6c070b.tar.gz
ek-d23d03829e5baf947d347f49cc1d7807be6c070b.zip
initial generics for structs
+ Likely still very much full of bugs
Diffstat (limited to 'src/parser.y')
-rw-r--r--src/parser.y11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/parser.y b/src/parser.y
index 06599f2..a9c4776 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -155,6 +155,7 @@
/* optional stuff */
%nterm <node> opt_exprs proc_decl member opt_members
%nterm <type> opt_types opt_sign_decls sign_decls sign_decl sign_var_decl
+%nterm <node> opt_construct_args
%nterm <node> opt_behaviours behaviours behaviour
/* reverse lists */
@@ -512,7 +513,7 @@ macro
ast_set_flags($6, AST_FLAG_UNHYGIENIC);
}
| "define" ID "(" references "..." id ")" body {
- ast_append($4, $6);
+ ast_append(&$4, $6);
$$ = gen_macro_def($[ID], $4, $8, src_loc(@$));
ast_set_flags($$, AST_FLAG_VARIADIC);
ast_set_flags($8, AST_FLAG_UNHYGIENIC);
@@ -544,12 +545,16 @@ construct_args
: rev_construct_args { $$ = reverse_ast_list($1); }
| rev_construct_args "," { $$ = reverse_ast_list($1); }
+opt_construct_args
+ : construct_args
+ | { $$ = NULL; }
+
construct
- : APPLY "{" construct_args "}" {
+ : APPLY "{" opt_construct_args "}" {
/** @todo add type info? */
$$ = gen_init($1, NULL, $3, src_loc(@$));
}
- | APPLY "[" opt_types "]" "{" construct_args "}" {
+ | APPLY "[" opt_types "]" "{" opt_construct_args "}" {
$$ = gen_init($1, $3, $6, src_loc(@$));
}