Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2007-10-22 16:14:12


Author: eric_niebler
Date: 2007-10-22 16:14:11 EDT (Mon, 22 Oct 2007)
New Revision: 40301
URL: http://svn.boost.org/trac/boost/changeset/40301

Log:
needed typeof registrations, from David Jenkins
Added:
   trunk/libs/xpressive/test/test_typeof.cpp (contents, props changed)
Text files modified:
   trunk/boost/xpressive/detail/detail_fwd.hpp | 33 ++++++++++++++++++++++++++++
   trunk/boost/xpressive/detail/static/transforms/as_independent.hpp | 8 ++++++
   trunk/boost/xpressive/proto/make_expr.hpp | 4 +-
   trunk/boost/xpressive/proto/proto_typeof.hpp | 1
   trunk/boost/xpressive/regex_actions.hpp | 16 ++++++++++++-
   trunk/boost/xpressive/xpressive_fwd.hpp | 12 ++++++++++
   trunk/boost/xpressive/xpressive_typeof.hpp | 46 ++++++++++++++++++++++++++++++++++++---
   trunk/libs/xpressive/test/Jamfile.v2 | 1
   8 files changed, 113 insertions(+), 8 deletions(-)

Modified: trunk/boost/xpressive/detail/detail_fwd.hpp
==============================================================================
--- trunk/boost/xpressive/detail/detail_fwd.hpp (original)
+++ trunk/boost/xpressive/detail/detail_fwd.hpp 2007-10-22 16:14:11 EDT (Mon, 22 Oct 2007)
@@ -387,6 +387,39 @@
 
 }}} // namespace boost::xpressive::detail
 
