[VC7.1/B_1_33] Newbie: problem compiling small sample

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[VC7.1/B_1_33] Newbie: problem compiling small sample

Daniel Lidström
Hi,

I'm using VC 7.1 and am trying to compile a simple sample, with a grammar
and file_iterator, as well as a simple line parser. The compilation fails
with these error messages:

p:\boost_1_33_0\include\boost-1_33\boost\spirit\core\non_terminal\impl\rule.
ipp(190): error C2664:
'boost::spirit::impl::abstract_parser<ScannerT,AttrT>::do_parse_virtual':
cannot convert parameter 1 from 'const scanner_t' to 'const
boost::spirit::rule<>::scanner_t &'
    with
    [
        ScannerT=boost::spirit::rule<>::scanner_t,
        AttrT=boost::spirit::rule<>::attr_t
    ]
    Reason: cannot convert from 'const scanner_t' to 'const
boost::spirit::rule<>::scanner_t'
    No constructor could take the source type, or constructor overload
resolution was ambiguous
 
p:\boost_1_33_0\include\boost-1_33\boost\spirit\core\non_terminal\impl\rule.
ipp(172): see reference to function template instantiation
'boost::spirit::parser_result<ParserT,ScannerT>::type
boost::spirit::impl::rule_base<DerivedT,EmbedT,T0,T1,T2>::parse_main<Scanner
T>(const ScannerT &) const' being compiled
    with
    [
        ParserT=boost::spirit::rule<>,
        ScannerT=scanner_t,
        DerivedT=boost::spirit::rule<>,
        EmbedT=const boost::spirit::rule<> &,
        T0=boost::spirit::nil_t,
        T1=boost::spirit::nil_t,
        T2=boost::spirit::nil_t
    ]
 
p:\boost_1_33_0\include\boost-1_33\boost\spirit\core\scanner\impl\skipper.ip
p(132): see reference to function template instantiation
'boost::spirit::parser_result<ParserT,ScannerT>::type
boost::spirit::impl::rule_base<DerivedT,EmbedT,T0,T1,T2>::parse<scanner_t>(c
onst ScannerT &) const' being compiled
    with
    [
        ParserT=boost::spirit::rule<>,
        ScannerT=scanner_t,
        DerivedT=boost::spirit::rule<>,
        EmbedT=const boost::spirit::rule<> &,
        T0=boost::spirit::nil_t,
        T1=boost::spirit::nil_t,
        T2=boost::spirit::nil_t
    ]
 
p:\boost_1_33_0\include\boost-1_33\boost\spirit\core\scanner\impl\skipper.ip
p(155): see reference to function template instantiation
'boost::spirit::parse_info<>
boost::spirit::impl::phrase_parser<boost::spirit::space_parser>::parse<Itera
torT,DerivedT>(const IteratorT &,const IteratorT &,const ParserT &,const
boost::spirit::space_parser &)' being compiled
    with
    [
        IteratorT=const char *,
        DerivedT=boost::spirit::rule<>,
        ParserT=boost::spirit::rule<>
    ]
 
p:\boost_1_33_0\include\boost-1_33\boost\spirit\core\scanner\impl\skipper.ip
p(173): see reference to function template instantiation
'boost::spirit::parse_info<> boost::spirit::parse<const CharT
*,DerivedT,boost::spirit::space_parser>(const IteratorT &,const IteratorT
&,const boost::spirit::parser<DerivedT> &,const
boost::spirit::parser<boost::spirit::space_parser> &)' being compiled
    with
    [
        CharT=char,
        DerivedT=boost::spirit::rule<>,
        IteratorT=const char *
    ]
    c:\Programming\boost_test\boost_test.cpp(112): see reference to function
template instantiation 'boost::spirit::parse_info<>
boost::spirit::parse<char,DerivedT,boost::spirit::space_parser>(const CharT
*,const boost::spirit::parser<DerivedT> &,const
boost::spirit::parser<boost::spirit::space_parser> &)' being compiled
    with
    [
        DerivedT=boost::spirit::rule<>,
        CharT=char
    ]

