Opened 13 years ago
Closed 13 years ago
#3235 closed Bugs (invalid)
position_iterator and skip parser
| Reported by: | Owned by: | Joel de Guzman | |
|---|---|---|---|
| Milestone: | Boost 1.40.0 | Component: | spirit |
| Version: | Boost 1.39.0 | Severity: | Problem |
| Keywords: | Cc: |
Description
This prints 1 while the error is on line 2.
#include <boost/spirit/include/classic.hpp>
#include <cassert>
#include <iostream>
using namespace boost::spirit::classic;
using namespace std;
int main()
{
typedef position_iterator<const char*> iterator_t;
const char* str = "1\nA";
parse_info<iterator_t> info = parse(iterator_t(str, str +
strlen(str)), iterator_t(), int_p >> !end_p, space_p);
cout << info.stop.get_position().line << endl;
return 0;
}
Note:
See TracTickets
for help on using tickets.

Sure, it needs to give you a line number of 1, because the parse fails before the end_p parser, which leaves the position of the last valid match at the point before the skip of the failed match (IOW, right after the last successful match).
Regards Hartmut