#include <boost/spirit/core.hpp>
#include <boost/spirit/actor/push_back_actor.hpp>
#include <iostream>
#include <vector>
#include <string>
using namespace boost::spirit;
void fString(char const* first, char const* last)
{
std::string str(first, last);
std::cout << "String - " << str << "\n";
}
int main()
{
//boost::spirit::rule<const char*> rString, rStrVal, rEcho, rIf, rVariable, rCode;
boost::spirit::rule<> rString, rStrVal, rEcho, rIf, rVariable, rCode;
//strings
rString = (ch_p('"') >> rStrVal);
rStrVal = ch_p('"') | anychar_p >> rStrVal;
//variables
rVariable = ch_p('$') >> +( range_p('a','z') | range_p('a','z') | ch_p('_') | range_p('0','9') );
//echo command
rEcho = boost::spirit::str_p("echo ") >> ( rVariable | rString ) >> ch_p(';');
rCode = *rEcho;
std::cout << parse("echo \"aaaabbb\"; echo $qwe; ", rCode, space_p).full << "\n";
system("PAUSE");
return 0;
}
This program didn't work.
If i replace
parse("echo \"aaaabbb\"; echo $qwe; ", rCode, space_p)
and use
parse("echo \"aaaabbb\"; echo $qwe; ", rCode)
it works, but cant parse because string have unnecessary spaces :(
How compile with parse("echo \"aaaabbb\"; echo $qwe; ", rCode, space_p)???
boost::spirit help
I'm trying create simple parser, but have some troubles. Please help!
Quote:Original post by ToohrVyk
*sigh*
What does the compiler say about it?
Compiling...main.cppd:\tools\boost\1.33.1\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::scanner<> &' with [ ScannerT=boost::spirit::scanner<>, AttrT=boost::spirit::nil_t ] Reason: cannot convert from 'const scanner_t' to 'const boost::spirit::scanner<>' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called d:\tools\boost\1.33.1\boost\spirit\core\non_terminal\impl\rule.ipp(172) : see reference to function template instantiation 'boost::spirit::match<boost::spirit::nil_t> boost::spirit::impl::rule_base<DerivedT,EmbedT,T0,T1,T2>::parse_main<ScannerT>(const ScannerT &) const' being compiled with [ DerivedT=boost::spirit::rule<>, EmbedT=const boost::spirit::rule<> &, T0=boost::spirit::nil_t, T1=boost::spirit::nil_t, T2=boost::spirit::nil_t, ScannerT=scanner_t ] d:\tools\boost\1.33.1\boost\spirit\core\scanner\impl\skipper.ipp(132) : see reference to function template instantiation 'boost::spirit::match<boost::spirit::nil_t> boost::spirit::impl::rule_base<DerivedT,EmbedT,T0,T1,T2>::parse<scanner_t>(const ScannerT &) const' being compiled with [ DerivedT=boost::spirit::rule<>, EmbedT=const boost::spirit::rule<> &, T0=boost::spirit::nil_t, T1=boost::spirit::nil_t, T2=boost::spirit::nil_t, ScannerT=scanner_t ] d:\tools\boost\1.33.1\boost\spirit\core\scanner\impl\skipper.ipp(155) : see reference to function template instantiation 'boost::spirit::parse_info<IteratorT> boost::spirit::impl::phrase_parser<boost::spirit::space_parser>::parse<IteratorT,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<> ] d:\tools\boost\1.33.1\boost\spirit\core\scanner\impl\skipper.ipp(173) : see reference to function template instantiation 'boost::spirit::parse_info<IteratorT> 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 [ IteratorT=const char *, CharT=char, DerivedT=boost::spirit::rule<> ] d:\pilgrim\diplom\parser\sources\main.cpp(35) : see reference to function template instantiation 'boost::spirit::parse_info<IteratorT> 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 [ IteratorT=const char *, DerivedT=boost::spirit::rule<>, CharT=char ]
Strange. It sounds as if it were ignoring line 127 of skipper.ipp:
Are you certain that the definition of scanner is available?
typedef scanner<IteratorT, scanner_policies_t> scanner_t;
Are you certain that the definition of scanner is available?
Quote:Original post by ToohrVyk
Strange. It sounds as if it were ignoring line 127 of skipper.ipp:typedef scanner<IteratorT, scanner_policies_t> scanner_t;
Are you certain that the definition of scanner is available?
typedef scanner<IteratorT, scanner_policies_t> scanner_t; exist in skipper.ipp
Quote:Original post by pilgrim saQuote:Original post by ToohrVyk
Strange. It sounds as if it were ignoring line 127 of skipper.ipp:typedef scanner<IteratorT, scanner_policies_t> scanner_t;
Are you certain that the definition of scanner is available?
typedef scanner<IteratorT, scanner_policies_t> scanner_t; exist in skipper.ipp
Are you certain that the definition of scanner is available?
Quote:Original post by ToohrVykQuote:Original post by pilgrim saQuote:Original post by ToohrVyk
Strange. It sounds as if it were ignoring line 127 of skipper.ipp:typedef scanner<IteratorT, scanner_policies_t> scanner_t;
Are you certain that the definition of scanner is available?
typedef scanner<IteratorT, scanner_policies_t> scanner_t; exist in skipper.ipp
Are you certain that the definition of scanner is available?
yes, I'm certain!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement