Solved

Yacc union returns struct.

Posted on 1998-11-11
1
689 Views
Last Modified: 2012-05-04
Hi.I  am writing a program with lex and yacc. In lex I have two chars that I want to pass to yacc at the same time. However, because yylval is a union that is  impossible. However, I have read that one can use structs. How do you do this?I need some code. Thanks.  
0
Comment
Question by:laeuchli
1 Comment
 
LVL 3

Accepted Solution

by:
elfie earned 20 total points
Comment Utility
if you have your union which currently contains something like char text[100], why don't you change the char text into a struct, like

%union {
struct {
char first;
char second;
} bi

and refer the vars like yylval.bi.first
}
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now