rule's attribute captures too much?
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <de5e3582b25247f384111f41ca8b1347@HE104838.emea1.cds.t-internal.com> |
Hello,
Trying to parse "0/1/x" with
qi::ascii::digit >> +(qi::char_('/') >> qi::ascii::digit)
I had expected the synthesized attributes value to be "0/1".
But he following code results in "0/1/", where the suffix is "/x". Is this the correct behavior?
#include <iostream>
#include <string>
#include <boost/spirit/include/qi.hpp>
int main(void)
{
using namespace boost::spirit;
char const * first = "0/1/x";
char const * last = first + std::strlen(first);
std::string capture;
bool ok = qi::parse(first, last, qi::ascii::digit >> +(qi::char_('/') >> qi::ascii::digit) >> lit("/x"), capture);
std::cout << "captured = '" << capture << "'\n";
std::cout << "full match = " << std::boolalpha << (ok && first == last) << "\n";
return ok;
}
Running the code results in
captured = '0/1/'
full match = true
Regards
Martin
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi