Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58047 - in trunk/boost/spirit: home home/karma home/karma/auto home/qi home/qi/auto home/support/auto include
From: hartmut.kaiser_at_[hidden]
Date: 2009-11-29 18:30:15


Author: hkaiser
Date: 2009-11-29 18:30:14 EST (Sun, 29 Nov 2009)
New Revision: 58047
URL: http://svn.boost.org/trac/boost/changeset/58047

Log:
Spirit: fixes to karma::auto_, added qi::auto_
Added:
   trunk/boost/spirit/home/qi/auto/
   trunk/boost/spirit/home/qi/auto.hpp (contents, props changed)
   trunk/boost/spirit/home/qi/auto/auto.hpp (contents, props changed)
   trunk/boost/spirit/home/qi/auto/create_parser.hpp (contents, props changed)
   trunk/boost/spirit/home/qi/auto/meta_create.hpp (contents, props changed)
   trunk/boost/spirit/include/qi_auto.hpp (contents, props changed)
Text files modified:
   trunk/boost/spirit/home/karma/auto.hpp | 4 ++--
   trunk/boost/spirit/home/karma/auto/auto.hpp | 9 ++++++---
   trunk/boost/spirit/home/karma/auto/create_generator.hpp | 2 +-
   trunk/boost/spirit/home/karma/auto/meta_create.hpp | 8 +++++---
   trunk/boost/spirit/home/qi.hpp | 1 +
   trunk/boost/spirit/home/support/auto/meta_create.hpp | 3 +++
   6 files changed, 18 insertions(+), 9 deletions(-)

Modified: trunk/boost/spirit/home/karma/auto.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/auto.hpp (original)
+++ trunk/boost/spirit/home/karma/auto.hpp 2009-11-29 18:30:14 EST (Sun, 29 Nov 2009)
@@ -3,8 +3,8 @@
 // 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)
 
-#if !defined(BOOST_SPIRIT_KARMA_AUTO_NOV_29_0324PM)
-#define BOOST_SPIRIT_KARMA_AUTO_NOV_29_0324PM
+#if !defined(BOOST_SPIRIT_KARMA_AUTO_NOV_29_2009_0324PM)
+#define BOOST_SPIRIT_KARMA_AUTO_NOV_29_2009_0324PM
 
 #if defined(_MSC_VER)
 #pragma once

Modified: trunk/boost/spirit/home/karma/auto/auto.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/auto/auto.hpp (original)
+++ trunk/boost/spirit/home/karma/auto/auto.hpp 2009-11-29 18:30:14 EST (Sun, 29 Nov 2009)
@@ -3,8 +3,8 @@
 // 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)
 
-#if !defined(BOOST_SPIRIT_KARMA_STREAM_MAY_01_2007_0310PM)
-#define BOOST_SPIRIT_KARMA_STREAM_MAY_01_2007_0310PM
+#if !defined(BOOST_SPIRIT_KARMA_AUTO_NOV_29_2009_0339PM)
+#define BOOST_SPIRIT_KARMA_AUTO_NOV_29_2009_0339PM
 
 #if defined(_MSC_VER)
 #pragma once
@@ -13,11 +13,14 @@
 #include <boost/spirit/home/support/common_terminals.hpp>
 #include <boost/spirit/home/support/info.hpp>
 #include <boost/spirit/home/support/container.hpp>
+#include <boost/spirit/home/support/assert_msg.hpp>
 #include <boost/spirit/home/support/detail/hold_any.hpp>
 #include <boost/spirit/home/karma/domain.hpp>
 #include <boost/spirit/home/karma/meta_compiler.hpp>
 #include <boost/spirit/home/karma/delimit_out.hpp>
+#include <boost/spirit/home/karma/generator.hpp>
 #include <boost/spirit/home/karma/auto/create_generator.hpp>
+#include <boost/mpl/bool.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit
@@ -38,7 +41,7 @@
     ///////////////////////////////////////////////////////////////////////////
     template <typename Modifiers>
     struct auto_generator
