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: make the table containing the oper...



details:   https://anonhg.NetBSD.org/src/rev/c48a14afbe5b
branches:  trunk
changeset: 949335:c48a14afbe5b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 09 22:19:11 2021 +0000

description:
lint: make the table containing the operator properties more readable

The C preprocessor does not require its arguments to be expressions, an
empty string is valid as well.  This allows to replace the 0 in the
operator properties table with a space, making the 1 stick out.

Since the table is quite long, divide it into sections and add section
headers.

No change in the generated code.

diffstat:

 usr.bin/xlint/lint1/oper.c  |    8 +-
 usr.bin/xlint/lint1/ops.def |  141 ++++++++++++++++++++++++-------------------
 2 files changed, 83 insertions(+), 66 deletions(-)

diffs (175 lines):

diff -r 7172e42d5ee1 -r c48a14afbe5b usr.bin/xlint/lint1/oper.c
--- a/usr.bin/xlint/lint1/oper.c        Sat Jan 09 21:37:44 2021 +0000
+++ b/usr.bin/xlint/lint1/oper.c        Sat Jan 09 22:19:11 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: oper.c,v 1.1 2021/01/09 21:37:44 rillig Exp $  */
+/*     $NetBSD: oper.c,v 1.2 2021/01/09 22:19:11 rillig Exp $  */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -43,8 +43,10 @@
 #define op(name, repr, \
                bi, lo, in, sc, ar, fo, va, ts, ba, se, \
                lu, ru, pc, cm, ve, de, ew, ic, active) \
-       { { bi, lo, in, sc, ar, fo, va, ts, ba, se, \
-           lu, ru, pc, cm, ve, de, ew, ic, repr }, active },
+       { { bi + 0, lo + 0, in + 0, sc + 0, ar + 0, \
+           fo + 0, va + 0, ts + 0, ba + 0, se + 0, \
+           lu + 0, ru + 0, pc + 0, cm + 0, ve + 0, \
+           de + 0, ew + 0, ic + 0, repr }, active },
 #define end_ops(n) };
 #include "ops.def"
 
diff -r 7172e42d5ee1 -r c48a14afbe5b usr.bin/xlint/lint1/ops.def
--- a/usr.bin/xlint/lint1/ops.def       Sat Jan 09 21:37:44 2021 +0000
+++ b/usr.bin/xlint/lint1/ops.def       Sat Jan 09 22:19:11 2021 +0000
@@ -1,71 +1,86 @@
-/*     $NetBSD: ops.def,v 1.8 2021/01/09 17:36:10 rillig Exp $ */
+/*     $NetBSD: ops.def,v 1.9 2021/01/09 22:19:11 rillig Exp $ */
 
 begin_ops()
+
+/* See mod_t in op.h for the definition of the table columns. */
+
 /*     name    repr            b l i c a s f v t b s l r p c e e =     act */
