ALLOC(ptr, sizeof (type)); \
*(ptr) = (type) { __VA_ARGS__ }; \
} while (0)
+
+/*
+ * With the postprocessing performed by fix-yytname.awk, all the symbol
+ * name strings can be used directly in error messages and there is no
+ * need for any string processing.
+ */
+#define yytnamerr(a, b) cdecl__strlcpy(a, b, (a) ? INT_MAX : 0)
%}
%code requires {
/* Magic tokens */
%token T_LEX_ERROR
-%token T_ENGLISH
%token <strval> T_IDENT "identifier"
%token <uintval> T_UINT "integer constant"
%%
-input: T_ENGLISH english {
- *out = $2;
+input: english {
+ *out = $1;
} | declaration {
*out = $1;
};
| T_COMPLEX
| T_IMAGINARY
-typespec_tagged: T_STRUCT | T_UNION | T_ENUM
+typespec_tagged: T_STRUCT | T_UNION | T_ENUM | { $$ = CDECL_TYPE_IDENT; }
qualifier_simple: T_CONST
| T_RESTRICT
ALLOC_STRUCT($$, struct cdecl_declspec,
.type = $1,
.ident = $2);
-} | T_IDENT {
- ALLOC_STRUCT($$, struct cdecl_declspec,
- .type = CDECL_TYPE_IDENT,
- .ident = $1);
}
declspec_noid: declspec_notype | typespec_noid
vla_ident: T_IDENT | T_ASTERISK {
ALLOC($$, sizeof "");
- strcpy($$, "");
+ *$$ = 0;
}
array: T_LBRACKET array_length T_RBRACKET {
english_vla: T_IDENT | {
ALLOC($$, sizeof "");
- strcpy($$, "");
+ *$$ = 0;
}
%%