+namespace boost { namespace xpressive { namespace op
+{
+ struct push;
+ struct push_back;
+ struct pop;
+ struct push_front;
+ struct pop_back;
+ struct pop_front;
+ struct back;
+ struct front;
+ struct top;
+ struct first;
+ struct second;
+ struct matched;
+ struct length;
+ struct str;
+ struct insert;
+ struct make_pair;
+
+ template<typename T>
+ struct as;
+ template<typename T>
+ struct static_cast_;
+ template<typename T>
+ struct dynamic_cast_;
+ template<typename T>
+ struct const_cast_;
+ template<typename T>
+ struct construct;
+ template<typename T>
+ struct throw_;
+}}} // namespace boost::xpressive::op
+
 /// INTERNAL ONLY
 namespace boost { namespace xpressive
 {

Modified: trunk/boost/xpressive/detail/static/transforms/as_independent.hpp
==============================================================================
--- trunk/boost/xpressive/detail/static/transforms/as_independent.hpp (original)
+++ trunk/boost/xpressive/detail/static/transforms/as_independent.hpp 2007-10-22 16:14:11 EDT (Mon, 22 Oct 2007)
@@ -21,6 +21,14 @@
 
 namespace boost { namespace xpressive { namespace detail
 {
+ struct keeper_tag
+ {};
+
+ struct lookahead_tag
+ {};
+
+ struct lookbehind_tag
+ {};
 
     template<typename Grammar>
     struct as_lookahead

Modified: trunk/boost/xpressive/proto/make_expr.hpp
==============================================================================
--- trunk/boost/xpressive/proto/make_expr.hpp (original)
+++ trunk/boost/xpressive/proto/make_expr.hpp 2007-10-22 16:14:11 EDT (Mon, 22 Oct 2007)
@@ -241,8 +241,8 @@
                     BOOST_PROTO_VARARG_TEMPLATE_, ~ \
                   , BOOST_PP_SEQ_PUSH_FRONT( \
                         BOOST_PROTO_SEQ_PUSH_FRONT( \
- BOOST_PP_TUPLE_ELEM(4, 2, DATA)\
- , (BOOST_PP_TUPLE_ELEM(4, 3, DATA))\
+ BOOST_PP_TUPLE_ELEM(4, 2, DATA) \
+ , (BOOST_PP_TUPLE_ELEM(4, 3, DATA)) \
                         ) \
                       , BOOST_PP_TUPLE_ELEM(4, 1, DATA) \
                     ) \

Modified: trunk/boost/xpressive/proto/proto_typeof.hpp
==============================================================================
--- trunk/boost/xpressive/proto/proto_typeof.hpp (original)
+++ trunk/boost/xpressive/proto/proto_typeof.hpp 2007-10-22 16:14:11 EDT (Mon, 22 Oct 2007)
@@ -64,6 +64,7 @@
 BOOST_TYPEOF_REGISTER_TYPE(boost::proto::tag::if_else_)
 BOOST_TYPEOF_REGISTER_TYPE(boost::proto::tag::function)
 
+BOOST_TYPEOF_REGISTER_TYPE(boost::proto::exprns_::is_proto_expr)
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::refns_::ref_, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::exprns_::expr, (typename)(typename)(long))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::proto::utility::literal, (typename)(typename))

Modified: trunk/boost/xpressive/regex_actions.hpp
==============================================================================
--- trunk/boost/xpressive/regex_actions.hpp (original)
+++ trunk/boost/xpressive/regex_actions.hpp 2007-10-22 16:14:11 EDT (Mon, 22 Oct 2007)
@@ -32,7 +32,10 @@
 #include <boost/xpressive/detail/core/matcher/attr_begin_matcher.hpp>
 #include <boost/xpressive/detail/core/matcher/predicate_matcher.hpp>
 #include <boost/xpressive/detail/utility/ignore_unused.hpp>
-#include <boost/typeof/std/string.hpp> // very often needed by client code.
+
+// These are very often needed by client code.
+#include <boost/typeof/std/map.hpp>
+#include <boost/typeof/std/string.hpp>
 
 // Doxygen can't handle proto :-(
 #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED
@@ -720,18 +723,24 @@
       , ((op::const_cast_)(typename))
     )
 
+ /// val()
+ ///
     template<typename T>
     value<T> const val(T const &t)
     {
         return value<T>(t);
     }
 
+ /// ref()
+ ///
     template<typename T>
     reference<T> const ref(T &t)
     {
         return reference<T>(t);
     }
 
+ /// cref()
+ ///
     template<typename T>
     reference<T const> const cref(T const &t)
     {
@@ -746,7 +755,10 @@
     ///
     detail::let_<proto::terminal<detail::let_tag>::type> const let = {{{}}};
 
- template<typename T, int I = 0, typename Dummy = proto::is_proto_expr>
+ /// placeholder<T>, for defining a placeholder to stand in fo
+ /// a variable of type T in a semantic action.
+ ///
+ template<typename T, int I, typename Dummy>
     struct placeholder
     {
         typedef placeholder<T, I, Dummy> this_type;

Modified: trunk/boost/xpressive/xpressive_fwd.hpp
==============================================================================
--- trunk/boost/xpressive/xpressive_fwd.hpp (original)
+++ trunk/boost/xpressive/xpressive_fwd.hpp 2007-10-22 16:14:11 EDT (Mon, 22 Oct 2007)
@@ -133,6 +133,18 @@
>
     struct regex_compiler;
 
+ template<typename T>
+ struct value;
+
+ template<typename T>
+ struct reference;
+
+ template<typename T>
+ struct local;
+
+ template<typename T, int I = 0, typename Dummy = proto::is_proto_expr>
+ struct placeholder;
+
     ///////////////////////////////////////////////////////////////////////////////
     // Common typedefs
     //

Modified: trunk/boost/xpressive/xpressive_typeof.hpp
==============================================================================
--- trunk/boost/xpressive/xpressive_typeof.hpp (original)
+++ trunk/boost/xpressive/xpressive_typeof.hpp 2007-10-22 16:14:11 EDT (Mon, 22 Oct 2007)
@@ -20,7 +20,7 @@
 # include <boost/typeof/std/locale.hpp>
 #endif
 #include <boost/xpressive/proto/proto_typeof.hpp>
-#include <boost/xpressive/xpressive_fwd.hpp>
+#include <boost/xpressive/detail/detail_fwd.hpp>
 
 #include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
 
@@ -34,6 +34,15 @@
 BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::lookbehind_tag)
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::generic_quant_tag, (unsigned int)(unsigned int))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::basic_regex, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::word_boundary, (bool))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::value, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::reference, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::local, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::placeholder, (typename)(int)(typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::tracking_ptr, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::regex_impl, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::let_, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::action_arg, (typename)(typename))
 
 ///////////////////////////////////////////////////////////////////////////////
 // Placeholders
@@ -44,11 +53,9 @@
 BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::assert_eol_placeholder)
 BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::logical_newline_placeholder)
 BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::self_placeholder)
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::string_placeholder, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::assert_word_placeholder, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::range_placeholder, (typename))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::regex_placeholder, (typename)(bool))
-BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::literal_placeholder, (typename)(bool))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::attribute_placeholder, (typename))
 
 ///////////////////////////////////////////////////////////////////////////////
 // Matchers
@@ -63,6 +70,7 @@
 BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::mark_end_matcher)
 BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::repeat_begin_matcher)
 BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::alternate_end_matcher)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::detail::attr_end_matcher)
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::assert_bol_matcher, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::assert_eol_matcher, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::literal_matcher, (typename)(bool)(bool))
@@ -84,6 +92,36 @@
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::lookahead_matcher, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::lookbehind_matcher, (typename))
 BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::set_matcher, (typename)(int))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::predicate_matcher, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::action_matcher, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::attr_matcher, (typename)(typename)(bool))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::detail::attr_begin_matcher, (typename))
+
+///////////////////////////////////////////////////////////////////////////////
+// Ops
+//
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::push)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::push_back)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::pop)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::push_front)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::pop_back)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::pop_front)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::back)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::front)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::top)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::first)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::second)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::matched)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::length)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::str)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::insert)
+BOOST_TYPEOF_REGISTER_TYPE(boost::xpressive::op::make_pair)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::op::as, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::op::static_cast_, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::op::dynamic_cast_, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::op::const_cast_, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::op::construct, (typename))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::xpressive::op::throw_, (typename))
 
 ///////////////////////////////////////////////////////////////////////////////
 // Modifiers

