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: use separate tokens for logical no...



details:   https://anonhg.NetBSD.org/src/rev/ba281052e9cc
branches:  trunk
changeset: 1022288:ba281052e9cc
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 11 18:03:47 2021 +0000

description:
lint: use separate tokens for logical not and bitwise complement

The token T_UNARY was misleading since it only captured 2 of the 6
operators that C99 calls unary-operator.  Make the grammar easier to
understand by explicitly listing these 2 operators.

No functional change.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  13 ++++++++-----
 usr.bin/xlint/lint1/scan.l  |   8 ++++----
 2 files changed, 12 insertions(+), 9 deletions(-)

diffs (72 lines):

diff -r e057b8e172b8 -r ba281052e9cc usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sun Jul 11 17:52:20 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Jul 11 18:03:47 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.309 2021/07/11 17:52:20 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.310 2021/07/11 18:03:47 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.309 2021/07/11 17:52:20 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.310 2021/07/11 18:03:47 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -145,7 +145,7 @@
 
 %token                 T_LBRACE T_RBRACE T_LBRACK T_RBRACK T_LPAREN T_RPAREN
 %token                 T_POINT T_ARROW
-%token <y_op>          T_UNARY
+%token                 T_COMPLEMENT T_LOGNOT
 %token <y_op>          T_INCDEC
 %token                 T_SIZEOF
 %token                 T_BUILTIN_OFFSETOF
@@ -1823,8 +1823,11 @@
                }
                $$ = build($1 == PLUS ? UPLUS : UMINUS, $2, NULL);
          }
-       | T_UNARY term {
-               $$ = build($1, $2, NULL);
+       | T_COMPLEMENT term {
+               $$ = build(COMPL, $2, NULL);
+         }
+       | T_LOGNOT term {
+               $$ = build(NOT, $2, NULL);
          }
        | T_SIZEOF unary_expression {
                $$ = $2 == NULL ? NULL : build_sizeof($2->tn_type);
diff -r e057b8e172b8 -r ba281052e9cc usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Sun Jul 11 17:52:20 2021 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Sun Jul 11 18:03:47 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.134 2021/06/20 18:15:12 rillig Exp $ */
+/* $NetBSD: scan.l,v 1.135 2021/07/11 18:03:47 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: scan.l,v 1.134 2021/06/20 18:15:12 rillig Exp $");
+__RCSID("$NetBSD: scan.l,v 1.135 2021/07/11 18:03:47 rillig Exp $");
 #endif
 
 #include "lint1.h"
@@ -101,8 +101,8 @@
 "*"                            return T_ASTERISK;
 "/"                            return lex_operator(T_MULTIPLICATIVE, DIV);
 "%"                            return lex_operator(T_MULTIPLICATIVE, MOD);
-"!"                            return lex_operator(T_UNARY, NOT);
-"~"                            return lex_operator(T_UNARY, COMPL);
+"!"                            return T_LOGNOT;
+"~"                            return T_COMPLEMENT;
 "\""                           return lex_string();
 "L\""                          return lex_wide_string();
 ";"                            return T_SEMI;



Home | Main Index | Thread Index | Old Index