- : primitive_generator<auto_generator<Modifiers> >
+ : generator<auto_generator<Modifiers> >
     {
         typedef mpl::int_<generator_properties::all_properties> properties;
 

Modified: trunk/boost/spirit/home/karma/auto/create_generator.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/auto/create_generator.hpp (original)
+++ trunk/boost/spirit/home/karma/auto/create_generator.hpp 2009-11-29 18:30:14 EST (Sun, 29 Nov 2009)
@@ -11,6 +11,7 @@
 #endif
 
 #include <boost/spirit/home/karma/auto/meta_create.hpp>
+#include <boost/proto/deep_copy.hpp>
 
 namespace boost { namespace spirit { namespace karma
 {
@@ -36,7 +37,6 @@
     {
         return generator_creator<T>::call();
     }
-
 }}}
 
 #endif

Modified: trunk/boost/spirit/home/karma/auto/meta_create.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/auto/meta_create.hpp (original)
+++ trunk/boost/spirit/home/karma/auto/meta_create.hpp 2009-11-29 18:30:14 EST (Sun, 29 Nov 2009)
@@ -12,12 +12,16 @@
 
 #include <boost/spirit/home/karma/domain.hpp>
 #include <boost/spirit/home/support/common_terminals.hpp>
-
 #include <boost/spirit/home/support/auto/meta_create.hpp>
 
 #include <boost/utility/enable_if.hpp>
 #include <boost/variant.hpp>
 #include <boost/optional.hpp>
+#include <boost/config.hpp>
+#include <boost/mpl/fold.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/push_back.hpp>
+#include <boost/fusion/include/as_vector.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
@@ -322,7 +326,6 @@
         typedef spirit::long_double_type const& type;
         static type call() { return spirit::long_double; }
     };
-
 }}}
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -340,7 +343,6 @@
             return karma::meta_create<data_type>::call();
         }
     };
-
 }}
 
 #endif

Modified: trunk/boost/spirit/home/qi.hpp
==============================================================================
--- trunk/boost/spirit/home/qi.hpp (original)
+++ trunk/boost/spirit/home/qi.hpp 2009-11-29 18:30:14 EST (Sun, 29 Nov 2009)
@@ -12,6 +12,7 @@
 #endif
 
 #include <boost/spirit/home/qi/action.hpp>
+#include <boost/spirit/home/qi/auto.hpp>
 #include <boost/spirit/home/qi/auxiliary.hpp>
 #include <boost/spirit/home/qi/char.hpp>
 #include <boost/spirit/home/qi/binary.hpp>

Added: trunk/boost/spirit/home/qi/auto.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/qi/auto.hpp 2009-11-29 18:30:14 EST (Sun, 29 Nov 2009)
@@ -0,0 +1,17 @@
+/*=============================================================================
+ Copyright (c) 2001-2009 Hartmut Kaiser
+
+ 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)
+==============================================================================*/
+
+#if !defined(BOOST_SPIRIT_AUTO_NOV_29_2009_0335PM)
+#define BOOST_SPIRIT_AUTO_NOV_29_2009_0335PM
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/qi/auto/auto.hpp>
+
+#endif