Modified: trunk/libs/xpressive/test/Jamfile.v2
==============================================================================
--- trunk/libs/xpressive/test/Jamfile.v2 (original)
+++ trunk/libs/xpressive/test/Jamfile.v2 2007-10-22 16:14:11 EDT (Mon, 22 Oct 2007)
@@ -67,5 +67,6 @@
          [ compile test_regex_token_iterator.cpp ]
          [ compile test_regex_traits.cpp ]
          [ compile test_sub_match.cpp ]
+# [ compile test_typeof.cpp : <define>BOOST_TYPEOF_EMULATION=1 <define>BOOST_TYPEOF_LIMIT_SIZE=200 ]
     ;
 

Added: trunk/libs/xpressive/test/test_typeof.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/xpressive/test/test_typeof.cpp 2007-10-22 16:14:11 EDT (Mon, 22 Oct 2007)
@@ -0,0 +1,88 @@
+///////////////////////////////////////////////////////////////////////////////
+// test_typeof.cpp
+//
+// Copyright 2007 David Jenkins. 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 <string>
+#include <map>
+#include <boost/version.hpp>
+#include <boost/xpressive/xpressive_static.hpp>
+#include <boost/xpressive/regex_actions.hpp>
+#include <boost/xpressive/xpressive_typeof.hpp>
+#include <boost/typeof/std/stack.hpp>
+#include <boost/typeof/std/list.hpp>
+#include <boost/typeof/std/map.hpp>
+
+// DJ: I couldn't find these registrations anywhere else, so I put them here
+// They are necessary for this program to compile
+#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::mpl::int_, (int))
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::reference_wrapper, (typename))
+
+namespace xp = boost::xpressive;
+
+int main()
+{
+ using namespace boost::xpressive;
+ // regexes from test_actions.cpp
+ std::string result;
+ BOOST_PROTO_AUTO(dummy1, (+_w)[ xp::ref(result) += _ ] >> *(' ' >> (+_w)[ xp::ref(result) += ',' + _ ]));
+ BOOST_PROTO_AUTO(dummy2, (+_w)[ xp::ref(result) += _ ] >> *(' ' >> (+_w)[ xp::ref(result) += ',' + _ ]) >> repeat<4>(_));
+ std::list<int> result2;
+ BOOST_PROTO_AUTO(dummy3, (+_d)[ xp::ref(result2)->*push_back( as<int>(_) ) ]
+ >> *(' ' >> (+_d)[ xp::ref(result2)->*push_back( as<int>(_) ) ]));
+ std::map<std::string, int> result3;
+ BOOST_PROTO_AUTO(dummy4, ( (s1= +_w) >> "=>" >> (s2= +_d) )[ xp::ref(result3)[s1] = as<int>(s2) ]);
+ placeholder< std::map<std::string, int> > const _map = {{}};
+ BOOST_PROTO_AUTO(dummy5,( (s1= +_w) >> "=>" >> (s2= +_d) )[ _map[s1] = as<int>(s2) ]);
+
+ local<int> left, right;
+ std::stack<int> stack_;
+ reference<std::stack<int> > stack(stack_);
+ cregex expression2;
+ BOOST_PROTO_AUTO(group, '(' >> by_ref(expression2) >> ')');
+ BOOST_PROTO_AUTO(factor, (+_d)[ push(stack, as<int>(_)) ] | group);
+ //BOOST_PROTO_AUTO(term, factor >> *(
+ // ('*' >> factor)
+ // [ right = top(stack)
+ // , pop(stack)
+ // , left = top(stack)
+ // , pop(stack)
+ // , push(stack, left * right)
+ // ]
+ // | ('/' >> factor)
+ // [ right = top(stack)
+ // , pop(stack)
+ // , left = top(stack)
+ // , pop(stack)
+ // , push(stack, left / right)
+ // ]
+ // ));
+ //BOOST_PROTO_AUTO(expression, term >> *(
+ // ('+' >> term)
+ // [ right = top(stack)
+ // , pop(stack)
+ // , left = top(stack)
+ // , pop(stack)
+ // , push(stack, left + right)
+ // ]
+ // | ('-' >> term)
+ // [ right = top(stack)
+ // , pop(stack)
+ // , left = top(stack)
+ // , pop(stack)
+ // , push(stack, left - right)
+ // ]
+ // ));
+
+ // regexes from test_symbols.cpp
+ std::string result10;
+ std::map<std::string,std::string> map10;
+ BOOST_PROTO_AUTO(dummy10, (a1=map10)[ xp::ref(result10) = a1 ] >> *(' ' >> (a1=map10)[ xp::ref(result10) += ',' + a1 ]));
+ BOOST_PROTO_AUTO(dummy11, (a1=map10)[ xp::ref(result10) = a1 ]
+ >> *((a1=map10)[ xp::ref(result10) += ',', xp::ref(result10) += a1 ]));
+
+ return 0;
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk