🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #2231

cplus-parse.y mentions yytname and yyrline even when YYDEBUG==0

#2231
From: Paul Eggert
Date: Fri, 02 Mar 1990 00:08
68 lines
2503 bytes
GNU C++ 1.37.0's cplus-parse.y refers to the variables yyrline and yytname
even when the YYDEBUG flag is zero.  In some versions of Bison, these
variables are not present unless YYDEBUG is nonzero, because the parser needs
them only when in debugging mode.  Here is a fix.

*** old/cplus-parse.y	The Mar  1 16:00:25 1990
--- new/cplus-parse.y	Thu Mar  1 16:00:12 1990
***************
*** 3087,3093 ****
  static int *token_count;
  
  #define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0]))
! #define TOKEN_LENGTH (256 + sizeof (yytname) / sizeof (yytname[0]))
  
  int *
  init_parse ()
--- 3087,3093 ----
  static int *token_count;
  
  #define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0]))
! #define TOKEN_LENGTH (256 + YYNTBASE + 1)
  
  int *
  init_parse ()
***************
*** 3147,3154 ****
  	break;
        if (token_count[index] < token_count[-1])
  	break;
!       fprintf (stderr, "token %d, `%s', count = %d\n",
! 	       index, yytname[YYTRANSLATE (index)], token_count[index]);
      }
    fprintf (stderr, "\n");
    for (i = 0; i < REDUCE_LENGTH; i++)
--- 3147,3157 ----
  	break;
        if (token_count[index] < token_count[-1])
  	break;
!       fprintf (stderr, "token %d", index);
! #if YYDEBUG
!       fprintf (stderr, ", `%s'", yytname[YYTRANSLATE (index)]);
! #endif
!       fprintf (stderr, ", count = %d\n", token_count[index]);
      }
    fprintf (stderr, "\n");
    for (i = 0; i < REDUCE_LENGTH; i++)
***************
*** 3161,3168 ****
  	break;
        if (reduce_count[index] < reduce_count[-1])
  	break;
!       fprintf (stderr, "rule %d, line %d, count = %d\n",
! 	       index, yyrline[index], reduce_count[index]);
      }
    fprintf (stderr, "\n");
  }
--- 3164,3174 ----
  	break;
        if (reduce_count[index] < reduce_count[-1])
  	break;
!       fprintf (stderr, "rule %d", index);
! #if YYDEBUG
!       fprintf (stderr, ", line %d", yyrline[index]);
! #endif
!       fprintf (stderr, ", count = %d\n", reduce_count[index]);
      }
    fprintf (stderr, "\n");
  }
Technical Details
Message-ID: <9003020008.AA06524@ata.twinsun.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!twinsun.com!eggert

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!twinsun.com!eggert
From: eggert@twinsun.com (Paul Eggert)
Newsgroups: gnu.g++.bug
Subject: cplus-parse.y mentions yytname and yyrline even when YYDEBUG==0
Message-ID: <9003020008.AA06524@ata.twinsun.com>
Date: 2 Mar 90 00:08:13 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 68