Boost logo

Boost Users :

Subject: [Boost-users] [qi] Get line number of an on_error handler from an ifstream iterator
From: boost_mailinglist_at_[hidden]
Date: 2011-09-13 13:40:20


Hello,

can anyone of you give me a hint, how I can get the line number of the
input file inside the on_error handler where the parsing error happens?

Full source is atttached as file.cpp.

bool test(Iterator first, Iterator last)
{

    qi::rule<Iterator>start;
    start.name("start");

    start=*(eps>char_('a')>>eol);

    on_error<fail>
    (
    start
    , std::cout
<< val("Error! Expecting ")
<< _4
<< val(" here(")
    //linenumber insert
<< val("): \"")
<< construct<std::string>(_3, _2)
<< val("\"")
<< std::endl
    );

    bool r = qi::parse(first,last,start);
    if (r && first == last){
        return true;
    }
    else{
        return false;
    }
}

Best regards





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