|Including bison parser into C++ email@example.com (2001-06-14)|
|Re: Including bison parser into C++ firstname.lastname@example.org (jacob navia) (2001-06-21)|
|Re: Including bison parser into C++ email@example.com (Tim Van Holder) (2001-06-21)|
|From:||Tim Van Holder <firstname.lastname@example.org>|
|Date:||21 Jun 2001 03:11:39 -0400|
|Posted-Date:||21 Jun 2001 03:11:39 EDT|
Joshua Earl Donahue wrote:
> What I am trying to do is include my bison parser into C++ I currently
> have the parser so that it will compile fine with the CC compiler and
> to include the parser into my program I just #include "y.tab.c". This
> works fine if I am just including it into an executable, i.e. the main
> program. but when I try to include it into a class that is included
> by the main program it says that all of the functions in y.tab.c are
> multiply defined. Any Ideas? Thanks
I'm surprised it's even working that well; the last time I tried
something similar, the C++ compiler choked on much of bison's output.
You're not #include'ing the .c file in more than one place, right?
Besides, #including the .c file will probably only work at the top
level (as it contains several #includes for standard headers, which
you don't want to appear withing a namespace/class/function), so
what's the gain of doing so (as opposed to simply linking in the
compiled source). Just compile y.tab.c, and link with the rest of
your program; include y.tab.h for token declarations and provide a
extern "C" int yyparse(void);
wherever you need to call the parser.
Using multiple parsers is trickier, but thanks to bison's renaming
should be easy enough, provided you don't need to use multiple
grammars with %union statements in a single source file (as bison does
NOT rename the YYSTYPE macro).
Hope this helps.
Tim Van Holder - Anubex N.V.
Return to the
Search the comp.compilers archives again.