Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: in the grammar, rename 'decl' to '...



details:   https://anonhg.NetBSD.org/src/rev/4871549d1674
branches:  trunk
changeset: 984636:4871549d1674
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Jul 14 17:19:37 2021 +0000

description:
lint: in the grammar, rename 'decl' to 'declarator'

For a casual reader, the abbreviation 'decl' was ambiguous since C has
both declarations and declarators.

No functional change.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  196 ++++++++++++++++++++++---------------------
 1 files changed, 99 insertions(+), 97 deletions(-)

diffs (truncated from 475 to 300 lines):

diff -r 7358f752f4e2 -r 4871549d1674 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Wed Jul 14 17:07:24 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Wed Jul 14 17:19:37 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.323 2021/07/14 17:07:24 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.324 2021/07/14 17:19:37 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.323 2021/07/14 17:07:24 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.324 2021/07/14 17:19:37 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -309,10 +309,10 @@
 %type  <y_sym>         struct_declaration_list_with_rbrace
 %type  <y_sym>         struct_declaration_list
 %type  <y_sym>         struct_declaration
-%type  <y_sym>         notype_member_decls
-%type  <y_sym>         type_member_decls
-%type  <y_sym>         notype_member_decl
-%type  <y_sym>         type_member_decl
+%type  <y_sym>         notype_struct_declarators
+%type  <y_sym>         type_struct_declarators
+%type  <y_sym>         notype_struct_declarator
+%type  <y_sym>         type_struct_declarator
 %type  <y_type>        enum_specifier
 %type  <y_sym>         enum_declaration
 %type  <y_sym>         enums_with_opt_comma
@@ -323,14 +323,14 @@
 %type  <y_qual_ptr>    asterisk
 %type  <y_qual_ptr>    type_qualifier_list_opt
 %type  <y_qual_ptr>    type_qualifier_list
-%type  <y_sym>         notype_decl
-%type  <y_sym>         type_decl
-%type  <y_sym>         notype_direct_decl
-%type  <y_sym>         type_direct_decl
-%type  <y_sym>         type_param_decl
-%type  <y_sym>         notype_param_decl
-%type  <y_sym>         direct_param_decl
-%type  <y_sym>         direct_notype_param_decl
+%type  <y_sym>         notype_declarator
+%type  <y_sym>         type_declarator
+%type  <y_sym>         notype_direct_declarator
+%type  <y_sym>         type_direct_declarator
+%type  <y_sym>         type_param_declarator
+%type  <y_sym>         notype_param_declarator
+%type  <y_sym>         direct_param_declarator
+%type  <y_sym>         direct_notype_param_declarator
 %type  <y_sym>         param_list
 %type  <y_tnode>       array_size
 %type  <y_sym>         identifier_list
@@ -348,7 +348,7 @@
 %type  <y_seen_statement> block_item_list
 %type  <y_seen_statement> block_item
 %type  <y_tnode>       do_while_expr
-%type  <y_sym>         func_decl
+%type  <y_sym>         func_declarator
 
 %%
 
@@ -726,7 +726,7 @@
                        warning(2);
                }
          }
-       | begin_type_declmods end_type notype_init_decls T_SEMI
+       | begin_type_declmods end_type notype_init_declarators T_SEMI
        | begin_type_declaration_specifiers end_type T_SEMI {
                if (dcs->d_scl == TYPEDEF) {
                        /* typedef declares no type name */
@@ -736,7 +736,8 @@
                        warning(2);
                }
          }
-       | begin_type_declaration_specifiers end_type type_init_decls T_SEMI
+       | begin_type_declaration_specifiers end_type
+           type_init_declarators T_SEMI
        | error T_SEMI
        ;
 
@@ -951,13 +952,13 @@
          begin_type_noclass_declmods end_type {
                /* too late, i know, but getsym() compensates it */
                symtyp = FMEMBER;
-         } notype_member_decls type_attribute_opt {
+         } notype_struct_declarators type_attribute_opt {
                symtyp = FVFT;
                $$ = $4;
          }
        | begin_type_noclass_declspecs end_type {
                symtyp = FMEMBER;
-         } type_member_decls type_attribute_opt {
+         } type_struct_declarators type_attribute_opt {
                symtyp = FVFT;
                $$ = $4;
          }
@@ -987,32 +988,31 @@
          }
        ;
 
