delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/03/19/21:52:47

From: ajay AT avlinsun DOT avlin DOT stpn DOT soft DOT net (Ajay Gautam)
Subject: ** Bug - byacc : %union problem
19 Mar 1998 21:52:47 -0800 :
Message-ID: <Pine.GSO.3.96.980318113000.2042F-100000.cygnus.gnu-win32@avlinsun>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

hello friends,

I am new to this mailing list. I could not find a solution to this problem
in the faq.

I am using byacc distributed with Cygnus rel 18. Win NT workstation 4.0 is
my base OS. 

-------------------------
C:\>byacc -V
byacc: Berkeley Yacc (+Cygnus.28)
usage: byacc [-dlrtvV] [-Q[y|n]] [-b file_prefix] [-o outputfile] filename
---------------------------

Bug :  if i run byacc on a file that has a union defined, the header file
(created by the use of -d option)  contains some extra data that is not
required. Sample follows -

Yacc script :
-------------------------- Code Starts -----------------------------
%{
#include <stdlib.h>
#include <stdio.h>
%}

%union{
	char *pString;
}

%token NAME1 NAME2
%token <pString> DATASTRING

%%
stm	: TableRow
	  ;
TableRow : NAME1 DATASTRING NAME2 DATASTRING { printf("%s\t\t -> %s\n",
$2->pString, $4->pString); }
		   ;
%%

extern FILE *yyin;

main()
{
	yyin = fopen("input.file", "r");
	if (!yyin)
	{
		printf("File inp.atf could not be opened\n");
		return 1;
	}
	yyprase();
	return 0;
}
---------------------code end -------------------------------------

the above file generates the following header file :
----------------- header file starts --------------------------
#define NAME1 257
#define NAME2 258
#define DATASTRING 259
typedef union{
	char *pString;
}h>
#include <stdio.h>
#line 6 "try.y"
typedef union{
	char *pString;
} YYSTYPE;
 YYSTYPE;
extern YYSTYPE yylval;
------------------ header file ends -----------------------------

if i remove the %union declaration from the yacc source, the following
header is generated :
----------------- header file starts --------------------------
#define NAME1 257
#define NAME2 258
#define DATASTRING 259
------------------ header file ends -----------------------------

This yacc script when compiled with MKS_LEX system generates the
following header file :
----------------- header file starts --------------------------
typedef union {
	char *pString;
} YYSTYPE;
#define NAME1	257
#define NAME2	258
#define DATASTRING	259
extern YYSTYPE yyval, yylval;
------------------ header file ends -----------------------------

if this has already been fixed, please do tell me.

------------------------------------------------------------------------
Ajay Gautam                          ajay AT avlin DOT stpn DOT soft DOT net.
http://avlinsun.avlin.stpn.soft.net/~ajay (A very dirty page).

if u say what u think, don't expect to hear what u like.
------------------------------------------------------------------------


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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