[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bison 1.35:class replacing union?
From: |
Jibin Han |
Subject: |
Bison 1.35:class replacing union? |
Date: |
Wed, 12 Feb 2003 22:43:39 -0700 |
Hi,
For some reason Bison %union can not satisfy my needs, I checked out a post
by
Hans Aberg saying class can replace union. I tried it in Bison v1.35, but it
could
not get through. The problem lies on YYSTYPE.
My Bison file is like this,
%{
... some include...
class my_parser_type{
string str;
vector<my_class> vec;
map<string, string> m;
};
#define YYSTYPE my_parser_type
%}
Then in the %type section, I declare the non-terminals as , for example,
"%type <vec> values".
The following is my Makefile, here CC is C++ compiler and cc is C compiler:
all: mbdy.o mbdl.o mbd.o
CC -I/. mbdy.o mbdl.o mbd.o -o mbd
mbdl.o: mbd.l
flex mbd.l
cc -c lex.yy.c -o mbdl.o
mbdy.o: mbd++.y
bison -dv mbd++.y
CC -c mbd++.tab.c -o mbdy.o
mbd.o: mbd.c
CC -c mbd.c -o mbd.o
clean:
@rm *.o
@rm lex.yy.c
@rm mbd++.tab.h
@rm mbd++.tab.c
The error is at "cc -c lex.yy.c -o mbdl.o", it complains at such line in
mbd++.tab.h: "extern YYSTYPE yylval;" for syntax error. If I change "cc" to "CC"
for this command, it still complains the same thing for "YYSTYPE undefined".
I am really confused...