473,396 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Bison: Problem with %union

1
Hi! I've included some of my classes in the union in my grammar file:
Expand|Select|Wrap|Line Numbers
  1. %union
  2. {
  3.     int int_type;
  4.     char* string_type;
  5.     PNode* pNode;
  6. }
  7.  
  8. %type <int_type>     programs 
  9. %type <pNode>           program
  10.  
Using 'Bison -d program.ypp', what happens is Bison places this in both .hpp and .cpp generated files as
Expand|Select|Wrap|Line Numbers
  1. typedef union YYSTYPE {
  2.     int int_type;
  3.     char* string_type;
  4.     PNode* pNode;
  5. } YYSTYPE;
  6.  
The problem is the .hpp file doesn't have the #include "PNode.h" that it needs to make sense of PNode* so it produces errors. When I try to put #include "PNode.h" in the .hpp file I get a hundred errors like this:

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cstdio(17) : error C2143: syntax error : missing '{' before ':'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cstdio(17) : error C2059: syntax error : ':'

Removing this part from the the .hpp file will also produce errors.

I'm using VS2003, Bison 2.1 and Flex 2.5.4a. I hope someone can help me with this. Thanks.
Sep 7 '07 #1
1 3142
weaknessforcats
9,208 Expert Mod 8TB
The problem is the .hpp file doesn't have the #include "PNode.h" that it needs to make sense of PNode* so it produces errors. When I try to put #include "PNode.h" in the .hpp file I get a hundred errors like this:

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cstdio(17) : error C2143: syntax error : missing '{' before ':'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\cstdio(17) : error C2059: syntax error : ':'
You can use a forward reference:
Expand|Select|Wrap|Line Numbers
  1. class PNode;           //forward reference
  2. typedef union YYSTYPE {
  3.     int int_type;
  4.     char* string_type;
  5.     PNode* pNode;
  6. } YYSTYPE;
  7.  
This is enough informattion for the compiler to allow a PNode* variable.

As to theVisual Studio errors, I would need to se your PNode.h and also to see where you included it. That is, before or after the incluce to cstdio.

Typically errors like this are caused by a) a missing semi-colon after a class/struct/union declaration or b) failing to have a null line as the last line of the header file.
Sep 7 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: RP | last post by:
Hello All, I have a strange problem with a UNION of 3 queries. The 3 separate select-queries return (at this point) respectively 4, 3 an zero rows, but the UNION returns no rows at all. When I...
2
by: MC | last post by:
Hi to all, I'm working with DB2 on iSeries V5R3 I would like to know if this kind of SQL statement is possible : select col1, count(col2) from TABLE where col2 in (select1 union select2). ...
2
by: Adam Louis | last post by:
Hi, I'm running a query unifying two relatively simple selections. The problem is that each selection, on its own, completes instantaneously, but, unified, the processing takes upwards of 30...
5
by: Andy Kent | last post by:
What's the syntax for combining INTO and UNION clauses? What I want to do is: SELECT blah INTO newtable FROM oldtable1 WHERE <conditions> UNION SELECT blah
0
by: RSN | last post by:
I hav a query that uses a union of 16 tables to get some counts and i need to get the end result as a Group by. This is inside a sub-query that has the count(*) ans the attribute for the group-by in...
7
sharijl
by: sharijl | last post by:
I have a SQL query which returns the total amount of issues: SELECT issue,Count(issue) as total FROM mytable Group by issue This works but I need the total of the same catagory in three tables...
5
by: ilikebirds | last post by:
Is it possible to create a union query that contains criteria from another union query? I would like the query to only display the order numbers from TeamUnions that are either contained in...
5
by: tasawer | last post by:
I need some assistance with SQL query. I will be grateful if you can provide help please. I have a database that records details of a road traffic accident and name of driver. sub-form records...
8
by: Amy Badgett | last post by:
The purpose of this query is to return seven different Counts for these 14 different EIDs (employee IDs). The problem is that only 8 of the EIDs are returned: 123, 122, 108, 164, 131, 136, 138, 150....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.