Here's the source file. Line 48 and line 111 seems to cause errors. If I
comment out line
111, I get errors referring to line 48 instead (boost_test.cpp(48): error
C2784: 'basic_ostream<_Elem,_Tr> &operator <<(basic_ostream<_Elem,_Tr>
&,const bitset<_Bits> &)': could not deduce template argument for
'basic_ostream<_Elem,_Traits> &' from 'const boost::spirit::int_parser<T>').


#include <boost/spirit.hpp>
#include <iostream>
#include <vector>

////////////////////////////////////////////////////////////////////////////
///
using namespace boost::spirit;

////////////////////////////////////////////////////////////////////////////
//
//  Types
//
////////////////////////////////////////////////////////////////////////////
typedef char                    char_t;
typedef file_iterator<char_t>   iterator_t;
typedef scanner<iterator_t>     scanner_t;
typedef rule<scanner_t>         rule_t;

////////////////////////////////////////////////////////////////////////////
//
//  Actions
//
////////////////////////////////////////////////////////////////////////////
void echo(iterator_t first, iterator_t const& last)
{
    while (first != last)
        std::cout << *first++;
}

////////////////////////////////////////////////////////////////////////////
//
// Grammar
//
////////////////////////////////////////////////////////////////////////////
namespace
{
   //! Grammar for REB format 66
   class reb66_grammar : public grammar<reb66_grammar>
   {
   public:

      template<typename ScannerT>
      class definition
      {
      public:
         definition(const reb66_grammar& self)
         {
/* 48 */    r = int_p << int_p << real_p << int_p << *(real_p && real_p);
         }
         const rule<ScannerT>& start() const { return r; }

      private:
         rule<ScannerT> r;
      };
   };
}

////////////////////////////////////////////////////////////////////////////
//
//  Main program
//
////////////////////////////////////////////////////////////////////////////
int
main(int argc, char* argv[])
{
   if (2 > argc)
   {
      std::cout << "Must specify a filename!\n";
      return -1;
   }

   // Create a file iterator for this file
   iterator_t first(argv[1]);

   if (!first)
   {
      std::cout << "Unable to open file!\n";
      return -1;
   }

   // Create an EOF iterator
   iterator_t last = first.make_end();

   // A simple rule
   rule_t r = *(anychar_p);

   // Grammar
   reb66_grammar g;

   // Parse
   parse_info <iterator_t> info = parse(
      first,
      last,
      g
      //r[&echo]
   );

   {
      // Parse character string
      int num, layer, n;
      double section;
      std::vector<double> offsets, heights;
      rule<> r
         =    int_p[assign_a(num)]
               && int_p[assign_a(layer)]
               && int_p[assign_a(section)]
               && int_p[assign_a(n)]
               && *(int_p[push_back_a(offsets)] &&
int_p[push_back_a(heights)]);

        const char* line = "66     42    60000 5    3382 207137    3383
207137    3582 207132    3787 206926";
/*112/* parse_info<> info = parse(line, r, space_p);
   }

   return 0;
}

What do I need to do to make this compile? Thanks in advance!

Daniel


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: [VC7.1/B_1_33] Newbie: problem compiling small sample

Joel de Guzman-2
Daniel Lidström wrote:
> Hi,
>
> I'm using VC 7.1 and am trying to compile a simple sample, with a grammar
> and file_iterator, as well as a simple line parser. The compilation fails
> with these error messages:
>
[...]

Hi Daniel,

Pardon the delay. I lost net connectivity when you posted.
I almost missed your post.

Ok... Please see FAQ 1: The scanner business.
http://tinyurl.com/733sd

Here's the problem code:

     rule<> r = ...;

     parse_info<> info = parse(line, r, space_p);

Cheers,
--
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general