error in source file... how to fix?

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

error in source file... how to fix?

Jens Kallup
# here is the g++ 5.4.0 output spirit V3 -templates 400 -used Qt5 framework
# see QString

/usr/include/boost/spirit/home/qi/nonterminal/rule.hpp:303: error: no
match for call to '(const function_type {aka const
boost::function<bool(boost::spirit::line_pos_iterator<__gnu_cxx::__normal_iterator<const
char*, std::__cxx11::basic_string<char> > >&, const
boost::spirit::line_pos_iterator<__gnu_cxx::__normal_iterator<const
char*, std::__cxx11::basic_string<char> > >&,
boost::spirit::context<boost::fusion::cons<Comment&,
boost::fusion::nil>, boost::fusion::vector0<> >&, const
boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space,
boost::spirit::char_encoding::standard> >&)>})
(boost::spirit::line_pos_iterator<__gnu_cxx::__normal_iterator<const
char*, std::__cxx11::basic_string<char> > >&, const
boost::spirit::line_pos_iterator<__gnu_cxx::__normal_iterator<const
char*, std::__cxx11::basic_string<char> > >&,
boost::spirit::qi::rule<boost::spirit::line_pos_iterator<__gnu_cxx::__normal_iterator<const
char*, std::__cxx11::basic_string<char> > >, Comment(),
boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space,
boost::spirit::char_encoding::standard> >, 0l>,
boost::spirit::unused_type, boost::spirit::unused_type>::context_type&,
const
boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space,
boost::spirit::char_encoding::ascii> >&)'
                  if (f(first, last, context, skipper))
                  ^

// ------------------------------------




#ifdef QT_CORE_LIB
#include "qmymainwindow.h"
#endif

#define BOOST_SPIRIT_USE_PHOENIX_V3
#define BOOST_SPIRIT_ACTIONS_ALLOW_ATTR_COMPAT

#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/home/support/iterators/line_pos_iterator.hpp>
#include <boost/spirit/repository/include/qi_confix.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
#include <boost/fusion/sequence/intrinsic/at_c.hpp>

#include <boost/fusion/include/adapt_struct.hpp>

#include <string>
#include <utility>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <exception>
#include <typeinfo>
#include <vector>
#include <exception>

int lineno = 1;

using namespace std;
using namespace boost::spirit;

namespace bs    = boost::spirit;
namespace ascii = boost::spirit::ascii;
namespace phx   = boost::phoenix;

using boost::spirit::ascii::space; // use the ASCII space parser
using boost::spirit::ascii::char_;
using boost::spirit::_val;

using boost::spirit::qi::skip;
using boost::spirit::qi::eoi;

using boost::phoenix::val;
using boost::phoenix::at_c;

typedef line_pos_iterator<std::string::const_iterator> Iterator;

struct get_line_f
{
     template <typename> struct result { typedef size_t type; };
     template <typename It> size_t operator()(It const& pos_iter) const
     {
         return get_line(pos_iter);
     }
};

struct Position
{
     Position()
         : beginLine(-1)
         , endLine(-1)
     {
     }

     size_t beginLine;
     size_t endLine;
};

struct Comment : public Position
{
     Comment()
     : Position()
     , text()
     {
     }

     std::vector<std::string> text;
     std::string source;
};

BOOST_FUSION_ADAPT_STRUCT(
     Comment,
     (std::vector<std::string>, text)
     (std::string, source)
     (size_t,      beginLine)
     (size_t,      endLine)
)

namespace dBaseParser
{
     QStringList strlist;
     int idx;

     Iterator _begin(strlist[idx].toStdString().begin());
     Iterator _end  (strlist[idx].toStdString().end  ());

     template <typename Iterator> //, typename Lexer>
     struct comment:
            public qi::grammar<Iterator, Comment(), qi::space_type>
     {
         comment() :
         comment::base_type(start)
         {
             c_comment     %= repository::confix("/*", "*/")[*(char_ -
"*/")];
             cpp_comment   %= repository::confix("//", eol |
eoi)[*(char_ - eol)];
             dbase_comment %= repository::confix("**", eol |
eoi)[*(char_ - eol)];

             comments
             %= *(c_comment | cpp_comment | dbase_comment);

             start = raw[ comments[at_c<0>(_val) = qi::_1] ]
                     [
                         at_c<1>(_val) =
phx::construct<std::string>(_begin, _end),
                         at_c<1>(_val) = get_line_(_begin),
                         at_c<2>(_val) = get_line_(_end  )
                     ]
             ;
         }

         boost::phoenix::function<get_line_f> get_line_;

         qi::rule<Iterator, Comment(), qi::space_type> start;

         qi::rule<Iterator, std::string()> c_comment;
         qi::rule<Iterator, std::string()> cpp_comment;
         qi::rule<Iterator, std::string()> dbase_comment;

         qi::rule<Iterator, std::vector<std::string>()> comments;
     };
}

