]> git.draconx.ca Git - cdecl99.git/commitdiff
libcdecl: Combine tag/typedef identifier rules.
authorNick Bowler <nbowler@draconx.ca>
Thu, 20 Jul 2023 01:25:09 +0000 (21:25 -0400)
committerNick Bowler <nbowler@draconx.ca>
Thu, 20 Jul 2023 01:25:09 +0000 (21:25 -0400)
There are actually no conflicts to add an empty production alongside
the rule for "struct", "union" and "enum", which allows the subsequent
reductions for "tag identifier" and "[nothing] identifier" to be done
with just one rule.

This replaces a relatively large action from the eliminated rule with
a very simple one.

src/parse.y

index 1542c0904e5bea5320ec864646fcfd4ddb63bd64..a993ea6100459e100bd3f367da553b35f7541d0f 100644 (file)
@@ -343,7 +343,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,10 +365,6 @@ 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