Boost logo

Boost Users :

Subject: [Boost-users] [spirit][qi] on_error handler
From: Diederick C. Niehorster (dcnieho_at_[hidden])
Date: 2012-12-21 19:44:34


Hi All,

I have struggled through getting a parser set up with qi, but in the
end it all worked out. Its really a nice library once you get the hang
of it a bit!
I have one leftover question. I now have an inline function with
phoenix for the error handler as per the example, but as i'm using it
multiple times, i would like to make its own function that i can
reuse. I have tried a function object, wrapped in a phoenix function
or not, but never got it to work (either got number of argument
mismatches or errors that const-volatile qualifiers were being
dropped).

So basically, how would i rewrite the below into a free function (object/etc)?

qi::on_error<qi::fail>
(
        stimSpecVec // rule name
        , std::cout // the function
            << phoenix::val("Error! Expecting \"")
            << qi::_4 // what failed?
            << phoenix::val("\", but got: \"")
            << phoenix::construct<std::string>(qi::_3, qi::_2) // iterators
to error-pos, end
            << phoenix::val("\"")
            << std::endl
);

Thanks!
Dee


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