Hello,
The following code doesn't compile (MSVC10, Boost 1.55). If I modify
"catch_all" line like this:
query = id[phx::try_[qi::_val = phx::bind(&string2test,
qi::_1)].catch_all [ qi::_pass = false ], qi::_val = qi::_val ];
...it compiles, but doesn't seem to invoke the semantic action in runtime.
It there a workaround that would both compile and work?
Thanks!
#define BOOST_SPIRIT_USE_PHOENIX_V3
#include <string>
#include
#include
#include
#include
#include
namespace qi = boost::spirit::qi;
namespace phx = boost::phoenix;
struct test
{
};
test string2test(const std::string &str)
{
if (str == "throw")
throw "exception!";
return test();
}
template <typename Iterator = std::string::const_iterator>
struct test_parser : qi::grammar
{
test_parser() : test_parser::base_type(query)
{
query = id[phx::try_[qi::_val = phx::bind(&string2test,
qi::_1)].catch_all [ qi::_pass = false ] ];
id = qi::lexeme[*qi::char_("a-zA-Z_0-9")];
}
qi::rule query;
qi::rule id;
};
int main()
{
const std::string input = "qwerty";
test_parser<> p;
test output;
bool ok = phrase_parse(input.begin(), input.end(), p, qi::blank, output);
}
//
1> boost\boost\proto\traits.hpp(297): error C2338: 0 == Expr::proto_arity_c
1> boost\boost\mpl\eval_if.hpp(63) : see reference to class template
instantiation 'boost::proto::result_of::value<Expr>' being compiled
1> with
1> [
1> Expr=boost::phoenix::try_catch_actor>,0>,boost::phoenix::actor>,0>,boost::phoenix::actor>>,2>>>,2>>>,1>>,boost::proto::exprns_::basic_expr>,0>,boost::phoenix::actor>>,2>>>,1>>,2>>
1> ]