Hi everybody. My name is Gilberto, I use the next tools:
- Flex: 2.5.35 - Bison: 3.0.2 ( C++ ) - OS: Linux 3.5.0-44-generic #67~precise1-Ubuntu SMP Wed Nov 13 16:16:57 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux - GCC: gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 I use Bison for C++, I get the following problem when I compile with gcc, I want to know if I am doing something wrong or it is a bug. It seems that bison duplicates the definition and declaration of a function: g++ -o parser location.hh position.hh rcss_parser.tab.cc lex.yy.c rcss_parser_driver.cpp -lfl In file included from rcss_parser_driver.h:16:0, from rcss_parser.y:15: rcss_parser.tab.hh:583:3: error: ‘yy::RcssParser::basic_symbol<Base>::basic_symbol(typename Base::kind_type, Playmode, const location_type&)’ cannot be overloaded rcss_parser.tab.hh:579:3: error: with ‘yy::RcssParser::basic_symbol<Base>::basic_symbol(typename Base::kind_type, Playmode, const location_type&)’ rcss_parser.tab.hh:1896:3: error: redefinition of ‘yy::RcssParser::basic_symbol<Base>::basic_symbol(typename Base::kind_type, Playmode, const location_type&)’ rcss_parser.tab.hh:1882:3: error: ‘yy::RcssParser::basic_symbol<Base>::basic_symbol(typename Base::kind_type, Playmode, const location_type&)’ previously declared here In file included from rcss_lexer.l:28:0: rcss_parser.tab.hh:583:3: error: ‘yy::RcssParser::basic_symbol<Base>::basic_symbol(typename Base::kind_type, Playmode, const location_type&)’ cannot be overloaded rcss_parser.tab.hh:579:3: error: with ‘yy::RcssParser::basic_symbol<Base>::basic_symbol(typename Base::kind_type, Playmode, const location_type&)’ rcss_parser.tab.hh:1896:3: error: redefinition of ‘yy::RcssParser::basic_symbol<Base>::basic_symbol(typename Base::kind_type, Playmode, const location_type&)’ rcss_parser.tab.hh:1882:3: error: ‘yy::RcssParser::basic_symbol<Base>::basic_symbol(typename Base::kind_type, Playmode, const location_type&)’ previously declared here In file included from rcss_parser_driver.h:16:0, from rcss_parser_driver.cpp:11: rcss_parser.tab.hh:583:3: error: ‘yy::RcssParser::basic_symbol<Base>::basic_symbol(typename Base::kind_type, Playmode, const location_type&)’ cannot be overloaded rcss_parser.tab.hh:579:3: error: with ‘yy::RcssParser::basic_symbol<Base>::basic_symbol(typename Base::kind_type, Playmode, const location_type&)’ rcss_parser.tab.hh:1896:3: error: redefinition of ‘yy::RcssParser::basic_symbol<Base>::basic_symbol(typename Base::kind_type, Playmode, const location_type&)’ rcss_parser.tab.hh:1882:3: error: ‘yy::RcssParser::basic_symbol<Base>::basic_symbol(typename Base::kind_type, Playmode, const location_type&)’ previously declared here I use variants, the next is on my grammar file: ... %skeleton "lalr1.cc" %require "3.0" /* The grammar is made to work on Bison 3.0 */ %language "C++" /* The output will be a c++ class */ %debug /* Debug mode */ %locations /* Gives an interface to access location information */ %defines /* */ %define parser_class_name {RcssParser} /* Name of the class generated by Bison */ %define api.token.constructor /* */ %define api.value.type variant /* Use a variant-based interface instead of unions */ %define parse.assert /* Enable assertions */ ... %token <Playmode> BEFORE_KICK_OFF %token <Playmode> TIME_OVER %token <Playmode> PLAY_ON ... %type < Playmode > playmode ... %% ... init: INIT side NUMBER playmode { driver.h_init_finished( $2, $3, $4 ); } ; playmode: BEFORE_KICK_OFF { $$ = $1; } | TIME_OVER { $$ = $1; } | PLAY_ON { $$ = $1; } ; And the tokens are defined as follows on my lexer file: ... "before_kick_off" { return yy::RcssParser::make_BEFORE_KICK_OFF( BeforeKickOff, loc); } "time_over" { return yy::RcssParser::make_TIME_OVER( TimeOver, loc); } "play_on" { return yy::RcssParser::make_PLAY_ON( PlayOn, loc); } ... I can attach the whole project if you want. Thanks in advance for the help.