Added: trunk/boost/spirit/home/qi/auto/auto.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/qi/auto/auto.hpp 2009-11-29 18:30:14 EST (Sun, 29 Nov 2009)
@@ -0,0 +1,97 @@
+// Copyright (c) 2001-2009 Hartmut Kaiser
+//
+// 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)
+
+#if !defined(BOOST_SPIRIT_QI_AUTO_NOV_29_2009_0336PM)
+#define BOOST_SPIRIT_QI_AUTO_NOV_29_2009_0336PM
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/info.hpp>
+#include <boost/spirit/home/support/container.hpp>
+#include <boost/spirit/home/support/detail/hold_any.hpp>
+#include <boost/spirit/home/qi/domain.hpp>
+#include <boost/spirit/home/qi/meta_compiler.hpp>
+#include <boost/spirit/home/qi/skip_over.hpp>
+#include <boost/spirit/home/qi/parser.hpp>
+#include <boost/spirit/home/qi/auto/create_parser.hpp>
+#include <boost/mpl/bool.hpp>
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // Enablers
+ ///////////////////////////////////////////////////////////////////////////
+ template <>
+ struct use_terminal<qi::domain, tag::auto_> // enables auto_
+ : mpl::true_ {};
+}}
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace qi
+{
+ using spirit::auto_;
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Modifiers>
+ struct auto_parser
+ : parser<auto_parser<Modifiers> >
+ {
+ template <typename Context, typename Iterator>
+ struct attribute
+ {
+ typedef spirit::hold_any type;
+ };
+
+ auto_parser(Modifiers const& modifiers)
+ : modifiers_(modifiers) {}
+
+ template <typename Iterator, typename Context, typename Skipper
+ , typename Attribute, typename Expr>
+ bool parse_auto(Iterator& first, Iterator const& last
+ , Context& context, Skipper const& skipper, Attribute& attr
+ , Expr const& expr) const
+ {
+ return compile<qi::domain>(expr, modifiers_)
+ .parse(first, last, context, skipper, attr);
+ }
+
+ template <typename Iterator, typename Context, typename Skipper
+ , typename Attribute>
+ bool parse(Iterator& first, Iterator const& last
+ , Context& context, Skipper const& skipper, Attribute& attr) const
+ {
+ return parse_auto(first, last, context, skipper, attr
+ , create_parser<Attribute>());
+ }
+
+ template <typename Context>
+ info what(Context& /*context*/) const
+ {
+ return info("auto_");
+ }
+
+ Modifiers modifiers_;
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Generator generators: make_xxx function (objects)
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Modifiers>
+ struct make_primitive<tag::auto_, Modifiers>
+ {
+ typedef auto_parser<Modifiers> result_type;
+
+ result_type operator()(unused_type, Modifiers const& modifiers) const
+ {
+ return result_type(modifiers);
+ }
+ };
+}}}
+
+#endif

