diff --git a/example/x3/rexpr/rexpr_full/Jamfile b/example/x3/rexpr/rexpr_full/Jamfile index cc91462f48..2cd3d6508b 100644 --- a/example/x3/rexpr/rexpr_full/Jamfile +++ b/example/x3/rexpr/rexpr_full/Jamfile @@ -19,7 +19,7 @@ project spirit-x3-example-rexpr ; lib rexpr - : [ glob src/*.cpp ] /boost//system + : [ glob src/*.cpp ] /boost//system /boost//filesystem ; build-project test ; diff --git a/include/boost/spirit/home/x3/core/call.hpp b/include/boost/spirit/home/x3/core/call.hpp index 9674c93efe..99c1d8576d 100644 --- a/include/boost/spirit/home/x3/core/call.hpp +++ b/include/boost/spirit/home/x3/core/call.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include namespace boost { namespace spirit { namespace x3 @@ -46,13 +46,13 @@ namespace boost { namespace spirit { namespace x3 namespace detail { template - auto call(F f, Context const& context, mpl::true_) + auto call(int, F f, Context const& context) -> decltype(f(context)) { return f(context); } template - auto call(F f, Context const& context, mpl::false_) + auto call(low_priority, F f, Context const& /*context*/) -> decltype(f()) { return f(); } @@ -69,7 +69,7 @@ namespace boost { namespace spirit { namespace x3 auto val_context = make_context(rcontext, context); auto where_context = make_context(rng, val_context); auto attr_context = make_context(attr, where_context); - return detail::call(f, attr_context, is_callable()); + return detail::call(0, f, attr_context); } }}} diff --git a/include/boost/spirit/home/x3/nonterminal/detail/rule.hpp b/include/boost/spirit/home/x3/nonterminal/detail/rule.hpp index 71dc4c549f..551f39febf 100644 --- a/include/boost/spirit/home/x3/nonterminal/detail/rule.hpp +++ b/include/boost/spirit/home/x3/nonterminal/detail/rule.hpp @@ -106,24 +106,6 @@ namespace boost { namespace spirit { namespace x3 { namespace detail : mpl::true_ {}; - template - struct has_on_success : mpl::false_ {}; - - template - struct has_on_success().on_success( - std::declval() - , std::declval() - , std::declval() - , std::declval() - ) - )>::type - > - : mpl::true_ - {}; - template struct make_id { @@ -155,28 +137,34 @@ namespace boost { namespace spirit { namespace x3 { namespace detail struct rule_parser { template - static bool call_on_success( + static void call_on_success( + low_priority, Iterator& first, Iterator const& last - , Context const& context, ActualAttribute& attr - , mpl::false_ /* No on_success handler */ ) + , Context const& context, ActualAttribute& attr, bool & pass) { - return true; + pass = true; } template - static bool call_on_success( + static auto call_on_success( + int, Iterator& first, Iterator const& last - , Context const& context, ActualAttribute& attr - , mpl::true_ /* Has on_success handler */) + , Context const& context, ActualAttribute& attr, bool & pass) + -> decltype( + ID().on_success( + first + , last + , attr + , make_context(pass, context) + ) + ) { - bool pass = true; ID().on_success( first , last , attr , make_context(pass, context) ); - return pass; } template ()); + call_on_success(0, first_, i, context, attr, r); } if (r) diff --git a/include/boost/spirit/home/x3/nonterminal/rule.hpp b/include/boost/spirit/home/x3/nonterminal/rule.hpp index 56075f34d7..bbf2bb0398 100644 --- a/include/boost/spirit/home/x3/nonterminal/rule.hpp +++ b/include/boost/spirit/home/x3/nonterminal/rule.hpp @@ -154,9 +154,10 @@ namespace boost { namespace spirit { namespace x3 /***/ #define BOOST_SPIRIT_DEFINE_(r, data, rule_name) \ + using BOOST_PP_CAT(rule_name, _synonym) = decltype(rule_name); \ template \ inline bool parse_rule( \ - decltype(rule_name) rule_ \ + BOOST_PP_CAT(rule_name, _synonym) rule_ \ , Iterator& first, Iterator const& last \ , Context const& context, Attribute& attr) \ { \ diff --git a/include/boost/spirit/home/x3/support/utility/sfinae.hpp b/include/boost/spirit/home/x3/support/utility/sfinae.hpp index 532ae5c54d..fd3d64f502 100644 --- a/include/boost/spirit/home/x3/support/utility/sfinae.hpp +++ b/include/boost/spirit/home/x3/support/utility/sfinae.hpp @@ -10,6 +10,11 @@ namespace boost { namespace spirit { namespace x3 { + struct low_priority + { + low_priority(int) { } + }; + template struct disable_if_substitution_failure { diff --git a/test/x3/actions.cpp b/test/x3/actions.cpp index 5400b38cc0..6ca5c3ef9f 100644 --- a/test/x3/actions.cpp +++ b/test/x3/actions.cpp @@ -4,6 +4,7 @@ Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ +#include #include #include #include @@ -22,6 +23,7 @@ auto fun1 = struct fun_action { + using result_type = void; template void operator()(Context const& ctx) const { @@ -65,9 +67,9 @@ int main() } { - using namespace std::placeholders; + using namespace boost::placeholders; char const *s1 = "{42}", *e1 = s1 + std::strlen(s1); - x3::parse(s1, e1, '{' >> int_[std::bind(fun_action(), _1)] >> '}'); + x3::parse(s1, e1, '{' >> int_[boost::bind(fun_action(), _1)] >> '}'); } BOOST_TEST(x == (42*3)); diff --git a/test/x3/char_class.cpp b/test/x3/char_class.cpp index 0900d150e5..d6aefce2d0 100644 --- a/test/x3/char_class.cpp +++ b/test/x3/char_class.cpp @@ -239,9 +239,8 @@ main() { // test action using namespace boost::spirit::x3::ascii; - using boost::spirit::x3::_attr; char ch; - auto f = [&](auto& ctx){ ch = _attr(ctx); }; + auto f = [&](auto& ctx){ ch = boost::spirit::x3::_attr(ctx); }; BOOST_TEST(test("x", alnum[f])); BOOST_TEST(ch == 'x'); diff --git a/test/x3/difference.cpp b/test/x3/difference.cpp index 5581cdeab8..70372c6dd5 100644 --- a/test/x3/difference.cpp +++ b/test/x3/difference.cpp @@ -43,20 +43,18 @@ main() } { - using boost::spirit::x3::_attr; - std::string s; BOOST_TEST(test( "/*abcdefghijk*/" - , "/*" >> *(char_ - "*/")[([&](auto& ctx){ s += _attr(ctx); })] >> "*/" + , "/*" >> *(char_ - "*/")[([&](auto& ctx){ s += boost::spirit::x3::_attr(ctx); })] >> "*/" )); BOOST_TEST(s == "abcdefghijk"); s.clear(); BOOST_TEST(test( " /*abcdefghijk*/" - , "/*" >> *(char_ - "*/")[([&](auto& ctx){ s += _attr(ctx); })] >> "*/" + , "/*" >> *(char_ - "*/")[([&](auto& ctx){ s += boost::spirit::x3::_attr(ctx); })] >> "*/" , space )); BOOST_TEST(s == "abcdefghijk"); diff --git a/test/x3/extensions/confix.cpp b/test/x3/extensions/confix.cpp index b55cfd1bb8..c7c2985747 100644 --- a/test/x3/extensions/confix.cpp +++ b/test/x3/extensions/confix.cpp @@ -37,7 +37,7 @@ int main() BOOST_TEST(value == 123); value = 0; - const auto lambda = [&value](auto& ctx ){ value = x3::_attr(ctx) + 1; }; + const auto lambda = [&value](auto& ctx ){ value = boost::spirit::x3::_attr(ctx) + 1; }; BOOST_TEST(test_attr("/*123*/", comment[x3::uint_][lambda], value)); BOOST_TEST(value == 124); } diff --git a/test/x3/int1.cpp b/test/x3/int1.cpp index 030923c172..347ef221be 100644 --- a/test/x3/int1.cpp +++ b/test/x3/int1.cpp @@ -142,12 +142,11 @@ main() // action tests /////////////////////////////////////////////////////////////////////////// { - using boost::spirit::x3::_attr; using boost::spirit::x3::ascii::space; using boost::spirit::x3::int_; int n, m; - auto f = [&](auto& ctx){ n = _attr(ctx); }; + auto f = [&](auto& ctx){ n = boost::spirit::x3::_attr(ctx); }; BOOST_TEST(test("123", int_[f])); BOOST_TEST(n == 123); diff --git a/test/x3/kleene.cpp b/test/x3/kleene.cpp index e830bee1ba..83fb2a97af 100644 --- a/test/x3/kleene.cpp +++ b/test/x3/kleene.cpp @@ -90,20 +90,16 @@ main() } { // actions - using boost::spirit::x3::_attr; - std::string v; - auto f = [&](auto& ctx){ v = _attr(ctx); }; + auto f = [&](auto& ctx){ v = boost::spirit::x3::_attr(ctx); }; BOOST_TEST(test("bbbb", (*char_)[f]) && 4 == v.size() && v[0] == 'b' && v[1] == 'b' && v[2] == 'b' && v[3] == 'b'); } { // more actions - using boost::spirit::x3::_attr; - std::vector v; - auto f = [&](auto& ctx){ v = _attr(ctx); }; + auto f = [&](auto& ctx){ v = boost::spirit::x3::_attr(ctx); }; BOOST_TEST(test("123 456 789", (*int_)[f], space) && 3 == v.size() && v[0] == 123 && v[1] == 456 && v[2] == 789); diff --git a/test/x3/list.cpp b/test/x3/list.cpp index ff3af8353b..2358743c4a 100644 --- a/test/x3/list.cpp +++ b/test/x3/list.cpp @@ -89,10 +89,8 @@ main() } { // actions - using boost::spirit::x3::_attr; - std::string s; - auto f = [&](auto& ctx){ s = std::string(_attr(ctx).begin(), _attr(ctx).end()); }; + auto f = [&](auto& ctx){ s = std::string(boost::spirit::x3::_attr(ctx).begin(), boost::spirit::x3::_attr(ctx).end()); }; BOOST_TEST(test("a,b,c,d,e,f,g,h", (char_ % ',')[f])); BOOST_TEST(s == "abcdefgh"); diff --git a/test/x3/raw.cpp b/test/x3/raw.cpp index c26406c7c7..2074006e87 100644 --- a/test/x3/raw.cpp +++ b/test/x3/raw.cpp @@ -18,7 +18,6 @@ int main() using namespace boost::spirit::x3::ascii; using boost::spirit::x3::raw; using boost::spirit::x3::eps; - using boost::spirit::x3::_attr; { boost::iterator_range range; @@ -43,7 +42,7 @@ int main() { boost::iterator_range range; - BOOST_TEST((test("x", raw[alpha][ ([&](auto& ctx){ range = _attr(ctx); }) ]))); + BOOST_TEST((test("x", raw[alpha][ ([&](auto& ctx){ range = boost::spirit::x3::_attr(ctx); }) ]))); BOOST_TEST(range.size() == 1 && *range.begin() == 'x'); } diff --git a/test/x3/uint1.cpp b/test/x3/uint1.cpp index ee8b6c3cd7..08300be9e8 100644 --- a/test/x3/uint1.cpp +++ b/test/x3/uint1.cpp @@ -131,12 +131,11 @@ main() // action tests /////////////////////////////////////////////////////////////////////////// { - using boost::spirit::x3::_attr; using boost::spirit::x3::uint_; using boost::spirit::x3::ascii::space; int n; - auto f = [&](auto& ctx){ n = _attr(ctx); }; + auto f = [&](auto& ctx){ n = boost::spirit::x3::_attr(ctx); }; BOOST_TEST(test("123", uint_[f])); BOOST_TEST(n == 123);