[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

    For some reason Bison %union can not satisfy my needs, I checked out a post 
Hans Aberg saying class can replace union. I tried it in Bison v1.35, but it 
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 -o mbdy.o

mbd.o: mbd.c
 CC -c mbd.c -o mbd.o

 @rm *.o
 @rm lex.yy.c

    The error is at "cc -c lex.yy.c -o mbdl.o", it complains at such line in "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...

reply via email to

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