Added: trunk/boost/spirit/home/qi/auto/create_parser.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/qi/auto/create_parser.hpp 2009-11-29 18:30:14 EST (Sun, 29 Nov 2009)
@@ -0,0 +1,42 @@
+// Copyright (c) 2001-2009 Hartmut Kaiser
+//
+// 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)
+
+#if !defined(BOOST_SPIRIT_QI_CREATE_NOV_21_2009_0444PM)
+#define BOOST_SPIRIT_QI_CREATE_NOV_21_2009_0444PM
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/qi/auto/meta_create.hpp>
+#include <boost/proto/deep_copy.hpp>
+
+namespace boost { namespace spirit { namespace qi
+{
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T>
+ struct parser_creator
+ {
+ typedef spirit::meta_create<qi::domain, T> creator_type;
+ typedef typename proto::result_of::deep_copy<
+ typename creator_type::type
+ >::type type;
+
+ static type call()
+ {
+ return proto::deep_copy(creator_type::call());
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename T>
+ typename parser_creator<T>::type
+ create_parser()
+ {
+ return parser_creator<T>::call();
+ }
+}}}
+
+#endif

Added: trunk/boost/spirit/home/qi/auto/meta_create.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/qi/auto/meta_create.hpp 2009-11-29 18:30:14 EST (Sun, 29 Nov 2009)
@@ -0,0 +1,279 @@
+// Copyright (c) 2001-2009 Hartmut Kaiser
+//
+// 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)
+
+#if !defined(BOOST_SPIRIT_QI_META_CREATE_NOV_21_2009_0432PM)
+#define BOOST_SPIRIT_QI_META_CREATE_NOV_21_2009_0432PM
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/qi/domain.hpp>
+#include <boost/spirit/home/support/common_terminals.hpp>
+#include <boost/spirit/home/support/auto/meta_create.hpp>
+
+#include <boost/utility/enable_if.hpp>
+#include <boost/variant.hpp>
+#include <boost/optional.hpp>
+#include <boost/config.hpp>
+#include <boost/mpl/fold.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/push_back.hpp>
+#include <boost/fusion/include/as_vector.hpp>
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace qi
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // compatible STL containers
+ template <typename Container>
+ struct meta_create_container
+ {
+ struct make_dereference
+ {
+ template <typename RT, typename T_>
+ static RT call(T_ const& t)
+ {
+ // we map STL containers to the Kleene star
+ return *t;
+ }
+ };
+
+ typedef spirit::detail::make_unary_proto_expr<
+ typename Container::value_type, proto::tag::dereference
+ , make_dereference, qi::domain
+ > make_proto_expr;
+
+ typedef typename make_proto_expr::type type;
+
+ static type call()
+ {
+ return make_proto_expr::call();
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Fusion sequences
+ template <typename Sequence>
+ struct meta_create_sequence
+ {
+ struct make_shift_right
+ {
+ template <typename RT, typename T1, typename T2>
+ static RT call(T1 const& t1, T2 const& t2)
+ {
+ return t1 >> t2;
+ }
+ };
+
+ // create a mpl sequence from the given fusion sequence
+ typedef typename mpl::fold<
+ typename fusion::result_of::as_vector<Sequence>::type
+ , mpl::vector<>, mpl::push_back<mpl::_, mpl::_>
+ >::type sequence_type;
+
+ typedef spirit::detail::make_nary_proto_expr<
+ sequence_type, proto::tag::shift_right, make_shift_right, qi::domain
+ > make_proto_expr;
+
+ typedef typename make_proto_expr::type type;
+
+ static type call()
+ {
+ return make_proto_expr::call();
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // the default is to use the standard streaming operator unless it's a
+ // STL container or a fusion sequence
+ template <typename T, typename Enable = void>
+ struct meta_create_impl;
+
+ template <typename T>
+ struct meta_create_impl<T
+ , typename enable_if<traits::is_container<T> >::type>
+ : meta_create_container<T> {};
+
+ template <typename T>
+ struct meta_create_impl<T
+ , typename enable_if<fusion::traits::is_sequence<T> >::type>
+ : meta_create_sequence<T> {};
+
+ template <typename T, typename Enable = void>
+ struct meta_create : meta_create_impl<T> {};
+
+ ///////////////////////////////////////////////////////////////////////////
+ // optional
+ template <typename T>
+ struct meta_create<boost::optional<T> >
+ {
+ struct make_negate
+ {
+ template <typename RT, typename T_>
+ static RT call(T_ const& t)
+ {
+ return -t;
+ }
+ };
+
+ typedef spirit::detail::make_unary_proto_expr<
+ T, proto::tag::negate, make_negate, qi::domain
+ > make_proto_expr;
+
+ typedef typename make_proto_expr::type type;
+
+ static type call()
+ {
+ return make_proto_expr::call();
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // alternatives
+ template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
+ struct meta_create<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
+ {
+ struct make_bitwise_or
+ {
+ template <typename RT, typename T1_, typename T2_>
+ static RT call(T1_ const& t1, T2_ const& t2)
+ {
+ return t1 | t2;
+ }
+ };
+
+ typedef spirit::detail::make_nary_proto_expr<
+ typename boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>::types
+ , proto::tag::bitwise_or, make_bitwise_or, qi::domain
+ > make_proto_expr;
+
+ typedef typename make_proto_expr::type type;
+
+ static type call()
+ {
+ return make_proto_expr::call();
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////////
+ // predefined specializations for primitive components
+
+ // character generator
+ template <>
+ struct meta_create<char>
+ {
+ typedef spirit::standard::char_type const& type;
+ static type call() { return spirit::standard::char_; }
+ };
+ template <>
+ struct meta_create<wchar_t>
+ {
+ typedef spirit::standard_wide::char_type const& type;
+ static type call() { return spirit::standard_wide::char_; }
+ };
+
+ // boolean generator
+ template <>
+ struct meta_create<bool>
+ {
+ typedef spirit::bool__type const& type;
+ static type call() { return spirit::bool_; }
+ };
+
+ // integral generators
+ template <>
+ struct meta_create<int>
+ {
+ typedef spirit::int__type const& type;
+ static type call() { return spirit::int_; }
+ };
+ template <>
+ struct meta_create<short>
+ {
+ typedef spirit::short__type const& type;
+ static type call() { return spirit::short_; }
+ };
+ template <>
+ struct meta_create<long>
+ {
+ typedef spirit::long__type const& type;
+ static type call() { return spirit::long_; }
+ };
+ template <>
+ struct meta_create<unsigned int>
+ {
+ typedef spirit::uint__type const& type;
+ static type call() { return spirit::uint_; }
+ };
+#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
+ template <>
+ struct meta_create<unsigned short>
+ {
+ typedef spirit::ushort__type const& type;
+ static type call() { return spirit::ushort_; }
+ };
+#endif
+ template <>
+ struct meta_create<unsigned long>
+ {
+ typedef spirit::ulong__type const& type;
+ static type call() { return spirit::ulong_; }
+ };
+
+#ifdef BOOST_HAS_LONG_LONG
+ template <>
+ struct meta_create<boost::long_long_type>
+ {
+ typedef spirit::long_long_type const& type;
+ static type call() { return spirit::long_long; }
+ };
+ template <>
+ struct meta_create<boost::ulong_long_type>
+ {
+ typedef spirit::ulong_long_type const& type;
+ static type call() { return spirit::ulong_long; }
+ };
+#endif
+
+ // floating point generators
+ template <>
+ struct meta_create<float>
+ {
+ typedef spirit::float__type const& type;
+ static type call() { return spirit::float_; }
+ };
+ template <>
+ struct meta_create<double>
+ {
+ typedef spirit::double__type const& type;
+ static type call() { return spirit::double_; }
+ };
+ template <>
+ struct meta_create<long double>
+ {
+ typedef spirit::long_double_type const& type;
+ static type call() { return spirit::long_double; }
+ };
+}}}
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit
+{
+ // dispatch this to the qi related specializations
+ template <typename T>
+ struct meta_create<qi::domain, T>
+ {
+ typedef typename spirit::detail::remove_const_ref<T>::type data_type;
+ typedef typename qi::meta_create<data_type>::type type;
+
+ static type call()
+ {
+ return qi::meta_create<data_type>::call();
+ }
+ };
+}}
+
+#endif

Modified: trunk/boost/spirit/home/support/auto/meta_create.hpp
==============================================================================
--- trunk/boost/spirit/home/support/auto/meta_create.hpp (original)
+++ trunk/boost/spirit/home/support/auto/meta_create.hpp 2009-11-29 18:30:14 EST (Sun, 29 Nov 2009)
@@ -12,10 +12,13 @@
 
 #include <boost/spirit/home/support/unused.hpp>
 
+#include <boost/proto/proto.hpp>
+#include <boost/utility/result_of.hpp>
 #include <boost/type_traits/add_const.hpp>
 #include <boost/type_traits/add_reference.hpp>
 #include <boost/type_traits/remove_const.hpp>
 #include <boost/type_traits/remove_reference.hpp>
+#include <boost/fusion/include/fold.hpp>
 
 namespace boost { namespace spirit
 {

Added: trunk/boost/spirit/include/qi_auto.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/include/qi_auto.hpp 2009-11-29 18:30:14 EST (Sun, 29 Nov 2009)
@@ -0,0 +1,18 @@
+/*=============================================================================
+ Copyright (c) 2001-2009 Joel de Guzman
+ Copyright (c) 2001-2009 Hartmut Kaiser
+ http://spirit.sourceforge.net/
+
+ 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)
+=============================================================================*/
+#ifndef BOOST_SPIRIT_INCLUDE_QI_AUTO
+#define BOOST_SPIRIT_INCLUDE_QI_AUTO
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/qi/auto.hpp>
+
+#endif


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