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: remove redundant operator informat...



details:   https://anonhg.NetBSD.org/src/rev/3a486baa29e7
branches:  trunk
changeset: 953795:3a486baa29e7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 21 08:46:26 2021 +0000

description:
lint: remove redundant operator information from the grammar

Several tokens can only ever map to a single operator and thus do not
need to encode the operator.  Indeed, they already encoded it as NOOP,
and it was not used by any grammar rule.

No functional change.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  19 +++++++++----------
 usr.bin/xlint/lint1/scan.l  |  18 +++++++++---------
 2 files changed, 18 insertions(+), 19 deletions(-)

diffs (109 lines):

diff -r 6b4f99c4c10e -r 3a486baa29e7 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sun Mar 21 07:32:44 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Mar 21 08:46:26 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.188 2021/03/20 16:16:32 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.189 2021/03/21 08:46:26 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.188 2021/03/20 16:16:32 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.189 2021/03/21 08:46:26 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -126,7 +126,6 @@
 %expect 134
 
 %union {
-       int     y_int;
        val_t   *y_val;
        sbuf_t  *y_sb;
        sym_t   *y_sym;
@@ -151,20 +150,20 @@
 %token                 T_TYPEOF
 %token                 T_EXTENSION
 %token                 T_ALIGNOF
-%token <y_op>          T_ASTERISK
+%token                 T_ASTERISK
 %token <y_op>          T_MULTIPLICATIVE
 %token <y_op>          T_ADDITIVE
 %token <y_op>          T_SHIFT
 %token <y_op>          T_RELATIONAL
 %token <y_op>          T_EQUALITY
-%token <y_op>          T_AMPER
-%token <y_op>          T_XOR
-%token <y_op>          T_BITOR
-%token <y_op>          T_LOGAND
-%token <y_op>          T_LOGOR
+%token                 T_AMPER
+%token                 T_XOR
+%token                 T_BITOR
+%token                 T_LOGAND
+%token                 T_LOGOR
 %token                 T_QUEST
 %token                 T_COLON
-%token <y_op>          T_ASSIGN
+%token                 T_ASSIGN
 %token <y_op>          T_OPASSIGN
 %token                 T_COMMA
 %token                 T_SEMI
diff -r 6b4f99c4c10e -r 3a486baa29e7 usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Sun Mar 21 07:32:44 2021 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Sun Mar 21 08:46:26 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: scan.l,v 1.131 2021/01/24 09:25:16 rillig Exp $ */
+/* $NetBSD: scan.l,v 1.132 2021/03/21 08:46:26 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.131 2021/01/24 09:25:16 rillig Exp $");
+__RCSID("$NetBSD: scan.l,v 1.132 2021/03/21 08:46:26 rillig Exp $");
 #endif
 
 #include "lint1.h"
@@ -68,7 +68,7 @@
 0[xX]{HD}+\.{HD}*{HX}{TL}      |
 0[xX]{HD}+{HX}{TL}             |
 \.{D}+{EX}?{TL}                        return lex_floating_constant(yytext, yyleng);
-"="                            return lex_operator(T_ASSIGN, NOOP);
+"="                            return T_ASSIGN;
 "*="                           return lex_operator(T_OPASSIGN, MULASS);
 "/="                           return lex_operator(T_OPASSIGN, DIVASS);
 "%="                           return lex_operator(T_OPASSIGN, MODASS);
@@ -79,11 +79,11 @@
 "&="                           return lex_operator(T_OPASSIGN, ANDASS);
 "^="                           return lex_operator(T_OPASSIGN, XORASS);
 "|="                           return lex_operator(T_OPASSIGN, ORASS);
-"||"                           return lex_operator(T_LOGOR, NOOP);
-"&&"                           return lex_operator(T_LOGAND, NOOP);
-"|"                            return lex_operator(T_BITOR, NOOP);
-"&"                            return lex_operator(T_AMPER, NOOP);
-"^"                            return lex_operator(T_XOR, NOOP);
+"||"                           return T_LOGOR;
+"&&"                           return T_LOGAND;
+"|"                            return T_BITOR;
+"&"                            return T_AMPER;
+"^"                            return T_XOR;
 "=="                           return lex_operator(T_EQUALITY, EQ);
 "!="                           return lex_operator(T_EQUALITY, NE);
 "<"                            return lex_operator(T_RELATIONAL, LT);
@@ -98,7 +98,7 @@
 "."                            return lex_operator(T_MEMBACC, POINT);
 "+"                            return lex_operator(T_ADDITIVE, PLUS);
 "-"                            return lex_operator(T_ADDITIVE, MINUS);
-"*"                            return lex_operator(T_ASTERISK, NOOP);
+"*"                            return T_ASTERISK;
 "/"                            return lex_operator(T_MULTIPLICATIVE, DIV);
 "%"                            return lex_operator(T_MULTIPLICATIVE, MOD);
 "!"                            return lex_operator(T_UNARY, NOT);



Home | Main Index | Thread Index | Old Index