Boost logo

Boost Users :

From: Olaf Peter (ope-devel_at_[hidden])
Date: 2008-03-21 15:59:14


Hello,

here my compile problem using phoenix (for use with spirit):

---8<---
template<typename ActionsT>
struct tag_keyword_action
{
     template <typename ScanT, typename Iter1T, typename Iter2T>
     struct result {
         typedef void type;
     };

     explicit tag_keyword_action( const ActionsT& action )
         : action( action )
     { }

     template <typename ScanT, typename Iter1T, typename Iter2T>
     void operator()( const ScanT& scan,
            const Iter1T& bgn, const Iter2T& end ) const
     {
         action.on_tag( // the real action / assign class
             std::string( bgn, end ), scan.first.get_position().line );
     }

     const ActionsT& action;
};

template<typename ActionsT>
struct ver_parser
{
     typedef ::phoenix::function<
         tag_keyword_action<ActionsT>
> keyword_tag_type;

     explicit ver_parser( const ActionsT& action )
         : tag_keyword( action )
     { }

     template <typename ScannerT>
     std::ptrdiff_t
     operator()(const ScannerT& scan, result_t& result) const
     {
         ...

         rule_t rule
             = lexeme_d[
                 ...
                 ][tag_keyword( var( scan ), arg1, arg2 )]
         ...
     }
     const keyword_tag_type tag_keyword;
};

template <typename ActionsT = parse_actions,
           typename ErrorHandlerT = parse_error_handler>
struct grammar :
     sp::grammar< grammar<ActionsT, ErrorHandlerT> >
{
     explicit grammar(const ActionsT& actions = ActionsT(),
                      const ErrorHandlerT& handler = ErrorHandlerT())
         : actions( actions ),
           error_handler( handler )
     { }

     template <typename ScannerT>
     struct definition
     {
         ...
         explicit definition( const grammar& self )
             : ver_p( self.actions )
         {
             ...
         }

         ...
         const sp::functor_parser<
             ver_parser<ActionsT> > ver_p;
     };
     ...
};
--->8---

The (beautified) error message is:

error: no matching function for call to
'boost::spirit::functor_parser<ver_parser<parse_actions>
>::functor_parser(const parse_actions&)'

candidates are:
boost::spirit::functor_parser<FunctorT>::functor_parser(const FunctorT&)
[with FunctorT = ver_parser<parse_actions>]

boost::spirit::functor_parser<FunctorT>::functor_parser() [with FunctorT
= ver_parser<parse_actions>]

boost::spirit::functor_parser<ver_parser<parse_actions>
>::functor_parser(const
boost::spirit::functor_parser<ver_parser<parse_actions> >&)

What is the correct syntax, is this way a good choice? I want to tag the
keyword in the given data files with their lines to display them in a
browser later.

Thanks,
Olaf


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net