a->next = b;
}
+/*
+ * Join three specifier lists into a single list, and returns the head of
+ * the new list.
+ *
+ * The list "b" is assumed to be a singleton list.
+ */
+static struct cdecl_declspec *join_specs3(struct cdecl_declspec *a,
+ struct cdecl_declspec *b,
+ struct cdecl_declspec *c)
+{
+ b->next = c;
+ join_specs(b, a);
+ return b;
+}
+
/*
* Alter an abstract declarator (type name) to declare an identifier instead,
* used by the English parser rules to reduce "identifier as type" sequences.
%type <spectype> typespec_simple typespec_tagged
%type <declspec> declspec_notype declspec_noid typespec_noid typespec
%type <declspec> qualifier qualifiers
-%type <declspec> declspecs declspecs_noid
+%type <declspec> declspecs declspecs_notype declspecs_noid
%type <declarator> direct_declarator declarator pointer array parens postfix
%type <declarator> direct_declarator_ish declarator_ish parameter_type_list
%type <decl> cdecl declaration declarators declarator_wrap parameter
* unexpected parses; libcdecl applies a simplification step to the resulting
* parse tree afterwards.
*/
-declspecs: declspec_notype declspecs {
- $$ = $1;
- $$->next = $2;
-} | typespec declspecs_noid {
- $$ = $1;
- $$->next = $2;
+declspecs: declspecs_notype typespec declspecs_noid {
+ $$ = join_specs3($1, $2, $3);
}
-declspecs_noid: { $$ = NULL; } | declspec_noid declspecs_noid {
- $$ = $1;
- $$->next = $2;
+declspecs_notype: { $$ = NULL; } | declspecs_notype declspec_notype {
+ $$ = $2;
+ $$->next = $1;
+}
+
+declspecs_noid: { $$ = NULL; } | declspecs_noid declspec_noid {
+ $$ = $2;
+ $$->next = $1;
}
qualifiers: { $$ = NULL; } | qualifiers qualifier {
* over reducing this empty rule; see below.
*/
storage_func_specs: %prec T_TYPE { $$ = NULL; }
-storage_func_specs: declspec_simple storage_func_specs {
- ALLOC_DECLSPEC($$, $1);
- $$->next = $2;
+storage_func_specs: storage_func_specs declspec_simple {
+ ALLOC_DECLSPEC($$, $2);
+ $$->next = $1;
}
type_qual_spec: typespec_noid | qualifier
-type_qual_specs: { $$ = NULL; } | type_qual_spec type_qual_specs {
- $$ = $1;
- $$->next = $2;
+type_qual_specs: { $$ = NULL; } | type_qual_specs type_qual_spec {
+ $$ = $2;
+ $$->next = $1;
}
/*
* together three different specifiers lists.
*/
post_specs: qualifiers typespec type_qual_specs {
- $2->next = $3;
- join_specs($2, $1);
- $$ = $2;
+ $$ = join_specs3($1, $2, $3);
}
english_declaration: storage_func_specs english_declarator post_specs {