-/* TODO: rename 'decls' to 'declarators', everywhere. */
-notype_member_decls:
-         notype_member_decl {
+notype_struct_declarators:
+         notype_struct_declarator {
                $$ = declarator_1_struct_union($1);
          }
-       | notype_member_decls {
+       | notype_struct_declarators {
                symtyp = FMEMBER;
-         } T_COMMA type_member_decl {
+         } T_COMMA type_struct_declarator {
                $$ = lnklst($1, declarator_1_struct_union($4));
          }
        ;
 
-type_member_decls:
-         type_member_decl {
+type_struct_declarators:
+         type_struct_declarator {
                $$ = declarator_1_struct_union($1);
          }
-       | type_member_decls {
+       | type_struct_declarators {
                symtyp = FMEMBER;
-         } T_COMMA type_member_decl {
+         } T_COMMA type_struct_declarator {
                $$ = lnklst($1, declarator_1_struct_union($4));
          }
        ;
 
-notype_member_decl:
-         notype_decl
-       | notype_decl T_COLON constant_expr {           /* C99 6.7.2.1 */
+notype_struct_declarator:
+         notype_declarator
+       | notype_declarator T_COLON constant_expr {             /* C99 6.7.2.1 */
                $$ = bitfield($1, to_int_constant($3, true));
          }
        | {
@@ -1022,9 +1022,9 @@
          }
        ;
 
-type_member_decl:
-         type_decl
-       | type_decl T_COLON constant_expr {
+type_struct_declarator:
+         type_declarator
+       | type_declarator T_COLON constant_expr {
                $$ = bitfield($1, to_int_constant($3, true));
          }
        | {
@@ -1156,22 +1156,22 @@
  * manual, section 7.1 "Semantic Info in Token Kinds".
  */
 
-notype_init_decls:
-         notype_init_decl
-       | notype_init_decls T_COMMA type_init_decl
+notype_init_declarators:
+         notype_init_declarator
+       | notype_init_declarators T_COMMA type_init_declarator
        ;
 
-type_init_decls:
-         type_init_decl
-       | type_init_decls T_COMMA type_init_decl
+type_init_declarators:
+         type_init_declarator
+       | type_init_declarators T_COMMA type_init_declarator
        ;
 
-notype_init_decl:
-         notype_decl asm_or_symbolrename_opt {
+notype_init_declarator:
+         notype_declarator asm_or_symbolrename_opt {
                cgram_declare($1, false, $2);
                check_size($1);
          }
-       | notype_decl asm_or_symbolrename_opt {
+       | notype_declarator asm_or_symbolrename_opt {
                begin_initialization($1);
                cgram_declare($1, true, $2);
          } T_ASSIGN initializer {
@@ -1180,12 +1180,12 @@
          }
        ;
 
-type_init_decl:
-         type_decl asm_or_symbolrename_opt {
+type_init_declarator:
+         type_declarator asm_or_symbolrename_opt {
                cgram_declare($1, false, $2);
                check_size($1);
          }
-       | type_decl asm_or_symbolrename_opt {
+       | type_declarator asm_or_symbolrename_opt {
                begin_initialization($1);
                cgram_declare($1, true, $2);
          } T_ASSIGN initializer {
@@ -1194,126 +1194,126 @@
          }
        ;
 
-notype_decl:
-         notype_direct_decl
-       | pointer notype_direct_decl {
+notype_declarator:
+         notype_direct_declarator
+       | pointer notype_direct_declarator {
                $$ = add_pointer($2, $1);
          }
        ;
 
-type_decl:
-         type_direct_decl
-       | pointer type_direct_decl {
+type_declarator:
+         type_direct_declarator
+       | pointer type_direct_declarator {
                $$ = add_pointer($2, $1);
          }
        ;
 
-notype_direct_decl:
+notype_direct_declarator:
          T_NAME {
                $$ = declarator_name(getsym($1));
          }
-       | T_LPAREN type_decl T_RPAREN {
+       | T_LPAREN type_declarator T_RPAREN {
                $$ = $2;
          }
-       | type_attribute notype_direct_decl {
+       | type_attribute notype_direct_declarator {
                $$ = $2;
          }
-       | notype_direct_decl T_LBRACK T_RBRACK {
+       | notype_direct_declarator T_LBRACK T_RBRACK {
                $$ = add_array($1, false, 0);
          }
-       | notype_direct_decl T_LBRACK array_size T_RBRACK {
+       | notype_direct_declarator T_LBRACK array_size T_RBRACK {
                $$ = add_array($1, true, to_int_constant($3, false));
          }
-       | notype_direct_decl param_list asm_or_symbolrename_opt {
+       | notype_direct_declarator param_list asm_or_symbolrename_opt {
                $$ = add_function(symbolrename($1, $3), $2);
                end_declaration_level();
                block_level--;
          }
-       | notype_direct_decl type_attribute
+       | notype_direct_declarator type_attribute
        ;
 
-type_direct_decl:
+type_direct_declarator:
          identifier {
                $$ = declarator_name(getsym($1));
          }
-       | T_LPAREN type_decl T_RPAREN {
+       | T_LPAREN type_declarator T_RPAREN {
                $$ = $2;
          }
-       | type_attribute type_direct_decl {
+       | type_attribute type_direct_declarator {
                $$ = $2;
          }
-       | type_direct_decl T_LBRACK T_RBRACK {
+       | type_direct_declarator T_LBRACK T_RBRACK {
                $$ = add_array($1, false, 0);
          }
-       | type_direct_decl T_LBRACK array_size T_RBRACK {
+       | type_direct_declarator T_LBRACK array_size T_RBRACK {
                $$ = add_array($1, true, to_int_constant($3, false));
          }
-       | type_direct_decl param_list asm_or_symbolrename_opt {
+       | type_direct_declarator param_list asm_or_symbolrename_opt {
                $$ = add_function(symbolrename($1, $3), $2);
                end_declaration_level();
                block_level--;
          }
-       | type_direct_decl type_attribute
+       | type_direct_declarator type_attribute
        ;
 
 /*
- * The two distinct rules type_param_decl and notype_param_decl avoid a
+ * The two distinct rules type_param_declarator and notype_param_declarator avoid a
  * conflict in argument lists. A typename enclosed in parentheses is always
  * treated as a typename, not an argument name. For example, after
  * "typedef double a;", the declaration "f(int (a));" is interpreted as
  * "f(int (double));", not "f(int a);".
  */



Home | Main Index | Thread Index | Old Index