%token T_UNION "union"
%token T_ENUM "enum"
-%type <uintval> declspec_simple
-%type <declspec> declspec declspecs
+%type <uintval> declspec_simple typespec_simple
+%type <declspec> declspec_notype declspec_noid typespec_noid typespec
+%type <declspec> declspecs declspecs_noid
%type <declarator> declarator declarators
%type <decl> declaration
.declarators = $2);
};
-declspecs: { $$ = NULL; } | declspecs declspec {
- $$ = $2;
- $$->next = $1;
+declspecs: declspec_notype declspecs {
+ $$ = $1;
+ $$->next = $2;
+} | typespec declspecs_noid {
+ $$ = $1;
+ $$->next = $2;
+}
+
+declspecs_noid: { $$ = NULL; } | declspec_noid declspecs_noid {
+ $$ = $1;
+ $$->next = $2;
}
declarators: declarator | declarator T_COMMA declarators {
$$->next = $3;
};
-declspec_simple: T_VOID { $$ = CDECL_TYPE_VOID; }
+declspec_simple: T_AUTO { $$ = CDECL_STOR_AUTO; }
+ | T_TYPEDEF { $$ = CDECL_STOR_TYPEDEF; }
+ | T_EXTERN { $$ = CDECL_STOR_EXTERN; }
+ | T_STATIC { $$ = CDECL_STOR_STATIC; }
+ | T_REGISTER { $$ = CDECL_STOR_REGISTER; }
+ | T_RESTRICT { $$ = CDECL_QUAL_RESTRICT; }
+ | T_VOLATILE { $$ = CDECL_QUAL_VOLATILE; }
+ | T_CONST { $$ = CDECL_QUAL_CONST; }
+ | T_INLINE { $$ = CDECL_FUNC_INLINE; }
+
+typespec_simple: T_VOID { $$ = CDECL_TYPE_VOID; }
| T_CHAR { $$ = CDECL_TYPE_CHAR; }
| T_SHORT { $$ = CDECL_TYPE_SHORT; }
| T_INT { $$ = CDECL_TYPE_INT; }
| T_UNSIGNED { $$ = CDECL_TYPE_UNSIGNED; }
| T_BOOL { $$ = CDECL_TYPE_BOOL; }
| T_COMPLEX { $$ = CDECL_TYPE_COMPLEX; }
- | T_TYPEDEF { $$ = CDECL_STOR_TYPEDEF; }
- | T_EXTERN { $$ = CDECL_STOR_EXTERN; }
- | T_STATIC { $$ = CDECL_STOR_STATIC; }
- | T_AUTO { $$ = CDECL_STOR_AUTO; }
- | T_REGISTER { $$ = CDECL_STOR_REGISTER; }
- | T_RESTRICT { $$ = CDECL_QUAL_RESTRICT; }
- | T_VOLATILE { $$ = CDECL_QUAL_VOLATILE; }
- | T_CONST { $$ = CDECL_QUAL_CONST; }
- | T_INLINE { $$ = CDECL_FUNC_INLINE; }
- ;
-declspec: declspec_simple {
+declspec_notype: declspec_simple {
ALLOC_STRUCT($$, struct cdecl_declspec, .type = $1);
-} | T_STRUCT T_IDENT {
+}
+
+typespec_noid: typespec_simple {
+ ALLOC_STRUCT($$, struct cdecl_declspec, .type = $1);
+}
+
+typespec: typespec_noid | T_STRUCT T_IDENT {
ALLOC_STRUCT($$, struct cdecl_declspec,
.type = CDECL_TYPE_STRUCT,
.ident = $2);
ALLOC_STRUCT($$, struct cdecl_declspec,
.type = CDECL_TYPE_IDENT,
.ident = $1);
-};
+}
+
+declspec_noid: declspec_notype | typespec_noid
declarator: T_IDENT {
ALLOC_STRUCT($$, struct cdecl_declarator,