mirror of
https://github.com/boostorg/spirit.git
synced 2026-01-19 04:42:11 +00:00
+ Using -std=c++1y
+ Using polymorphic lambda on semantic actions
This commit is contained in:
@@ -47,6 +47,14 @@ namespace boost { namespace spirit { namespace x3
|
||||
Attribute& val;
|
||||
};
|
||||
|
||||
template <typename Context>
|
||||
inline auto
|
||||
_val(Context& context)
|
||||
-> decltype(x3::get<rule_context_tag>(context).val())
|
||||
{
|
||||
return x3::get<rule_context_tag>(context).val();
|
||||
}
|
||||
|
||||
template <typename ID, typename RHS, typename Attribute>
|
||||
struct rule_definition : parser<rule_definition<ID, RHS, Attribute>>
|
||||
{
|
||||
|
||||
@@ -19,9 +19,9 @@ project spirit_test
|
||||
<include>.
|
||||
<toolset>gcc:<cxxflags>-std=c++0x
|
||||
<toolset>gcc:<cxxflags>-ftemplate-depth-512
|
||||
<toolset>clang:<cxxflags>-std=c++0x
|
||||
<toolset>clang:<cxxflags>-std=c++1y
|
||||
<toolset>clang:<cxxflags>-ftemplate-depth-512
|
||||
<toolset>darwin:<cxxflags>-std=c++0x
|
||||
<toolset>darwin:<cxxflags>-std=c++1y
|
||||
<toolset>darwin:<cxxflags>-ftemplate-depth-512
|
||||
:
|
||||
:
|
||||
|
||||
@@ -50,7 +50,7 @@ main()
|
||||
|
||||
char ch = '\0';
|
||||
auto a = rule<class a, char>() = alpha;
|
||||
auto f = [&](unused_type, char attr){ ch = attr; };
|
||||
auto f = [&](auto&, char attr){ ch = attr; };
|
||||
|
||||
BOOST_TEST(test("x", a[f]));
|
||||
BOOST_TEST(ch == 'x');
|
||||
@@ -73,7 +73,7 @@ main()
|
||||
// that is convertible to the value_type of the attribute).
|
||||
|
||||
std::string s;
|
||||
auto f = [&](unused_type, std::string attr){ s = attr; };
|
||||
auto f = [&](auto&, std::string attr){ s = attr; };
|
||||
|
||||
{
|
||||
auto r = rule<class r, std::string>()
|
||||
|
||||
@@ -48,6 +48,7 @@ main()
|
||||
//~ using boost::spirit::x3::on_error;
|
||||
//~ using boost::spirit::x3::debug;
|
||||
using boost::spirit::x3::lit;
|
||||
using boost::spirit::x3::_val;
|
||||
//~ using boost::spirit::x3::_val;
|
||||
//~ using boost::spirit::x3::_1;
|
||||
//~ using boost::spirit::x3::_r1;
|
||||
@@ -74,11 +75,8 @@ main()
|
||||
std::string s;
|
||||
typedef rule<class r, std::string> rule_type;
|
||||
|
||||
// MSVC does not want to have this by value! (MSVC lambda bug)
|
||||
typedef rule_type::context const& ctx;
|
||||
|
||||
auto rdef = rule_type()
|
||||
= alpha [([](ctx r, char c){ r.val += c; })]
|
||||
= alpha [([](auto& r, char c){ _val(r) += c; })]
|
||||
;
|
||||
|
||||
BOOST_TEST(test_attr("abcdef", +rdef, s));
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace parser
|
||||
|
||||
namespace g_definition
|
||||
{
|
||||
rule<class x> const x;
|
||||
auto const x = rule<class x>();
|
||||
auto const ax = char_('a') >> x;
|
||||
|
||||
auto const g =
|
||||
@@ -203,7 +203,7 @@ int main()
|
||||
{ // a recursive rule
|
||||
using namespace boost::spirit::x3;
|
||||
|
||||
rule<class x> const x;
|
||||
auto const x = rule<class x>();
|
||||
auto const ax = char_('a') >> x;
|
||||
auto const start = (x = char_('x') | ax);
|
||||
|
||||
@@ -214,7 +214,7 @@ int main()
|
||||
std::cout << "==========================================" << std::endl;
|
||||
}
|
||||
|
||||
{ // a grammar (gcc only: see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3582.html)
|
||||
{ // a grammar ( gcc and clang only: see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3582.html )
|
||||
|
||||
using namespace boost::spirit::x3;
|
||||
auto g = []()
|
||||
|
||||
Reference in New Issue
Block a user