On 27 May 2009, at 20:52, Akim Demaille wrote:
You will be able to do that in Bison 2.6. A preview is available at
http://www.lrde.epita.fr/~akim/download/bison-2.4.266-4ff3b.tar.bz2
Using that version, you can use actual objects (not pointers to), as
in the attached sample file.
...
<variant.yy>
Looks nice, but I got linker errors - a header missing somewhere :-).
I used
bison variant.yy
gcc variant.tab.cc -o variant > error.txt 2>&1
bison --version
bison (GNU Bison) 2.4.266-4ff3b
with gcc of Xcode 3.1.2, Mac OS X 10.5.7 PPC G4:
gcc --version
powerpc-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5490)
Hans
Undefined symbols:
"std::allocator<char>::~allocator()", referenced from:
yylex() in ccsYmOkN.o
yylex() in ccsYmOkN.o
yylex() in ccsYmOkN.o
yylex() in ccsYmOkN.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::operator=(char const*)", referenced from:
yy::parser::yysyntax_error_(int, int)in ccsYmOkN.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string()", referenced from:
yy::parser::yysyntax_error_(int, int)in ccsYmOkN.o
std::basic_string<char, std::char_traits<char>, std::allocator<char> >&
yy::variant<8ul>::build<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >()in ccsYmOkN.o
"std::basic_ostream<char, std::char_traits<char> >& std::operator<<
<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&,
char)", referenced from:
yy::parser::yystack_print_() in ccsYmOkN.o
yy::parser::yy_reduce_print_(int) in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
yy::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
yy::position const&)in ccsYmOkN.o
yy::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
yy::position const&)in ccsYmOkN.o
yy::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
yy::location const&)in ccsYmOkN.o
yy::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
yy::location const&)in ccsYmOkN.o
yy::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
yy::location const&)in ccsYmOkN.o
yy::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
yy::location const&)in ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::stack_symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::stack_symbol_type> const&) constin
ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::stack_symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::stack_symbol_type> const&) constin
ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::symbol_type> const&) constin ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::symbol_type> const&) constin ccsYmOkN.o
void yy::parser::yy_destroy_<yy::parser::symbol_type>(char const*,
yy::parser::symbol_base_type<yy::parser::symbol_type>&) constin ccsYmOkN.o
void yy::parser::yy_destroy_<yy::parser::stack_symbol_type>(char const*,
yy::parser::symbol_base_type<yy::parser::stack_symbol_type>&) constin ccsYmOkN.o
yy::parser::yypush_(char const*, int, yy::parser::symbol_type&)in
ccsYmOkN.o
yy::parser::yypush_(char const*, yy::parser::stack_symbol_type&)in
ccsYmOkN.o
"std::cout", referenced from:
__ZSt4cout$non_lazy_ptr in ccsYmOkN.o
"___cxa_begin_catch", referenced from:
std::_Deque_base<yy::parser::stack_symbol_type,
std::allocator<yy::parser::stack_symbol_type>
>::_M_create_nodes(yy::parser::stack_symbol_type**,
yy::parser::stack_symbol_type**)in ccsYmOkN.o
std::_Deque_base<yy::parser::stack_symbol_type,
std::allocator<yy::parser::stack_symbol_type> >::_M_initialize_map(unsigned
long)in ccsYmOkN.o
std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >
>::_M_create_node(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)in ccsYmOkN.o
std::deque<yy::parser::stack_symbol_type,
std::allocator<yy::parser::stack_symbol_type>
>::_M_new_elements_at_front(unsigned long)in ccsYmOkN.o
std::deque<yy::parser::stack_symbol_type,
std::allocator<yy::parser::stack_symbol_type>
>::_M_new_elements_at_back(unsigned long)in ccsYmOkN.o
"std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char>
>::str() const", referenced from:
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
string_cast<int>(int const&)in ccsYmOkN.o
"___gxx_personality_v0", referenced from:
___gxx_personality_v0$non_lazy_ptr in ccsYmOkN.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::~basic_string()", referenced from:
yy::parser::yysyntax_error_(int, int)in ccsYmOkN.o
yylex() in ccsYmOkN.o
yylex() in ccsYmOkN.o
yylex() in ccsYmOkN.o
yylex() in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
void yy::variant<8ul>::destroy<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >()in ccsYmOkN.o
__gnu_cxx::new_allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >::destroy(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >*)in ccsYmOkN.o
"std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char,
std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char,
std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)", referenced from:
yy::parser::error(yy::location const&, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)in ccsYmOkN.o
yy::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
yy::position const&)in ccsYmOkN.o
std::ostream_iterator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, char, std::char_traits<char>
>::operator=(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)in ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::stack_symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::stack_symbol_type> const&) constin
ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::stack_symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::stack_symbol_type> const&) constin
ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::symbol_type> const&) constin ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::symbol_type> const&) constin ccsYmOkN.o
"std::__throw_bad_alloc()", referenced from:
__gnu_cxx::new_allocator<yy::parser::stack_symbol_type>::allocate(unsigned
long, void const*)in ccsYmOkN.o
__gnu_cxx::new_allocator<yy::parser::stack_symbol_type*>::allocate(unsigned
long, void const*)in ccsYmOkN.o
__gnu_cxx::new_allocator<std::_List_node<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > >::allocate(unsigned long,
void const*)in ccsYmOkN.o
"std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)",
referenced from:
__ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_$non_lazy_ptr
in ccsYmOkN.o
"std::_List_node_base::swap(std::_List_node_base&, std::_List_node_base&)",
referenced from:
std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >
>::swap(std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > >&)in ccsYmOkN.o
"operator new(unsigned long)", referenced from:
__gnu_cxx::new_allocator<yy::parser::stack_symbol_type>::allocate(unsigned
long, void const*)in ccsYmOkN.o
__gnu_cxx::new_allocator<yy::parser::stack_symbol_type*>::allocate(unsigned
long, void const*)in ccsYmOkN.o
__gnu_cxx::new_allocator<std::_List_node<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > >::allocate(unsigned long,
void const*)in ccsYmOkN.o
"std::ios_base::Init::Init()", referenced from:
__static_initialization_and_destruction_0(int, int)in ccsYmOkN.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::operator=(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)", referenced from:
yy::parser::parse() in ccsYmOkN.o
"std::ios_base::Init::~Init()", referenced from:
___tcf_0 in ccsYmOkN.o
"std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char>
>::~basic_ostringstream()", referenced from:
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
string_cast<int>(int const&)in ccsYmOkN.o
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
string_cast<int>(int const&)in ccsYmOkN.o
"std::basic_ostream<char, std::char_traits<char> >::operator<<(int)",
referenced from:
yy::parser::yystack_print_() in ccsYmOkN.o
yy::parser::yy_reduce_print_(int) in ccsYmOkN.o
yy::parser::yy_reduce_print_(int) in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
string_cast<int>(int const&)in ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::stack_symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::stack_symbol_type> const&) constin
ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::symbol_type> const&) constin ccsYmOkN.o
"std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned
int)", referenced from:
yy::parser::yy_reduce_print_(int) in ccsYmOkN.o
yy::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
yy::position const&)in ccsYmOkN.o
yy::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
yy::position const&)in ccsYmOkN.o
yy::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
yy::location const&)in ccsYmOkN.o
yy::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
yy::location const&)in ccsYmOkN.o
yy::operator<<(std::basic_ostream<char, std::char_traits<char> >&,
yy::location const&)in ccsYmOkN.o
"___cxa_rethrow", referenced from:
std::_Deque_base<yy::parser::stack_symbol_type,
std::allocator<yy::parser::stack_symbol_type>
>::_M_create_nodes(yy::parser::stack_symbol_type**,
yy::parser::stack_symbol_type**)in ccsYmOkN.o
std::_Deque_base<yy::parser::stack_symbol_type,
std::allocator<yy::parser::stack_symbol_type> >::_M_initialize_map(unsigned
long)in ccsYmOkN.o
std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >
>::_M_create_node(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)in ccsYmOkN.o
std::deque<yy::parser::stack_symbol_type,
std::allocator<yy::parser::stack_symbol_type>
>::_M_new_elements_at_front(unsigned long)in ccsYmOkN.o
std::deque<yy::parser::stack_symbol_type,
std::allocator<yy::parser::stack_symbol_type>
>::_M_new_elements_at_back(unsigned long)in ccsYmOkN.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string(char const*, std::allocator<char> const&)", referenced from:
yylex() in ccsYmOkN.o
yylex() in ccsYmOkN.o
"std::basic_ostream<char, std::char_traits<char>
>::operator<<(std::basic_ostream<char, std::char_traits<char> >&
(*)(std::basic_ostream<char, std::char_traits<char> >&))", referenced from:
yy::parser::error(yy::location const&, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)in ccsYmOkN.o
yy::parser::yystack_print_() in ccsYmOkN.o
yy::parser::yy_reduce_print_(int) in ccsYmOkN.o
yy::parser::yy_reduce_print_(int) in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
void yy::parser::yy_destroy_<yy::parser::symbol_type>(char const*,
yy::parser::symbol_base_type<yy::parser::symbol_type>&) constin ccsYmOkN.o
void yy::parser::yy_destroy_<yy::parser::stack_symbol_type>(char const*,
yy::parser::symbol_base_type<yy::parser::stack_symbol_type>&) constin ccsYmOkN.o
yy::parser::yypush_(char const*, int, yy::parser::symbol_type&)in
ccsYmOkN.o
yy::parser::yypush_(char const*, yy::parser::stack_symbol_type&)in
ccsYmOkN.o
"std::cerr", referenced from:
__ZSt4cerr$non_lazy_ptr in ccsYmOkN.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::compare(std::basic_string<char, std::char_traits<char>, std::allocator<char>
> const&) const", referenced from:
bool std::operator!=<char, std::char_traits<char>, std::allocator<char>
>(std::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >
const&)in ccsYmOkN.o
"vtable for __cxxabiv1::__class_type_info", referenced from:
typeinfo for yy::parserin ccsYmOkN.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::basic_string(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)", referenced from:
yy::variant<8ul>::variant<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)in ccsYmOkN.o
__gnu_cxx::new_allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >::construct(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)in ccsYmOkN.o
"std::_List_node_base::hook(std::_List_node_base*)", referenced from:
std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >
>::_M_insert(std::_List_iterator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)in ccsYmOkN.o
"std::allocator<char>::allocator()", referenced from:
yylex() in ccsYmOkN.o
yylex() in ccsYmOkN.o
"std::basic_ostream<char, std::char_traits<char> >& std::operator<<
<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&,
char const*)", referenced from:
yy::parser::error(yy::location const&, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)in ccsYmOkN.o
yy::parser::yystack_print_() in ccsYmOkN.o
yy::parser::yy_reduce_print_(int) in ccsYmOkN.o
yy::parser::yy_reduce_print_(int) in ccsYmOkN.o
yy::parser::yy_reduce_print_(int) in ccsYmOkN.o
yy::parser::yy_reduce_print_(int) in ccsYmOkN.o
yy::parser::yy_reduce_print_(int) in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
yy::parser::parse() in ccsYmOkN.o
std::ostream_iterator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, char, std::char_traits<char>
>::operator=(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)in ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::stack_symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::stack_symbol_type> const&) constin
ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::stack_symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::stack_symbol_type> const&) constin
ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::stack_symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::stack_symbol_type> const&) constin
ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::stack_symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::stack_symbol_type> const&) constin
ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::symbol_type> const&) constin ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::symbol_type> const&) constin ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::symbol_type> const&) constin ccsYmOkN.o
void
yy::parser::yy_print_<yy::parser::symbol_type>(std::basic_ostream<char,
std::char_traits<char> >&,
yy::parser::symbol_base_type<yy::parser::symbol_type> const&) constin ccsYmOkN.o
void yy::parser::yy_destroy_<yy::parser::symbol_type>(char const*,
yy::parser::symbol_base_type<yy::parser::symbol_type>&) constin ccsYmOkN.o
void yy::parser::yy_destroy_<yy::parser::stack_symbol_type>(char const*,
yy::parser::symbol_base_type<yy::parser::stack_symbol_type>&) constin ccsYmOkN.o
yy::parser::yypush_(char const*, int, yy::parser::symbol_type&)in
ccsYmOkN.o
yy::parser::yypush_(char const*, yy::parser::stack_symbol_type&)in
ccsYmOkN.o
"std::basic_ostringstream<char, std::char_traits<char>, std::allocator<char>
>::basic_ostringstream(std::_Ios_Openmode)", referenced from:
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
string_cast<int>(int const&)in ccsYmOkN.o
"operator delete(void*)", referenced from:
yy::parser::~parser()in ccsYmOkN.o
yy::parser::~parser()in ccsYmOkN.o
yy::parser::~parser()in ccsYmOkN.o
__gnu_cxx::new_allocator<yy::parser::stack_symbol_type*>::deallocate(yy::parser::stack_symbol_type**,
unsigned long)in ccsYmOkN.o
__gnu_cxx::new_allocator<yy::parser::stack_symbol_type>::deallocate(yy::parser::stack_symbol_type*,
unsigned long)in ccsYmOkN.o
__gnu_cxx::new_allocator<std::_List_node<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >
>::deallocate(std::_List_node<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > >*, unsigned long)in ccsYmOkN.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::swap(std::basic_string<char, std::char_traits<char>, std::allocator<char>
>&)", referenced from:
void std::swap<char, std::char_traits<char>, std::allocator<char>
>(std::basic_string<char, std::char_traits<char>, std::allocator<char> >&,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)in
ccsYmOkN.o
"___cxa_end_catch", referenced from:
std::_Deque_base<yy::parser::stack_symbol_type,
std::allocator<yy::parser::stack_symbol_type>
>::_M_create_nodes(yy::parser::stack_symbol_type**,
yy::parser::stack_symbol_type**)in ccsYmOkN.o
std::_Deque_base<yy::parser::stack_symbol_type,
std::allocator<yy::parser::stack_symbol_type> >::_M_initialize_map(unsigned
long)in ccsYmOkN.o
std::list<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >
>::_M_create_node(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)in ccsYmOkN.o
std::deque<yy::parser::stack_symbol_type,
std::allocator<yy::parser::stack_symbol_type>
>::_M_new_elements_at_front(unsigned long)in ccsYmOkN.o
std::deque<yy::parser::stack_symbol_type,
std::allocator<yy::parser::stack_symbol_type>
>::_M_new_elements_at_back(unsigned long)in ccsYmOkN.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison