Boost logo

Boost Users :

Subject: [Boost-users] problems with boost::spirit
From: Goran (xamiw_at_[hidden])
Date: 2009-03-14 17:44:42


Hi all,

I wanna get boost::spirit to tell me which position in my string is
liable that parsing fails. Here's a fully compiling demonstration:

#--------------------------------------------------------------------
#include <iostream>
#include <string>
#include <boost/spirit.hpp>

using namespace std;
using namespace boost::spirit;

int main()
{
  string s = "#x";
  rule<> r = chlit<>('#') >> chlit<>('X') >> *space_p;

  parse_info<> p = parse(s.c_str(),r);
  if(p.full)
    cout << "File is OK:\n";
  else
    cout << "Error at pos " << p.length << ".\n";

  return 0;
}
#--------------------------------------------------------------------

With this I get:

Error at pos 4294967295.

But if "string s = "#Xx" I get:

Error at pos 2.

This is what I want. But why do I get 4294967295 which is 2^32-1.

Thanks for any comments,
Goran.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net