decl_typedef_body(def) ::= decl_typedef_body_ex(def_). {
def = def_;
}
-decl_typedef_body(def) ::= decl_func(func_) LPAREN decl_args(args) RPAREN. {
+%type decl_typedef_body_fn_args {decl_args *}
+%destructor decl_typedef_body_fn_args {free_decl_args($$);}
+decl_typedef_body_fn_args(args) ::= LPAREN decl_args(args_) RPAREN. {
+ args = args_;
+}
+decl_typedef_body(def) ::= decl_func(func_) decl_typedef_body_fn_args(args). {
def = init_decl_arg(init_decl_type(PSI_T_FUNCTION, func_->var->name), copy_decl_var(func_->var));
def->type->token = PSI_TokenCopy(func_->token);
def->type->func = init_decl(init_decl_abi("default"), func_, args);
func->var->token = N;
func->token = N;
}
+decl_typedef_body(def) ::= VOID(T) indirection(i) LPAREN ASTERISK NAME(N) RPAREN decl_typedef_body_fn_args(args). {
+ decl_arg *func_ = init_decl_arg(
+ init_decl_type(T->type, T->text),
+ init_decl_var(N->text, i, 0)
+ );
+ func_->type->token = T;
+ func_->var->token = N;
+ func_->token = N;
+ def = init_decl_arg(init_decl_type(PSI_T_FUNCTION, func_->var->name), copy_decl_var(func_->var));
+ def->type->token = PSI_TokenCopy(func_->token);
+ def->type->func = init_decl(init_decl_abi("default"), func_, args);
+}
+decl_typedef_body(def) ::= CONST VOID(T) pointers(i) LPAREN ASTERISK NAME(N) RPAREN decl_typedef_body_fn_args(args). {
+ decl_arg *func_ = init_decl_arg(
+ init_decl_type(T->type, T->text),
+ init_decl_var(N->text, i, 0)
+ );
+ func_->type->token = T;
+ func_->var->token = N;
+ func_->token = N;
+ def = init_decl_arg(init_decl_type(PSI_T_FUNCTION, func_->var->name), copy_decl_var(func_->var));
+ def->type->token = PSI_TokenCopy(func_->token);
+ def->type->func = init_decl(init_decl_abi("default"), func_, args);
+}
%type decl_abi {decl_abi*}
%destructor decl_abi {free_decl_abi($$);}
decl_arg(arg_) ::= const_decl_type(type) decl_var(var). {
arg_ = init_decl_arg(type, var);
}
+decl_typedef_body(def) ::= const_decl_type(type_) indirection(i) LPAREN ASTERISK NAME(N) RPAREN decl_typedef_body_fn_args(args). {
+ decl_arg *func_ = init_decl_arg(
+ type_,
+ init_decl_var(N->text, i, 0)
+ );
+ func_->var->token = N;
+ func_->token = N;
+ def = init_decl_arg(init_decl_type(PSI_T_FUNCTION, func_->var->name), copy_decl_var(func_->var));
+ def->type->token = PSI_TokenCopy(func_->token);
+ def->type->func = init_decl(init_decl_abi("default"), func_, args);
+}
+
/* void pointers need a specific rule */
decl_arg(arg_) ::= VOID(T) pointers(p) NAME(N). {
arg_ = init_decl_arg(
%type impl_var {impl_var*}
%destructor impl_var {free_impl_var($$);}
-impl_var(var) ::= reference(r) DOLLAR NAME(T). {
+impl_var(var) ::= reference(r) DOLLAR_NAME(T). {
var = init_impl_var(T->text, r);
var->token = T;
}
%type impl_vararg {impl_arg*}
%destructor impl_vararg {free_impl_arg($$);}
-impl_vararg(va) ::= impl_type(type) reference(r) ELLIPSIS DOLLAR NAME(T). {
+impl_vararg(va) ::= impl_type(type) reference(r) ELLIPSIS DOLLAR_NAME(T). {
va = init_impl_arg(type, init_impl_var(T->text, r), NULL);
free(T);
}
call->token = F;
}
-%token_class impl_type_token VOID MIXED BOOL INT FLOAT STRING ARRAY OBJECT.
+%token_class impl_type_token VOID MIXED BOOL INT FLOAT STRING ARRAY OBJECT CALLABLE.
%type impl_type {impl_type*}
%destructor impl_type {free_impl_type($$);}
impl_type(type_) ::= impl_type_token(T). {