help-bison
[Top][All Lists]
Advanced

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

Re: %union problems


From: Yinpeng Li
Subject: Re: %union problems
Date: Sat, 16 May 2009 12:19:23 +0800

Dear Daniel,

I think this problem is currently inherent of Bison. In the tab.h generated
by Bison, there are normally only three things that are incorporated:

1. The enumeration of the tokens
2. The YYSTYPE definition and yylval declaration
3. The YYLTYPE  definition and yylloc declaration

Notice that nothing else,  even the header files that you specify in the
first section of the .y file,  is incorporated. Thus, your problem can not
be eliminated by Bison itself.....

The way I dealt with this problem is as follows:

Suppose the header file generated by Bison is grammar.h. Now you write a new
header file structdef.h, including your where_cls definition. In the first
section of your lex.lex, you INCLUDE structdef.h BEFORE YOU INCLUDE
grammar.h.

THis causes the definition of your structure to appear in lex.yy.c before
the definition of YYSTYPE.


Yinpeng


reply via email to

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