mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-20 18:52:28 +00:00
Allow qc style function params.
Due to ambiguities in the grammar, qc-style function params and c-style function params had to be completely separated. This means that qc-style functions can not use pointers and must use qc-style function declarations for parameters, and c-style functions must use c-style param declarations. While this rule is tedious for converting the Ruamoko library, it does actually make for a more consistent language.
This commit is contained in:
parent
8a314e9e87
commit
d75c35ba30
1 changed files with 36 additions and 2 deletions
|
@ -157,6 +157,7 @@ int yylex (void);
|
|||
%type <spec> type
|
||||
|
||||
%type <param> function_params var_list param_declaration
|
||||
%type <param> qc_func_params qc_var_list qc_param_decl
|
||||
%type <symbol> var_decl function_decl
|
||||
%type <symbol> abstract_decl abs_decl
|
||||
|
||||
|
@ -307,7 +308,7 @@ external_def_list
|
|||
external_def
|
||||
: optional_specifiers external_decl_list ';' { }
|
||||
| optional_specifiers ';' { }
|
||||
| optional_specifiers function_params
|
||||
| optional_specifiers qc_func_params
|
||||
{
|
||||
$<spec>$ = $1; // copy spec bits and storage
|
||||
$<spec>$.type = parse_params ($1.type, $2), st_global, 0;
|
||||
|
@ -569,7 +570,6 @@ var_decl
|
|||
| var_decl function_params
|
||||
{
|
||||
$$->type = append_type ($$->type, parse_params (0, $2));
|
||||
print_type ($$->type);
|
||||
}
|
||||
| var_decl array_decl
|
||||
{
|
||||
|
@ -615,6 +615,11 @@ function_params
|
|||
| '(' ps var_list ')' { $$ = check_params ($3); }
|
||||
;
|
||||
|
||||
qc_func_params
|
||||
: '(' ')' { $$ = 0; }
|
||||
| '(' ps qc_var_list ')' { $$ = check_params ($3); }
|
||||
;
|
||||
|
||||
ps : ;
|
||||
|
||||
var_list
|
||||
|
@ -630,6 +635,19 @@ var_list
|
|||
}
|
||||
;
|
||||
|
||||
qc_var_list
|
||||
: qc_param_decl
|
||||
| qc_var_list ',' qc_param_decl
|
||||
{
|
||||
param_t *p;
|
||||
|
||||
for (p = $1; p->next; p = p->next)
|
||||
;
|
||||
p->next = $3;
|
||||
$$ = $1;
|
||||
}
|
||||
;
|
||||
|
||||
param_declaration
|
||||
: type var_decl
|
||||
{
|
||||
|
@ -648,6 +666,22 @@ abstract_decl
|
|||
}
|
||||
;
|
||||
|
||||
qc_param_decl
|
||||
: type NAME
|
||||
{
|
||||
$2->type = find_type ($1.type);
|
||||
$$ = new_param (0, $2->type, $2->name);
|
||||
}
|
||||
| type qc_func_params NAME
|
||||
{
|
||||
$3->type = parse_params ($1.type, $2);
|
||||
$3->type = find_type ($3->type);
|
||||
$3->params = $2;
|
||||
$$ = new_param (0, $3->type, $3->name);
|
||||
}
|
||||
| ELLIPSIS { $$ = new_param (0, 0, 0); }
|
||||
;
|
||||
|
||||
//FIXME type construction is inside-out
|
||||
abs_decl
|
||||
: /* empty */ { $$ = new_symbol (""); }
|
||||
|
|
Loading…
Reference in a new issue