From: Nick Bowler Date: Mon, 24 Jul 2023 04:10:22 +0000 (-0400) Subject: libcdecl: Factor out toplevel parser actions. X-Git-Tag: v1.3~94 X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/commitdiff_plain/1b56fac4a07ed3ef680a46639c8e8e5bae4767e9 libcdecl: Factor out toplevel parser actions. Using a separate rule so there is just one semantic action for the start symbol seems to give a slight code size improvement. --- diff --git a/src/parse.y b/src/parse.y index ba9bf22..f8c9608 100644 --- a/src/parse.y +++ b/src/parse.y @@ -256,16 +256,14 @@ static struct cdecl_declarator *nulldecl(void) %type declspecs declspecs_noid %type direct_declarator declarator pointer array parens postfix %type direct_declarator_ish declarator_ish parameter_type_list -%type declaration declarators declarator_wrap -%type parameter +%type cdecl declaration declarators declarator_wrap parameter %type english_vla %type storage_func_specs post_specs %type type_qual_spec type_qual_specs typedef_name_qual %type english_declarator english_array english_function %type english_parameter_list null_decl -%type english english_declaration -%type english_parameter +%type english english_declaration english_parameter /* Precedence declaration to avoid conflict in english_parameter; see below. */ %right T_TYPE @@ -273,14 +271,10 @@ static struct cdecl_declarator *nulldecl(void) %% -input: english { - *out = $1; -} | declaration { - *out = $1; -}; +input: cdecl { *out = $1; } +cdecl: english | declaration semi: | T_SEMICOLON - declaration: declspecs declarators semi { $$ = $2; $$->specifiers = $1;