Update of /cvsroot/boost/boost/boost/xpressive/detail/static/transforms
In directory
sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32640/detail/static/transforms
Modified Files:
as_quantifier.hpp transform.hpp
Log Message:
fix handling of optional sub-expressions wrt captures
Index: as_quantifier.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/boost/xpressive/detail/static/transforms/as_quantifier.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- as_quantifier.hpp 6 Apr 2007 02:07:10 -0000 1.5
+++ as_quantifier.hpp 6 Apr 2007 02:54:23 -0000 1.6
@@ -146,48 +146,109 @@
}
};
- // TODO use optional_matcher and optional_mark_matcher
+
///////////////////////////////////////////////////////////////////////////////
+ // optional_tag
template<bool Greedy>
- struct make_optional_
+ struct optional_tag
+ {};
+
+
///////////////////////////////////////////////////////////////////////////////
+ // as_default_optional
+ template<typename Grammar, bool Greedy>
+ struct as_default_optional
+ : Grammar
{
+ as_default_optional();
+
template<typename Expr, typename State, typename Visitor>
struct apply
- : proto::bitwise_or<
- Expr
- , proto::terminal<epsilon_matcher>::type
- >
- {};
+ {
+ typedef optional_matcher<
+ typename Grammar::template apply<Expr,
alternate_end_xpression, Visitor>::type
+ , Greedy
+ > type;
+ };
template<typename Expr, typename State, typename Visitor>
static typename apply<Expr, State, Visitor>::type
call(Expr const &expr, State const &state, Visitor &visitor)
{
- typename apply<Expr, State, Visitor>::type that = {expr,
{epsilon_matcher()}};
- return that;
- }
+ return typename apply<Expr, State, Visitor>::type(
+ Grammar::call(expr, alternate_end_xpression(), visitor)
+ );
+ };
};
- template<>
- struct make_optional_<false>
+
///////////////////////////////////////////////////////////////////////////////
+ // as_mark_optional
+ template<typename Grammar, bool Greedy>
+ struct as_mark_optional
+ : Grammar
{
+ as_mark_optional();
+
template<typename Expr, typename State, typename Visitor>
struct apply
- : proto::bitwise_or<
- proto::terminal<epsilon_matcher>::type
- , Expr
- >
+ {
+ typedef optional_mark_matcher<
+ typename Grammar::template apply<Expr,
alternate_end_xpression, Visitor>::type
+ , Greedy
+ > type;
+ };
+
+ template<typename Expr, typename State, typename Visitor>
+ static typename apply<Expr, State, Visitor>::type
+ call(Expr const &expr, State const &state, Visitor &visitor)
+ {
+ int mark_number = proto::arg(proto::left(expr)).mark_number_;
+ return typename apply<Expr, State, Visitor>::type(
+ Grammar::call(expr, alternate_end_xpression(), visitor)
+ , mark_number
+ );
+ };
+ };
+
+
///////////////////////////////////////////////////////////////////////////////
+ // IsMarkerOrRepeater
+ struct IsMarkerOrRepeater
+ : proto::or_<
+ proto::right_shift<proto::terminal<repeat_begin_matcher>, proto::_>
+ , proto::assign<proto::terminal<mark_placeholder>, proto::_>
+ >
+ {};
+
+
///////////////////////////////////////////////////////////////////////////////
+ // as_optional
+ template<typename Grammar, bool Greedy>
+ struct as_optional
+ : proto::trans::conditional<
+ proto::matches<mpl::_, IsMarkerOrRepeater>
+ , as_mark_optional<Grammar, Greedy>
+ , as_default_optional<Grammar, Greedy>
+ >
+ {
+ as_optional();
+ };
+
+
///////////////////////////////////////////////////////////////////////////////
+ // make_optional_
+ template<bool Greedy>
+ struct make_optional_
+ {
+ template<typename Expr, typename State, typename Visitor>
+ struct apply
+ : proto::unary_expr<optional_tag<Greedy>, Expr>
{};
template<typename Expr, typename State, typename Visitor>
static typename apply<Expr, State, Visitor>::type
call(Expr const &expr, State const &state, Visitor &visitor)
{
- typename apply<Expr, State, Visitor>::type that =
{{epsilon_matcher()}, expr};
+ typename apply<Expr, State, Visitor>::type that = {expr};
return that;
}
};
-
///////////////////////////////////////////////////////////////////////////////
// as_default_quantifier_impl
template<bool Greedy, uint_t Max>
Index: transform.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/boost/xpressive/detail/static/transforms/transform.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- transform.hpp 6 Apr 2007 02:07:11 -0000 1.7
+++ transform.hpp 6 Apr 2007 02:54:23 -0000 1.8
@@ -126,6 +126,11 @@
, as_inverse<proto::trans::arg<proto::complement<InvertibleMatcher>
> >
, proto::trans::arg<proto::unary_expr<keeper_tag, as_keeper<Grammar>
> >
+
+ , proto::or_<
+ proto::trans::arg<proto::unary_expr<optional_tag<true>,
as_optional<Grammar, true> > >
+ , proto::trans::arg<proto::unary_expr<optional_tag<false>,
as_optional<Grammar, false> > >
+ >
>
{};
-------------------------------------------------------------------------
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