Update of /cvsroot/boost/boost/libs/xpressive/proto/test
In directory
sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv12267/libs/xpressive/proto/test
Modified Files:
calculator.cpp lambda.cpp toy_spirit.cpp
Log Message:
make eval() a free function, make xpressive deep_copy semantic actions
Index: calculator.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/xpressive/proto/test/calculator.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- calculator.cpp 28 Mar 2007 08:35:57 -0000 1.5
+++ calculator.cpp 29 Mar 2007 22:19:39 -0000 1.6
@@ -35,25 +35,25 @@
template<typename Left, typename Right>
int operator()(proto::tag::add, Left const &left, Right const &right) const
{
- return left.eval(*this) + right.eval(*this);
+ return proto::eval(left, *this) + proto::eval(right, *this);
}
template<typename Left, typename Right>
int operator()(proto::tag::subtract, Left const &left, Right const &right)
const
{
- return left.eval(*this) - right.eval(*this);
+ return proto::eval(left, *this) - proto::eval(right, *this);
}
template<typename Left, typename Right>
int operator()(proto::tag::multiply, Left const &left, Right const &right)
const
{
- return left.eval(*this) * right.eval(*this);
+ return proto::eval(left, *this) * proto::eval(right, *this);
}
template<typename Left, typename Right>
int operator()(proto::tag::divide, Left const &left, Right const &right)
const
{
- return left.eval(*this) / right.eval(*this);
+ return proto::eval(left, *this) / proto::eval(right, *this);
}
private:
@@ -73,7 +73,7 @@
result_type operator()(T const &t) const
{
Fun fun(t);
- return this->expr_.eval(fun);
+ return proto::eval(this->expr_, fun);
}
private:
@@ -88,8 +88,8 @@
void test_calculator()
{
- BOOST_CHECK_EQUAL(10, (((_1 + 42)-3)/4).eval(calculator(1)));
- BOOST_CHECK_EQUAL(11, (((_1 + 42)-3)/4).eval(calculator(5)));
+ BOOST_CHECK_EQUAL(10, proto::eval(((_1 + 42)-3)/4, calculator(1)));
+ BOOST_CHECK_EQUAL(11, proto::eval(((_1 + 42)-3)/4, calculator(5)));
BOOST_CHECK_EQUAL(10, as<calculator>(((_1 + 42)-3)/4)(1));
BOOST_CHECK_EQUAL(11, as<calculator>(((_1 + 42)-3)/4)(5));
Index: lambda.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/xpressive/proto/test/lambda.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- lambda.cpp 26 Mar 2007 06:06:25 -0000 1.8
+++ lambda.cpp 29 Mar 2007 22:19:39 -0000 1.9
@@ -110,7 +110,7 @@
typedef typename mpl::eval_if<
typename lambda_arity<T>::type
, mpl::identity<void>
- , proto::result_of::eval<T, lambda_context<fusion::tuple<> > >
+ , proto::result_of::eval<T const, lambda_context<fusion::tuple<> > >
>::type nullary_type;
// Define our operator() that evaluates the lambda expression.
@@ -118,25 +118,25 @@
{
fusion::tuple<> args;
lambda_context<fusion::tuple<> > ctx(args);
- return this->eval(ctx);
+ return proto::eval(*this, ctx);
}
template<typename A0>
- typename proto::result_of::eval<T, lambda_context<fusion::tuple<A0 const
&> > >::type
+ typename proto::result_of::eval<T const, lambda_context<fusion::tuple<A0
const &> > >::type
operator()(A0 const &a0) const
{
fusion::tuple<A0 const &> args(a0);
lambda_context<fusion::tuple<A0 const &> > ctx(args);
- return this->eval(ctx);
+ return proto::eval(*this, ctx);
}
template<typename A0, typename A1>
- typename proto::result_of::eval<T, lambda_context<fusion::tuple<A0 const
&, A1 const &> > >::type
+ typename proto::result_of::eval<T const, lambda_context<fusion::tuple<A0
const &, A1 const &> > >::type
operator()(A0 const &a0, A1 const &a1) const
{
fusion::tuple<A0 const &, A1 const &> args(a0, a1);
lambda_context<fusion::tuple<A0 const &, A1 const &> > ctx(args);
- return this->eval(ctx);
+ return proto::eval(*this, ctx);
}
};
Index: toy_spirit.cpp
===================================================================
RCS file: /cvsroot/boost/boost/libs/xpressive/proto/test/toy_spirit.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- toy_spirit.cpp 26 Mar 2007 20:28:54 -0000 1.6
+++ toy_spirit.cpp 29 Mar 2007 22:19:39 -0000 1.7
@@ -171,7 +171,7 @@
bool operator()(proto::tag::function, anychar_p, Expr const &expr)
{
this->skip();
- return expr.eval(*this);
+ return proto::eval(expr, *this);
}
// parse function for space_p
@@ -254,7 +254,7 @@
{
this->skip();
iterator where = this->first;
- if(expr.eval(*this))
+ if(proto::eval(expr, *this))
return this->first = where, false;
this->first = ++where;
return true;
@@ -270,7 +270,7 @@
template<typename Left, typename Right>
bool operator()(proto::tag::right_shift, Left const &left, Right const
&right)
{
- return left.eval(*this) && right.eval(*this);
+ return proto::eval(left, *this) && proto::eval(right, *this);
}
// for A | B, succeeds if either A or B matches at this point.
@@ -278,7 +278,7 @@
bool operator()(proto::tag::bitwise_or, Left const &left, Right const
&right)
{
iterator where = this->first;
- return left.eval(*this) || right.eval(this->reset(where));
+ return proto::eval(left, *this) || proto::eval(right,
this->reset(where));
}
// for *A, greedily match A as many times as possible.
@@ -286,7 +286,7 @@
bool operator()(proto::tag::unary_star, Expr const &expr)
{
iterator where = this->first;
- while(expr.eval(*this))
+ while(proto::eval(expr, *this))
where = this->first;
// make sure that when we return true, the iterator is at the
correct position!
this->first = where;
@@ -297,7 +297,7 @@
template<typename Expr>
bool operator()(proto::tag::unary_plus, Expr const &expr)
{
- return expr.eval(*this) && (*expr).eval(*this);
+ return proto::eval(expr, *this) && proto::eval(*expr, *this);
}
// for !A, optionally match A.
@@ -305,7 +305,7 @@
bool operator()(proto::tag::logical_not, Expr const &expr)
{
iterator where = this->first;
- if(!expr.eval(*this))
+ if(!proto::eval(expr, *this))
this->first = where;
return true;
}
@@ -315,7 +315,7 @@
bool operator()(proto::tag::subtract, Left const &left, Right const
&right)
{
iterator where = this->first;
- return !right.eval(*this) && left.eval(this->reset(where));
+ return !proto::eval(right, *this) && proto::eval(left,
this->reset(where));
}
private:
spirit_context &reset(iterator where)
@@ -329,7 +329,7 @@
if(!this->in_skip_)
{
this->in_skip_ = true;
- while(this->skip_.eval(*this))
+ while(proto::eval(this->skip_, *this))
{}
this->in_skip_ = false;
}
@@ -546,7 +546,7 @@
struct no_case_directive
{
template<typename Expr>
- typename SpiritGrammar::apply<Expr, mpl::void_, mpl::void_>::type
+ typename SpiritGrammar::apply<Expr, mpl::void_, mpl::void_>::type const
operator [](Expr const &expr) const
{
mpl::void_ null;
@@ -565,7 +565,7 @@
{}
template<typename Expr>
- typename SkipperGrammar::apply<Expr, Skipper, mpl::void_>::type
+ typename SkipperGrammar::apply<Expr, Skipper, mpl::void_>::type const
operator [](Expr const &expr) const
{
mpl::void_ null;
@@ -593,7 +593,7 @@
BOOST_MPL_ASSERT((proto::matches<Rule, SpiritGrammar>));
spirit_context<FwdIter> ctx(begin, end);
- return rule.eval(ctx);
+ return proto::eval(rule, ctx);
}
// parse with a skip parser can be implemented in one of two ways:
@@ -624,11 +624,11 @@
//// Method 1: pass skip parser in the context structure.
//spirit_context<FwdIter, Skipper> ctx(begin, end, skipper);
- //return rule.eval(ctx);
+ //return proto::eval(rule, ctx);
// Method 2: Embed skip parser via tree transformation.
spirit_context<FwdIter> ctx(begin, end);
- return spirit2::skip(skipper)[rule].eval(ctx);
+ return proto::eval(spirit2::skip(skipper)[rule], ctx);
}
}}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs