On Thu, Feb 11, 2010 at 10:53 PM, Matthias Vallentin
On Thu, Feb 11, 2010 at 03:22:53PM -0700, OvermindDL1 wrote:
std::string result; parse(str.begin(),str.end(), raw[+~char_(delim)]%lit(delim), result);
This fails in the first argument of qi::parse:
using boost::spirit::qi::lit; using boost::spirit::qi::raw; using boost::spirit::qi::string;
std::string str("foo---bar---baz"); std::string delim("---"); std::string result; boost::spirit::qi::parse(str.begin(), str.end(), raw[+~string(delim)] % lit(delim), result);
Any ideas why?
If you are using GCC (which is actually doing things correctly, the
above code works on MSVC, which is not quite correct, but this code
works everywhere), then do this for the parse line instead:
std::string::const_iterator iter=str.begin(),iterEnd=str.end();
boost::spirit::qi::parse(iter, iterEnd,
raw[+~string(delim)] % lit(delim), result);
On Thu, Feb 11, 2010 at 8:17 PM, Rob Riggs
On 02/11/2010 03:22 PM, OvermindDL1 wrote:
You can do that off the bat using Boost.Spirit2.1+ like this: Or case insensitive:
parse(str.begin(),str.end(), nocase[raw[+~char_(delim)]%lit(delim)], result);
And there is *SO*MUCH* more you can do with spirit too, and it executes faster then the tokanizer and such as well, while working on input iterators, etc...
Spirit seems to have the same operator-overloaded "write-only code" quality that Perl suffers from. The implementation may be the greatest thing ever, but the end result is a bit worrisome. The string algorithm library's syntax is far more reasonable IMO.
Not sure of what you speak, I cannot think of any better way to implement anything as powerful as Spirit within the confines of the C++ language without becoming *exceedingly* long and impossible to read... How is the string algorithm libraries syntax better? It is slower and cannot do anywhere near as much (Spirit is a full PEG parser).