]> git.draconx.ca Git - cdecl99.git/blobdiff - src/parse.y
libcdecl: Remove magic T_ENGLISH token.
[cdecl99.git] / src / parse.y
index 918cbd033a085870a70fc8f59a8058e468ebfbc5..fd5776ede27596b488d34a7cf113811113eade9a 100644 (file)
        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 {
@@ -181,7 +188,6 @@ static struct cdecl *insert_identifier(struct cdecl *decl, char *ident)
 
 /* Magic tokens */
 %token T_LEX_ERROR
-%token T_ENGLISH
 
 %token <strval> T_IDENT "identifier"
 %token <uintval> T_UINT "integer constant"
@@ -267,8 +273,8 @@ static struct cdecl *insert_identifier(struct cdecl *decl, char *ident)
 
 %%
 
-input: T_ENGLISH english {
-       *out = $2;
+input: english {
+       *out = $1;
 } | declaration {
        *out = $1;
 };
@@ -343,7 +349,7 @@ typespec_simple: T_VOID
        | 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
@@ -365,17 +371,13 @@ typespec: typespec_noid | typespec_tagged T_IDENT {
        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 {
@@ -572,7 +574,7 @@ array_length: T_UINT {
 
 english_vla: T_IDENT | {
        ALLOC($$, sizeof "");
-       strcpy($$, "");
+       *$$ = 0;
 }
 
 %%