Update of /cvsroot/boost/boost/boost/xpressive/detail/static/transforms
In directory
sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv30998/detail/static/transforms
Modified Files:
as_quantifier.hpp transform.hpp
Log Message:
as_optional transform, and proto::trans::conditional
Index: as_quantifier.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/boost/xpressive/detail/static/transforms/as_quantifier.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- as_quantifier.hpp 2 Apr 2007 06:41:56 -0000 1.1
+++ as_quantifier.hpp 3 Apr 2007 06:32:17 -0000 1.2
@@ -22,9 +22,11 @@
#include <boost/xpressive/detail/utility/cons.hpp>
#include <boost/xpressive/proto/transform/branch.hpp>
#include <boost/xpressive/proto/transform/arg.hpp>
+#include <boost/xpressive/proto/transform/conditional.hpp>
// BUGBUG move quant traits here
#include <boost/xpressive/detail/static/productions/quant_traits.hpp>
+#include <boost/xpressive/detail/static/productions/quant_transforms.hpp>
namespace boost { namespace xpressive { namespace detail
{
@@ -146,6 +148,80 @@
}
};
+ struct MarkerPattern;
+ struct DefaultGreedyQuantifier;
+
+ struct OptionalMark
+ : proto::unary_expr<proto::_, proto::or_<MarkerPattern,
DefaultGreedyQuantifier> >
+ {};
+
+
///////////////////////////////////////////////////////////////////////////////
+ // 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
+ {
+ 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)
+ {
+ return typename apply<Expr, State, Visitor>::type(
+ Grammar::call(expr, alternate_end_xpression(), visitor)
+ );
+ }
+ };
+
+
///////////////////////////////////////////////////////////////////////////////
+ // 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
+ {
+ 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)
+ {
+ typename Grammar::template apply<Expr, alternate_end_xpression,
Visitor>::type const &
+ marked_expr = Grammar::call(expr, alternate_end_xpression(),
visitor);
+ return typename apply<Expr, State, Visitor>::type(marked_expr,
marked_expr.mark_number_);
+ }
+ };
+
+
///////////////////////////////////////////////////////////////////////////////
+ // as_optional
+ template<typename Grammar, bool Greedy>
+ struct as_optional
+ : proto::trans::conditional<
+ proto::matches<mpl::_, OptionalMark>
+ , as_mark_optional<Grammar, Greedy>
+ , as_default_optional<Grammar, Greedy>
+ >
+ {
+ as_optional();
+ };
+
}}}
#endif
Index: transform.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/boost/xpressive/detail/static/transforms/transform.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- transform.hpp 2 Apr 2007 06:41:56 -0000 1.1
+++ transform.hpp 3 Apr 2007 06:32:17 -0000 1.2
@@ -13,6 +13,7 @@
# pragma once
#endif
+#include <boost/mpl/not.hpp>
#include <boost/xpressive/proto/proto.hpp>
#include <boost/xpressive/proto/transform/fold.hpp>
#include <boost/xpressive/detail/static/transforms/as_matcher.hpp>
@@ -20,12 +21,27 @@
#include <boost/xpressive/detail/static/transforms/as_sequence.hpp>
#include <boost/xpressive/detail/static/transforms/as_quantifier.hpp>
#include <boost/xpressive/detail/static/transforms/as_marker.hpp>
+#include <boost/xpressive/proto/transform/arg.hpp>
#include <boost/xpressive/proto/transform/compose.hpp>
namespace boost { namespace xpressive { namespace detail
{
+ //template<typename Tag>
+ //struct is_generic_quant_tag
+ // : mpl::false_
+ //{};
+
+ //template<unsigned Min, unsigned Max>
+ //struct is_generic_quant_tag<generic_quant_tag<Min, Max> >
+ // : mpl::true_
+ //{};
+
struct Grammar;
+ struct Sequence
+ : proto::right_shift<Grammar, Grammar>
+ {};
+
struct Alternate
: proto::bitwise_or< Grammar, Grammar >
{};
@@ -34,11 +50,27 @@
: proto::terminal< proto::_ >
{};
+ struct Mark
+ : proto::assign<basic_mark_tag, Grammar>
+ {};
+
struct GreedyQuantifier
: proto::or_<
proto::unary_plus<Grammar>
, proto::unary_star<Grammar>
- , proto::logical_not<Grammar>
+ //, proto::and_<
+ // proto::unary_expr<proto::_, Grammar>
+ // , proto::if_<is_generic_quant_tag<proto::tag_of<mpl::_> > >
+ // >
+ >
+ {};
+
+ struct GreedyOptional
+ : proto::trans::arg<
+ //proto::or_<
+ proto::logical_not<Grammar>
+ // , proto::unary_expr<generic_quant_tag<0, 1>, Grammar>
+ //>
>
{};
@@ -50,7 +82,7 @@
: proto::and_<
GreedyQuantifier
, proto::if_<use_simple_repeat<proto::result_of::arg<mpl::_>,
proto::tag_of<proto::result_of::arg<mpl::_> > > >
- , proto::transform::arg<GreedyQuantifier>
+ , proto::trans::arg<GreedyQuantifier>
>
{};
@@ -61,28 +93,16 @@
>
{};
- struct Mark
- : proto::assign<basic_mark_tag, Grammar>
- {};
-
- struct Sequence
- : proto::right_shift<Grammar, Grammar>
- {};
-
// These sub-expressions generate simple matcher types
// that must be placed in sequence.
struct NonSequence
: proto::or_<
as_matcher<Terminal>
, as_alternate<Alternate>
+ , as_optional<GreedyOptional, false>
+ , proto::trans::arg<proto::unary_minus<as_optional<GreedyOptional,
true> > >
, as_simple_quantifier<SimpleGreedyQuantifier, false>
- , proto::transform::compose<
- proto::and_<
- proto::unary_minus<SimpleGreedyQuantifier>
- , proto::transform::arg<proto::_>
- >
- , as_simple_quantifier<SimpleGreedyQuantifier, true>
- >
+ ,
proto::trans::arg<proto::unary_minus<as_simple_quantifier<SimpleGreedyQuantifier,
true> > >
>
{};
@@ -90,21 +110,15 @@
struct Transforms
: proto::or_<
as_default_quantifier<DefaultGreedyQuantifier, false>
- , proto::transform::compose<
- proto::and_<
- proto::unary_minus<DefaultGreedyQuantifier> //
match -(GreedyQuant) ...
- , proto::transform::arg<proto::_> // and
strip off the - ...
- >
- , as_default_quantifier<DefaultGreedyQuantifier, true> // and
process the GreedyQuat
- >
+ ,
proto::trans::arg<proto::unary_minus<as_default_quantifier<DefaultGreedyQuantifier,
true> > >
, as_marker<Mark>
>
{};
struct Grammar
: proto::or_<
- proto::transform::reverse_fold<Sequence>
- , proto::transform::compose<Transforms, Grammar>
+ proto::trans::reverse_fold<Sequence>
+ , proto::trans::compose<Transforms, Grammar>
, in_sequence<NonSequence>
>
{};
-------------------------------------------------------------------------
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