Subject: Bug in byacc/cygwin32
From: [email-masked] (Skip Egdorf)

14 Nov 1996 17:50:34 -0800
Sender: [email-masked]
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Original-To: [email-masked]
Original-Cc: [email-masked], [email-masked]
Original-Sender: [email-masked]

Windows-95, Pentium, Beta-16

A %union in a yacc grammer produces bad output from byacc.
I suspect that the problem lies with buffers being output
at the wrong times in cygwin32 rather than a bug in byacc
itself, but I only have the cygwin32 version of byacc to try...
I have reproduced this in two large grammers. Here is a
small case.

this grammer produces correct output:
---
%{
extern int yylex ();
extern void yyerror (char *);
%}

%token A B

%%

test_program:		test_program_sequence
		;
test_program_sequence:	test_program_sequence stmt
		|	/* empty */
		;
stmt:			A
		|	B
		;

%%
---

Adding a %union:
---
%{
extern int yylex ();
extern void yyerror (char *);
%}

%union 
	{
	long INTEGER;
	double FLOAT;
	}

%token A B

%%

test_program:		test_program_sequence
		;
test_program_sequence:	test_program_sequence stmt
		|	/* empty */
		;
stmt:			A
		|	B
		;

%%
---
and compiling with "byacc -d -o test.c test.y"
causes errors in the .c andf .h files. Here is the
..h file from the grammer above:
---
#define A 257
#define B 258
typedef union 
	{
	long INTEGER;
	double FLOAT;
	}yerror (char *);
#line 6 "test1.y"
typedef union 
	{
	long INTEGER;
	double FLOAT;
	} YYSTYPE;
 YYSTYPE;
extern YYSTYPE yylval;
---
Note that the %union generates two typedefs, with the first
walking onto the user-code in the grammer. e.g. the "yerror (char *)"
at the end of the irst typedef is a fragment of the code from
%{
extern int yylex ();
extern void yyerror (char *);
%}

					Skip Egdorf
					[email-masked]
-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".