help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

%union problems


From: Varga-Háli Dániel
Subject: %union problems
Date: Fri, 15 May 2009 13:22:47 +0200

hello all,

I just started to get the grasp of bison and how to make it work with
flex. I have defined a struct in the grammar file similar to this:

typedef struct {
  char *mem1;
  char *mem2;
} where_cls;

The union includes it:
%union{
  ...
  where_cls aswhere;
}

This is pretty straightforward even to me. I ran flex and bison on the
files as fallows:
bison -d grammar.y && flex lex.lex
When trying to compile it I get an error: expected
specifier-qualifier-list before
The error points to the line in the grammar file where I have the
where_cls aswhere line in the union. I checked out the tab.c file and
I saw that the proper typedef and struct is there before defining the
union so I didn't quite understand. After looking at the tab.h file I
noticed that the union is also defined there but this time my structs
and such were not there. So after manually editing the tab.h file it
worked like a charm. I tried to prevent this kinda problem by creating
a new header file for my structs and custom things and then included
them in the prologue however my includes only appear in tab.c file and
not in tab.h file which would be required for proper functioning.

I must miss something, please if you have an idea how I could correct
this problem, let me know.

Daniel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]