+english: T_DECLARE T_IDENT T_AS english_declaration {
+ $$ = insert_identifier($4, $2);
+} | T_TYPE english_declaration {
+ $$ = $2;
+}
+
+/*
+ * We use a precedence declaration to prefer shifting an identifier
+ * 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;
+}
+
+type_qual_spec: typespec_noid | qualifier
+
+type_qual_specs: { $$ = NULL; } | type_qual_spec type_qual_specs {
+ $$ = $1;
+ $$->next = $2;
+}
+
+/*
+ * The "qualifiers" nonterminal needs to be used here to avoid shift/reduce
+ * conflicts with pointer declarators. So we end up needing to stitch
+ * together three different specifiers lists.
+ */
+post_specs: qualifiers typespec type_qual_specs {
+ $2->next = $3;
+ join_specs($2, $1);
+ $$ = $2;
+}
+
+english_declaration: storage_func_specs english_declarator post_specs {
+ join_specs($3, $1);
+ ALLOC_DECL($$, $3, $2);
+}
+
+english_declarator: {
+ $$ = NULLDECL;
+} | english_declarator qualifiers T_POINTER T_TO {
+ ALLOC_POINTER($$, $2, $1);
+} | english_declarator english_array {
+ $$ = $2;
+ $$->child = $1;
+} | english_declarator english_function {
+ $$ = $2;
+ $$->child = $1;
+}
+
+english_function: T_FUNCTION T_RETURNING {
+ ALLOC_FUNCTION($$, NULL, false);
+} | T_FUNCTION T_LPAREN english_parameter_list T_RPAREN T_RETURNING {
+ $$ = $3;
+}
+
+english_parameter_list: english_parameter varargs {
+ ALLOC_FUNCTION($$, $1, $2);
+} | english_parameter T_COMMA english_parameter_list {
+ $$ = $3;
+ $1->next = $$->u.function.parameters;
+ $$->u.function.parameters = $1;
+}
+
+typedef_name_qual: T_IDENT qualifiers {
+ /* Compiler should be able to elide this assignment. */
+ $1->u.declspec.ident = $1->u.declarator.u.ident;
+
+ $$ = &$1->u.declspec;
+ $$->type = CDECL_TYPE_IDENT;
+ $$->next = $2;
+}
+
+null_decl: {
+ $$ = NULLDECL;
+}
+
+/*
+ * There is a shift/reduce conflict here when an identifier appears as the
+ * first token. The conflict is between shifting T_IDENT, or reducing the
+ * empty production for storage_func_specs (cf. english_declaration).
+ *
+ * - In either case, if we reduce, we won't match T_IDENT T_AS since the
+ * stack now has the extra storage_func_specs nonterminal symbol.
+ * - And if we shift, we won't match english_declaration since it is
+ * too late to add storage_func_specs to the stack.
+ *
+ * The only valid input affected by the conflict is a simple type names,
+ * possibly followed by qualifiers. So the conflict is adequately resolved
+ * by shifting, so long as we have a special-case reduction to handle this.
+ */
+english_parameter: english_declaration | typedef_name_qual null_decl {
+ ALLOC_DECL($$, $1, $2);
+} | T_IDENT T_AS english_declaration {
+ $$ = insert_identifier($3, $1);
+}
+
+english_array: T_VLA T_ARRAY english_vla T_OF {
+ $$ = &$3->u.declarator;
+ $$->type = CDECL_DECL_ARRAY;
+ $$->u.array.vla = $$->u.ident;
+ $$->u.array.length = 0;
+} | T_ARRAY array_length T_OF {
+ ALLOC_ARRAY($$, $2);
+}
+
+array_length: { $$ = 0; }
+array_length: T_UINT {
+ if (!($$ = $1))
+ FAIL(_("array length must be positive"));
+}
+
+english_vla: T_IDENT | {
+ if (!($$ = cdecl__alloc_item(1)))
+ YYERROR;
+ *$$->s = 0;
+}
+