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 grammar compatible with Bison



details:   https://anonhg.NetBSD.org/src/rev/1f1a45c282fc
branches:  trunk
changeset: 365869:1f1a45c282fc
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Apr 29 22:44:44 2022 +0000

description:
lint: make grammar compatible with Bison

Bison and BSD Yacc differ in how they translate the grammar into C code.

Bison:
        code above '%union' (YYDEBUG is either undefined or 1)
        #include "cgram.h" (which defines YYDEBUG to 0 if undefined)
        code from below '%union' until the first '%%'
        actions
        code below the second '%%'

BSD Yacc:
        code above the first '%%' (YYDEBUG is either undefined or 1)
        (no #include for "cgram.h")
        define YYDEBUG to 0 if undefined
        code below the second '%%' (YYDEBUG is either 0 or 1)
        actions

The easiest way around these differences is to remove the 'defined(...)'
around the conditionals YYDEBUG, YYBISON and YYBYACC.

diffstat:

 usr.bin/xlint/lint1/cgram.y |  15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diffs (60 lines):

diff -r 0697f83e0867 -r 1f1a45c282fc usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Fri Apr 29 22:17:49 2022 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Fri Apr 29 22:44:44 2022 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.406 2022/04/29 19:37:00 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.407 2022/04/29 22:44:44 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.406 2022/04/29 19:37:00 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.407 2022/04/29 22:44:44 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -117,10 +117,10 @@
                s->u.s_member.sm_sou_type = NULL;
 }
 
-#if defined(YYDEBUG) && (defined(YYBYACC) || defined(YYBISON))
+#if YYDEBUG && (YYBYACC || YYBISON)
 #define YYSTYPE_TOSTRING cgram_to_string
 #endif
-#if defined(YYDEBUG) && defined(YYBISON)
+#if YYDEBUG && YYBISON
 #define YYPRINT cgram_print
 #endif
 
@@ -363,7 +363,7 @@
 %type  <y_in_system_header> sys
 
 %{
-#if defined(YYDEBUG) && defined(YYBISON)
+#if YYDEBUG && YYBISON
 static inline void cgram_print(FILE *, int, YYSTYPE);
 #endif
 %}
@@ -2177,8 +2177,7 @@
        return 0;
 }
 
-#if (defined(YYDEBUG) && YYDEBUG > 0 && defined(YYBYACC)) \
-    || (defined(YYDEBUG) && defined(YYBISON))
+#if YYDEBUG && (YYBYACC || YYBISON)
 static const char *
 cgram_to_string(int token, YYSTYPE val)
 {
@@ -2207,7 +2206,7 @@
 }
 #endif
 
-#if defined(YYDEBUG) && defined(YYBISON)
+#if YYDEBUG && YYBISON
 static inline void
 cgram_print(FILE *output, int token, YYSTYPE val)
 {



Home | Main Index | Thread Index | Old Index