www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/10/09/09:47:56

X-Originating-IP: [24.27.64.187]
From: "Thomas Hutto" <huttothomas AT hotmail DOT com>
To: djgpp AT delorie DOT com
Subject: Re: Newbie needs Bison help
Date: Tue, 09 Oct 2001 08:43:45 -0500
Mime-Version: 1.0
Message-ID: <F196ot0OUIHNkjgJKVA0000098a@hotmail.com>
X-OriginalArrivalTime: 09 Oct 2001 13:43:45.0908 (UTC) FILETIME=[6AD48B40:01C150C8]
Reply-To: djgpp AT delorie DOT com

See below for original question and a reasonable attempt to answer it.

bison -l -d -t -v -oreg.parser.c reg.y
I had the -d option turned on originally.

When I #include reg.parser.h I get a compiler error complaining about 
YYSTYPE being defined twice.  And sure enough *.h has a definition for 
YYSTYPE and so does *.c.

The only solution that I have found so far is to edit the *.c file to put 
prototype for yyparse immediately following the declartion for the typedef 
union {stuff} YYSTYPE; statement.

A workable but nasty solution.

>From: eplmst AT lu DOT erisoft DOT se (Martin Stromberg)
>Reply-To: djgpp AT delorie DOT com
>To: djgpp AT delorie DOT com
>Subject: Re: Newbie needs Bison help
>Date: 9 Oct 2001 12:04:46 GMT
>
>Thomas Hutto (huttothomas AT hotmail DOT com) wrote:
>: I've RTFM'd till I'm sick.  So maybe there is some help out there, pretty
>: please?
>
>: Need to implement YYPRINT.
>: So in the C-section add
>
>: #define YYDEBUG 1
>: #define YYPRINT(a,b,c) yyprint(a,b,c)
>
>: In the Bisson types section I must have
>: %union
>: {
>:   char rxch;
>:   int  rxint
>:   str  rxstr;
>: }   for the YYSTACK's type.
>
>: Which yields a
>
>: typedef union {
>:   char rxch;
>:   int  rxint
>:   str  rxstr;
>: }YYSTYPE;
>
>: in the parser code _AFTER_ the stuff from the C-Section.
>
>: This means that when I prototype my
>
>: stactic void yyprint(FILE *F, int type, YYSTYPE value);
>
>: function the compiler complains because it has not yet seen the typedef 
>for
>: the union.
>
>: Anyway to make Bisson behave other than directly editing the generated
>: C-Code (y.tab.c)?  Have a hunch that TFM left off a critical step and I'm
>: not good enough at C-Code to figure what it is.
>
>: I tried to cobble up a forward declaration for the union without success.
>
>Try the "-d" option to bison and #include "y.tab.h" in the C section.
>
>
>Right,
>
>						MartinS


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

- Raw text -


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