Module Name:    src
Committed By:   rillig
Date:           Sun Mar 21 08:46:26 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: cgram.y scan.l

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.188 -r1.189 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.131 -r1.132 src/usr.bin/xlint/lint1/scan.l

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.188 src/usr.bin/xlint/lint1/cgram.y:1.189
--- src/usr.bin/xlint/lint1/cgram.y:1.188	Sat Mar 20 16:16:32 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Sun Mar 21 08:46:26 2021
@@ -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 @@ anonymize(sym_t *s)
 %expect 134
 
 %union {
-	int	y_int;
 	val_t	*y_val;
 	sbuf_t	*y_sb;
 	sym_t	*y_sym;
@@ -151,20 +150,20 @@ anonymize(sym_t *s)
 %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

Index: src/usr.bin/xlint/lint1/scan.l
diff -u src/usr.bin/xlint/lint1/scan.l:1.131 src/usr.bin/xlint/lint1/scan.l:1.132
--- src/usr.bin/xlint/lint1/scan.l:1.131	Sun Jan 24 09:25:16 2021
+++ src/usr.bin/xlint/lint1/scan.l	Sun Mar 21 08:46:26 2021
@@ -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 @@ TL	([fFlL]?[i]?)
 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 @@ TL	([fFlL]?[i]?)
 "&="				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 @@ TL	([fFlL]?[i]?)
 "."				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);

Reply via email to