struct stoken_vector svec;
struct type **tvec;
int *ivec;
+
+ struct type_stack *type_stack;
}
%{
/* %type <bval> block */
/* Fancy type parsing. */
-%type <voidval> func_mod direct_abs_decl abs_decl
%type <tval> ptype
%type <lval> array_mod
+%type <tval> conversion_type_id
+
+%type <type_stack> ptr_operator_ts abs_decl direct_abs_decl
%token <typed_val_int> INT
%token <typed_val_float> FLOAT
;
space_identifier : '@' NAME
- { push_type_address_space (copy_name ($2.stoken));
- push_type (tp_space_identifier);
- }
+ { insert_type_address_space (copy_name ($2.stoken)); }
;
const_or_volatile: const_or_volatile_noopt
|
;
-abs_decl: '*'
- { push_type (tp_pointer); $$ = 0; }
- | '*' abs_decl
- { push_type (tp_pointer); $$ = $2; }
+ptr_operator:
+ ptr_operator '*'
+ { insert_type (tp_pointer); }
+ const_or_volatile_or_space_identifier
+ | '*'
+ { insert_type (tp_pointer); }
+ const_or_volatile_or_space_identifier
| '&'
- { push_type (tp_reference); $$ = 0; }
- | '&' abs_decl
- { push_type (tp_reference); $$ = $2; }
+ { insert_type (tp_reference); }
+ | '&' ptr_operator
+ { insert_type (tp_reference); }
+ ;
+
+ptr_operator_ts: ptr_operator
+ {
+ $$ = get_type_stack ();
+ /* This cleanup is eventually run by
+ c_parse. */
+ make_cleanup (type_stack_cleanup, $$);
+ }
+ ;
+
+abs_decl: ptr_operator_ts direct_abs_decl
+ { $$ = append_type_stack ($2, $1); }
+ | ptr_operator_ts
| direct_abs_decl
;
{ $$ = $2; }
| direct_abs_decl array_mod
{
+ push_type_stack ($1);
push_type_int ($2);
push_type (tp_array);
+ $$ = get_type_stack ();
}
| array_mod
{
push_type_int ($1);
push_type (tp_array);
- $$ = 0;
+ $$ = get_type_stack ();
}
| direct_abs_decl func_mod
- { push_type (tp_function); }
+ {
+ push_type_stack ($1);
+ push_type (tp_function);
+ $$ = get_type_stack ();
+ }
| func_mod
- { push_type (tp_function); }
+ {
+ push_type (tp_function);
+ $$ = get_type_stack ();
+ }
;
array_mod: '[' ']'
;
func_mod: '(' ')'
- { $$ = 0; }
| '(' nonempty_typelist ')'
- { free ($2); $$ = 0; }
+ { free ($2); }
;
/* We used to try to recognize pointer to member types here, but
;
ptype : typebase
- | ptype const_or_volatile_or_space_identifier abs_decl const_or_volatile_or_space_identifier
+ | ptype abs_decl
+ {
+ push_type_stack ($2);
+ $$ = follow_types ($1);
+ }
+ ;
+
+conversion_type_id: typebase conversion_declarator
{ $$ = follow_types ($1); }
;
+conversion_declarator: /* Nothing. */
+ | ptr_operator conversion_declarator
+ ;
+
const_and_volatile: CONST_KEYWORD VOLATILE_KEYWORD
| VOLATILE_KEYWORD CONST_KEYWORD
;
const_or_volatile_noopt: const_and_volatile
- { push_type (tp_const);
- push_type (tp_volatile);
+ { insert_type (tp_const);
+ insert_type (tp_volatile);
}
| CONST_KEYWORD
- { push_type (tp_const); }
+ { insert_type (tp_const); }
| VOLATILE_KEYWORD
- { push_type (tp_volatile); }
+ { insert_type (tp_volatile); }
;
operator: OPERATOR NEW
{ $$ = operator_stoken (" new"); }
| OPERATOR DELETE
- { $$ = operator_stoken (" delete "); }
+ { $$ = operator_stoken (" delete"); }
| OPERATOR NEW '[' ']'
{ $$ = operator_stoken (" new[]"); }
| OPERATOR DELETE '[' ']'
- { $$ = operator_stoken (" delete[] "); }
+ { $$ = operator_stoken (" delete[]"); }
| OPERATOR '+'
{ $$ = operator_stoken ("+"); }
| OPERATOR '-'
{ $$ = operator_stoken ("()"); }
| OPERATOR '[' ']'
{ $$ = operator_stoken ("[]"); }
- | OPERATOR ptype
+ | OPERATOR conversion_type_id
{ char *name;
long length;
struct ui_file *buf = mem_fileopen ();