using namespace dBaseParser;

bool InitParseText(QString text)
{
     dBaseParser::strlist.clear();
     dBaseParser::strlist = text.split("\n");

     for (int i = 0; i < strlist.count(); ++i)
     {
         dBaseParser::idx = i;
         dBaseParser::comment<Iterator> g;

         Iterator iter(strlist[i].toStdString().begin());
         Iterator end (strlist[i].toStdString().end  ());

         Comment comment;
         bool r = qi::phrase_parse(iter, end, g, space, comment);
         if (r && iter == end) {
             std::cout << comment.beginLine << comment.source << "\n";
             return true;
         }   else {
             std::cout << "Parsing failed\n";
             return false;
         }
     }
}

bool parseText(QString text, int mode)
{
     try {
         if (InitParseText(text)) {
             QMessageBox::information(w,"text parser","SUCCESS");
//          printer(dp::dast);
         }   else {
             QMessageBox::information(w,"text parser","ERROR");
         }
     }
     catch (exception& e) {
         QMessageBox::information(w,"parser error",e.what());
     }

     return 0;
}


------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

Re: error in source file... how to fix?

llonesmiz
Jens Kallup wrote
# here is the g++ 5.4.0 output spirit V3 -templates 400 -used Qt5 framework
# see QString

/usr/include/boost/spirit/home/qi/nonterminal/rule.hpp:303: error: no
match for call to '(const function_type {aka const
boost::function<bool(boost::spirit::line_pos_iterator<__gnu_cxx::__normal_iterator<const
char*, std::__cxx11::basic_string<char> > >&, const
boost::spirit::line_pos_iterator<__gnu_cxx::__normal_iterator<const
char*, std::__cxx11::basic_string<char> > >&,
boost::spirit::context<boost::fusion::cons<Comment&,
boost::fusion::nil>, boost::fusion::vector0<> >&, const
boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space,
boost::spirit::char_encoding::standard> >&)>})
(boost::spirit::line_pos_iterator<__gnu_cxx::__normal_iterator<const
char*, std::__cxx11::basic_string<char> > >&, const
boost::spirit::line_pos_iterator<__gnu_cxx::__normal_iterator<const
char*, std::__cxx11::basic_string<char> > >&,
boost::spirit::qi::rule<boost::spirit::line_pos_iterator<__gnu_cxx::__normal_iterator<const
char*, std::__cxx11::basic_string<char> > >, Comment(),
boost::proto::exprns_::expr<boost::proto::tagns_::tag::terminal,
boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space,
boost::spirit::char_encoding::standard> >, 0l>,
boost::spirit::unused_type, boost::spirit::unused_type>::context_type&,
const
boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space,
boost::spirit::char_encoding::ascii> >&)'
                  if (f(first, last, context, skipper))
                  ^
...
You forgot the most important part of the error message:

note: no known conversion for argument 4 from 'const boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::ascii> >' to 'const boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, boost::spirit::char_encoding::standard> >&'
Reply | Threaded
Open this post in threaded view
|

Re: error in source file... how to fix?

Jens Kallup
Hi,

This is the line that I modified: (qi::space)...
bool r = phrase_parse(iter, end, g, qi::space, comment);

The Compiler does his job, and create an executable (ELF).
But the all the input give me "ERROR" message.
What is wrong on the code?

Jens

Am 30.08.2016 um 11:07 schrieb llonesmiz:
> You forgot the most important part of the error message:
>
> note: no known conversion for argument 4 from 'const
> boost::spirit::qi::char_class<boost::spirit::tag::char_code&lt;boost::spirit::tag::space,
> boost::spirit::char_encoding::ascii> >' to 'const
> boost::spirit::qi::char_class<boost::spirit::tag::char_code&lt;boost::spirit::tag::space,
> boost::spirit::char_encoding::standard> >&'
>

------------------------------------------------------------------------------
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general