$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [Boost-users] problems with boost::spirit
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-03-16 20:41:18
AMDG
Goran wrote:
> 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. 
>   
Parsing fails so there is no match.  p.length is therefore not valid.
In Christ,
Steven Watanabe