-op(    NOOP,   "no-op",        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    0)
-op(    ARROW,  "->",           1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,    1)
-op(    POINT,  ".",            1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    1)
-op(    NOT,    "!",            0,1,0,0,0,1,1,0,1,0,0,0,0,0,0,0,1,0,    1)
-op(    COMPL,  "~",            0,0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,1,1,    1)
-op(    INC,    "++",           0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    0)
-op(    DEC,    "--",           0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    0)
-op(    INCBEF, "++x",          0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,    1)
-op(    DECBEF, "--x",          0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,    1)
-op(    INCAFT, "x++",          0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,    1)
-op(    DECAFT, "x--",          0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,    1)
-op(    UPLUS,  "+",            0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,1,1,    1)
-op(    UMINUS, "-",            0,0,0,0,1,0,1,1,0,0,0,1,0,0,0,0,1,1,    1)
-op(    STAR,   "*",            0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,    1)
-op(    AMPER,  "&",            0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    1)
-op(    MULT,   "*",            1,0,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,1,    1)
-op(    DIV,    "/",            1,0,0,0,1,0,1,1,0,1,0,1,1,0,0,0,1,1,    1)
-op(    MOD,    "%",            1,0,1,0,0,0,1,1,0,1,0,1,1,0,0,0,1,1,    1)
-op(    PLUS,   "+",            1,0,0,0,0,1,1,1,0,1,0,0,0,0,0,0,1,0,    1)
-op(    MINUS,  "-",            1,0,0,0,0,1,1,1,0,1,0,0,0,0,0,0,1,0,    1)
-op(    SHL,    "<<",           1,0,1,0,0,0,1,1,0,0,0,0,0,1,0,0,1,1,    1)
-op(    SHR,    ">>",           1,0,1,0,0,0,1,1,0,0,0,1,0,1,0,0,1,1,    1)
-op(    LT,     "<",            1,1,0,0,0,1,1,1,0,1,0,1,1,0,1,1,0,1,    1)
-op(    LE,     "<=",           1,1,0,0,0,1,1,1,0,1,0,1,1,0,1,1,0,1,    1)
-op(    GT,     ">",            1,1,0,0,0,1,1,1,0,1,0,1,1,0,1,1,0,1,    1)
-op(    GE,     ">=",           1,1,0,0,0,1,1,1,0,1,0,1,1,0,1,1,0,1,    1)
-op(    EQ,     "==",           1,1,0,0,0,1,1,1,0,1,0,0,0,0,1,1,0,1,    1)
-op(    NE,     "!=",           1,1,0,0,0,1,1,1,0,1,0,0,0,0,1,1,0,1,    1)
-op(    AND,    "&",            1,0,1,0,0,0,1,1,0,1,0,0,0,1,0,0,1,0,    1)
-op(    XOR,    "^",            1,0,1,0,0,0,1,1,0,1,0,0,0,1,0,0,1,0,    1)
-op(    OR,     "|",            1,0,1,0,0,0,1,1,0,1,0,0,0,1,0,0,1,0,    1)
-op(    LOGAND, "&&",           1,1,0,0,0,1,1,0,1,0,0,0,0,0,0,0,1,0,    1)
-op(    LOGOR,  "||",           1,1,0,0,0,1,1,0,1,0,0,0,0,1,0,0,1,0,    1)
-op(    QUEST,  "?",            1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,    1)
-op(    COLON,  ":",            1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,    1)
-op(    ASSIGN, "=",            1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,    1)
-op(    MULASS, "*=",           1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,    1)
-op(    DIVASS, "/=",           1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,1,0,    1)
-op(    MODASS, "%=",           1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,    1)
-op(    ADDASS, "+=",           1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,    1)
-op(    SUBASS, "-=",           1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,    1)
-op(    SHLASS, "<<=",          1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,    1)
-op(    SHRASS, ">>=",          1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,    1)
-op(    ANDASS, "&=",           1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,    1)
-op(    XORASS, "^=",           1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,    1)
-op(    ORASS,  "|=",           1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,    1)
-op(    NAME,   "name",         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    1)
-op(    CON,    "const",        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    1)
-op(    STRING, "string",       0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    1)
-op(    FSEL,   "fsel",         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    1)
-op(    CALL,   "call",         1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,    1)
-op(    COMMA,  ",",            1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,    1)
-op(    CVT,    "convert",      0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,    1)
-op(    ICALL,  "icall",        1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,    1)
-op(    LOAD,   "load",         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    1)
-op(    PUSH,   "push",         0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,    1)
-op(    RETURN, "return",       1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,    1)
-op(    REAL,   "real",         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    0)
-op(    IMAG,   "imag",         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    0)
+op(    NOOP,   "no-op",         , , , , , , , , , , , , , , , , , ,    0)
+op(    ARROW,  "->",           1, , , , , , ,1, , , , , , , , , , ,    1)
+op(    POINT,  ".",            1, , , , , , , , , , , , , , , , , ,    1)
+op(    NOT,    "!",             ,1, , , ,1,1, ,1, , , , , , , ,1, ,    1)
+op(    COMPL,  "~",             , , ,1, , ,1,1, , , , , , , , ,1,1,    1)
+op(    INC,    "++",            , , , , , , , , , , , , , , , , , ,    0)
+op(    DEC,    "--",            , , , , , , , , , , , , , , , , , ,    0)
+op(    INCBEF, "++x",           , , , , ,1, , , , ,1, , , , , ,1, ,    1)
+op(    DECBEF, "--x",           , , , , ,1, , , , ,1, , , , , ,1, ,    1)
+op(    INCAFT, "x++",           , , , , ,1, , , , ,1, , , , , ,1, ,    1)
+op(    DECAFT, "x--",           , , , , ,1, , , , ,1, , , , , ,1, ,    1)
+op(    UPLUS,  "+",             , , , ,1, ,1,1, , , , , , , , ,1,1,    1)
+op(    UMINUS, "-",             , , , ,1, ,1,1, , , ,1, , , , ,1,1,    1)
+op(    STAR,   "*",             , , , , , , ,1, , , , , , , , , , ,    1)
+op(    AMPER,  "&",             , , , , , , , , , , , , , , , , , ,    1)
+
+/*     name    repr            b l i c a s f v t b s l r p c e e =     act */
+op(    MULT,   "*",            1, , , ,1, ,1,1, ,1, , ,1, , , ,1,1,    1)
+op(    DIV,    "/",            1, , , ,1, ,1,1, ,1, ,1,1, , , ,1,1,    1)
+op(    MOD,    "%",            1, ,1, , , ,1,1, ,1, ,1,1, , , ,1,1,    1)
+op(    PLUS,   "+",            1, , , , ,1,1,1, ,1, , , , , , ,1, ,    1)
+op(    MINUS,  "-",            1, , , , ,1,1,1, ,1, , , , , , ,1, ,    1)
+op(    SHL,    "<<",           1, ,1, , , ,1,1, , , , , ,1, , ,1,1,    1)
+op(    SHR,    ">>",           1, ,1, , , ,1,1, , , ,1, ,1, , ,1,1,    1)
+
+/*     name    repr            b l i c a s f v t b s l r p c e e =     act */
+op(    LT,     "<",            1,1, , , ,1,1,1, ,1, ,1,1, ,1,1, ,1,    1)
+op(    LE,     "<=",           1,1, , , ,1,1,1, ,1, ,1,1, ,1,1, ,1,    1)
+op(    GT,     ">",            1,1, , , ,1,1,1, ,1, ,1,1, ,1,1, ,1,    1)
+op(    GE,     ">=",           1,1, , , ,1,1,1, ,1, ,1,1, ,1,1, ,1,    1)
+op(    EQ,     "==",           1,1, , , ,1,1,1, ,1, , , , ,1,1, ,1,    1)
+op(    NE,     "!=",           1,1, , , ,1,1,1, ,1, , , , ,1,1, ,1,    1)
+
+/*     name    repr            b l i c a s f v t b s l r p c e e =     act */
+op(    AND,    "&",            1, ,1, , , ,1,1, ,1, , , ,1, , ,1, ,    1)
+op(    XOR,    "^",            1, ,1, , , ,1,1, ,1, , , ,1, , ,1, ,    1)
+op(    OR,     "|",            1, ,1, , , ,1,1, ,1, , , ,1, , ,1, ,    1)
+op(    LOGAND, "&&",           1,1, , , ,1,1, ,1, , , , , , , ,1, ,    1)
+op(    LOGOR,  "||",           1,1, , , ,1,1, ,1, , , , ,1, , ,1, ,    1)
+op(    QUEST,  "?",            1, , , , , ,1, ,1, , , , , , , , , ,    1)
+op(    COLON,  ":",            1, , , , , , ,1, ,1, , , , , ,1, , ,    1)
+
+/*     name    repr            b l i c a s f v t b s l r p c e e =     act */
+op(    ASSIGN, "=",            1, , , , , , , , , ,1, , , , ,1, , ,    1)
+op(    MULASS, "*=",           1, , , ,1, , , , , ,1, , , , , ,1, ,    1)
+op(    DIVASS, "/=",           1, , , ,1, , , , , ,1, ,1, , , ,1, ,    1)
+op(    MODASS, "%=",           1, ,1, , , , , , , ,1, ,1, , , ,1, ,    1)
+op(    ADDASS, "+=",           1, , , , ,1, , , , ,1, , , , , ,1, ,    1)
+op(    SUBASS, "-=",           1, , , , ,1, , , , ,1, , , , , ,1, ,    1)
+op(    SHLASS, "<<=",          1, ,1, , , , , , , ,1, , , , , ,1, ,    1)
+op(    SHRASS, ">>=",          1, ,1, , , , , , , ,1, , , , , ,1, ,    1)
+op(    ANDASS, "&=",           1, ,1, , , , , , , ,1, , , , , ,1, ,    1)
+op(    XORASS, "^=",           1, ,1, , , , , , , ,1, , , , , ,1, ,    1)
+op(    ORASS,  "|=",           1, ,1, , , , , , , ,1, , , , , ,1, ,    1)
+
+/*     name    repr            b l i c a s f v t b s l r p c e e =     act */
+op(    NAME,   "name",          , , , , , , , , , , , , , , , , , ,    1)
+op(    CON,    "const",         , , , , , , , , , , , , , , , , , ,    1)
+op(    STRING, "string",        , , , , , , , , , , , , , , , , , ,    1)
+op(    FSEL,   "fsel",          , , , , , , , , , , , , , , , , , ,    1)
+op(    CALL,   "call",         1, , , , , , , , , ,1, , , , , , , ,    1)
+op(    COMMA,  ",",            1, , , , , , , , , , , , , , , , ,1,    1)
+op(    CVT,    "convert",       , , , , , , ,1, , , , , , , , , , ,    1)
+op(    ICALL,  "icall",        1, , , , , , , , , ,1, , , , , , , ,    1)
+op(    LOAD,   "load",          , , , , , , , , , , , , , , , , , ,    1)
+op(    PUSH,   "push",          , , , , , , ,1, , , , , , , , , , ,    1)
+op(    RETURN, "return",       1, , , , , , , , , ,1, , , , ,1, , ,    1)
+op(    REAL,   "real",          , , , , , , , , , , , , , , , , , ,    0)
+op(    IMAG,   "imag",          , , , , , , , , , , , , , , , , , ,    0)
+
 /* INIT, CASE and FARG are pseudo operators that don't appear in the tree. */
-op(    INIT,   "init",         1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,    1)
-op(    CASE,   "case",         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    0)
-op(    FARG,   "farg",         1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,    1)
 /*     name    repr            b l i c a s f v t b s l r p c e e =     act */
+op(    INIT,   "init",         1, , , , , , , , , , , , , , ,1, , ,    1)
+op(    CASE,   "case",          , , , , , , , , , , , , , , , , , ,    0)
+op(    FARG,   "farg",         1, , , , , , , , , , , , , , ,1, , ,    1)
+
 end_ops()
 
 #ifndef NOPS



Home | Main Index | Thread Index | Old Index