help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

specifying a C++ template class parse-param


From: galexander2
Subject: specifying a C++ template class parse-param
Date: Thu, 14 Dec 2006 01:20:41 -0500

I'm using Bison to generate a parser that I compile with g++.  I'm using
using the default Bison skeleton, not the Bison C++ skeleton.

I would like to pass a reference to a C++ template class, such as A<T>&
a where T is the template parameter, to yyparse.  I specify

  %parse-param {A<T>& a}

in my Bison input.  The problem is that any function that has the
parse-params as parameters must
be defined as a template function on T.  With Bison 2.1, the only
generated function that takes parse-params as parameters is yyparse. 
So, I use an awk script to add "template <T>" to the definitions of
yyparse in the generated Bison parser.  This works fine.

With Bison 2.3, the generated functions yy_symbol_value_print,
yy_symbol_print, yy_reduce_print, and yy_destruct now have the
parse-params as parameters in addition to yyparse.  So I now have to
update my awk script to define these functions as template functions on T.

Before making the update to my awk script, I thought I'd ask if anyone
has a better idea on how to handle a C++ template class parse-param.  In
particular, it would be great if there was a way to have Bison
automatically make functions taking parse-parm parameters template
functions on T, so I wouldn't need to modify Bison generated code. Would
using Bison's C++ skeleton help?

Thanks,
Geoff Alexander




reply via email to

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