[Boost-bugs] [Boost C++ Libraries] #5566: Spirit.Lex converting a token to its value in a lexer semantic action fails

Subject: [Boost-bugs] [Boost C++ Libraries] #5566: Spirit.Lex converting a token to its value in a lexer semantic action fails
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-05-25 13:55:45


#5566: Spirit.Lex converting a token to its value in a lexer semantic action fails
-----------------------------------------+----------------------------------
 Reporter: Reko Tiira <reko@…> | Owner: djowel
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: spirit
  Version: Boost 1.46.1 | Severity: Problem
 Keywords: |
-----------------------------------------+----------------------------------
 Discussed this on #boost with heller and he said to post a bug report
 about the issue. Here's a test case that should apparently work fine:

 {{{
 #include <string>
 #include <vector>
 #include <boost/spirit/include/lex_lexertl.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
 #include <boost/spirit/include/phoenix_stl.hpp>

 namespace lex = boost::spirit::lex;

 template <typename Lexer>
 struct text_decorator_lexer : lex::lexer<Lexer>
 {
         text_decorator_lexer()
                 : tag_open("\\{\\{.+?\\}\\}")
                 , tag_close("\\{\\{\\/.+?\\}\\}")
                 , var("\\$\\$.+?\\$\\$")
                 , any(".")
         {
                 using boost::spirit::lex::_val;
                 using boost::phoenix::push_back;
                 using boost::phoenix::ref;

                 this->self
                         = tag_open [push_back(ref(tokens), _val)]
                         | tag_close [push_back(ref(tokens), _val)]
                         | var [push_back(ref(tokens), _val)]
                         | any [push_back(ref(tokens), _val)]
                         ;
         }

         std::vector<std::string> tokens;
         lex::token_def<std::string> tag_open, tag_close, var, any;
 };

 int main()
 {
         typedef lex::lexertl::token<const char*,
 boost::mpl::vector<std::string>, boost::mpl::false_> token_type;
         typedef lex::lexertl::actor_lexer<token_type> lexer_type;

         text_decorator_lexer<lexer_type> text_decorator_tokenizer;
         std::string input = "Hello {{b}}there{{/b}}, the time is
 $$time$$.";

         char const* first = input.c_str();
         char const* last = &first[input.size()];
         lex::tokenize(first, last, text_decorator_tokenizer);
 }
 }}}

 And the relevant part of the error is:

 {{{
 /opt/local/include/boost/spirit/home/phoenix/stl/container/container.hpp:492:40:
 error: no matching function for call to
 'std::vector<std::basic_string<char> >::push_back(const
 boost::variant<boost::detail::variant::over_sequence<boost::mpl::v_item<boost::iterator_range<const
 char*>, boost::mpl::v_item<std::basic_string<char>,
 boost::mpl::vector0<mpl_::na>, 1>, 1> >, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_>&)'
 /opt/local/include/boost/spirit/home/phoenix/stl/container/container.hpp:492:40:
 note: candidate is:
 /opt/local/include/gcc46/c++/bits/stl_vector.h:826:7: note: void
 std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp =
 std::basic_string<char>, _Alloc = std::allocator<std::basic_string<char>
>, std::vector<_Tp, _Alloc>::value_type = std::basic_string<char>]
 /opt/local/include/gcc46/c++/bits/stl_vector.h:826:7: note: no known
 conversion for argument 1 from 'const
 boost::variant<boost::detail::variant::over_sequence<boost::mpl::v_item<boost::iterator_range<const
 char*>, boost::mpl::v_item<std::basic_string<char>,
 boost::mpl::vector0<mpl_::na>, 1>, 1> >, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_,
 boost::detail::variant::void_, boost::detail::variant::void_>' to 'const
 value_type&'
 /opt/local/include/boost/spirit/home/phoenix/stl/container/container.hpp:492:40:
 error: return-statement with a value, in function returning 'void'
 [-fpermissive]
 }}}

 Tested with:

 gcc version 4.6.1 20110325 (prerelease) (GCC)
 gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5566>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC