delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/08/19:38:11

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Patch for BISON.SIM for C++
Date: 5 Aug 1997 06:34:22 GMT
Organization: The National Capital FreeNet
Lines: 69
Message-ID: <5s6hhe$p8f@freenet-news.carleton.ca>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet2.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp


I have noticed that if a bison file is compiled as C++ for use with
classes, say, it generates a pair of warnings about comparisons between
signed and unsigned. These can be a nuisance, and if you use -werror, worse.

Consequently I have come up with a simple patch that changes two lines of
BISON.SIM without altering the functionality, but that gets rid of the
warnings in C++.
The two lines are clearly marked by comments.

And just out of curiosity, what is BISON.HAI? It comes with BISON.SIM, but
it's only BISON.SIM that I've ever seen get incorporated into parsers by
Bison.

.
.
.
#ifdef YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (yyn > YYFLAG && yyn < YYLAST)
	{
	  int size = 0;
	  char *msg;
	  int x, count;

	  count = 0;
	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
	  for (x = (yyn < 0 ? -yyn : 0);
	       x < ((int)sizeof(yytname) / (int)sizeof(char *)); x++) /* (int) added by PGD to fix warnings when using C++ */
	    if (yycheck[x + yyn] == x)
	      size += strlen(yytname[x]) + 15, count++;
	  msg = (char *) malloc(size + 15);
	  if (msg != 0)
	    {
	      strcpy(msg, "parse error");

	      if (count < 5)
		{
		  count = 0;
		  for (x = (yyn < 0 ? -yyn : 0);
		       x < ((int)sizeof(yytname) / (int)sizeof(char *)); x++) /* (int) added by PGD to fix warnings when using C++ */
		    if (yycheck[x + yyn] == x)
		      {
			strcat(msg, count == 0 ? ", expecting `" : " or `");
			strcat(msg, yytname[x]);
			strcat(msg, "'");
			count++;
		      }
		}
	      yyerror(msg);
	      free(msg);
	    }
	  else
	    yyerror ("parse error; also virtual memory exceeded");
	}
      else
#endif /* YYERROR_VERBOSE */
	yyerror("parse error");
    }
.
.
.
--
    .*.  Where feelings are concerned, answers are rarely simple [GeneDeWeese]
 -()  <  When I go to the theater, I always go straight to the "bag and mix"
    `*'  bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019