Boost logo

Boost-Commit :

From: hartmut.kaiser_at_[hidden]
Date: 2008-04-26 16:12:14


Author: hkaiser
Date: 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
New Revision: 44786
URL: http://svn.boost.org/trac/boost/changeset/44786

Log:
Spirit: applied patch from #1886, closed now.
Text files modified:
   trunk/boost/spirit/home/lex/lexer/lexertl/lexertl_functor.hpp | 5 ++-
   trunk/boost/spirit/home/lex/lexer/lexertl/lexertl_static_functor.hpp | 2
   trunk/boost/spirit/home/qi/auxiliary/primitives.hpp | 12 +++++-----
   trunk/boost/spirit/home/qi/skip.hpp | 2
   trunk/boost/spirit/home/support/argument.hpp | 38 ++++++++++++++++++++++++++++++++-
   trunk/boost/spirit/home/support/as_variant.hpp | 45 +++++++++++++++++++++++++++++++++++----
   trunk/boost/spirit/home/support/detail/action_dispatch.hpp | 4 +-
   trunk/boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp | 2
   trunk/boost/spirit/home/support/iterators/detail/combine_policies.hpp | 2
   trunk/boost/spirit/home/support/iterators/detail/first_owner_policy.hpp | 2
   trunk/boost/spirit/home/support/iterators/detail/input_iterator_policy.hpp | 4 +-
   trunk/boost/spirit/home/support/iterators/detail/lex_input_policy.hpp | 8 +++---
   trunk/boost/spirit/home/support/iterators/detail/multi_pass.hpp | 18 ++++++++--------
   trunk/boost/spirit/home/support/iterators/detail/no_check_policy.hpp | 2
   trunk/boost/spirit/home/support/iterators/detail/ref_counted_policy.hpp | 4 +-
   trunk/boost/spirit/home/support/iterators/detail/split_functor_input_policy.hpp | 4 +-
   trunk/boost/spirit/home/support/iterators/detail/split_std_deque_policy.hpp | 2
   17 files changed, 113 insertions(+), 43 deletions(-)

Modified: trunk/boost/spirit/home/lex/lexer/lexertl/lexertl_functor.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/lexertl_functor.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/lexertl_functor.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -89,7 +89,8 @@
           : Data<Iterator, mpl::false_, mpl::false_>
         {
             typedef Data<Iterator, mpl::false_, mpl::false_> base_type;
-
+ typedef std::size_t state_type;
+
             // initialize the shared data
             template <typename IterData>
             Data (IterData const& data_, Iterator& first_, Iterator const& last_)
@@ -354,7 +355,7 @@
         
         // we don't need this, but it must be there
         template <typename MultiPass>
- static void destroy(MultiPass const& mp)
+ static void destroy(MultiPass const&)
         {}
     };
 

Modified: trunk/boost/spirit/home/lex/lexer/lexertl/lexertl_static_functor.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/lexertl_static_functor.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/lexertl_static_functor.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -345,7 +345,7 @@
         
         // we don't need this, but it must be there
         template <typename MultiPass>
- static void destroy(MultiPass const& mp)
+ static void destroy(MultiPass const&)
         {}
     };
 

Modified: trunk/boost/spirit/home/qi/auxiliary/primitives.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/auxiliary/primitives.hpp (original)
+++ trunk/boost/spirit/home/qi/auxiliary/primitives.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -32,10 +32,10 @@
           , typename Iterator, typename Context
           , typename Skipper, typename Attribute>
         static bool parse(
- Component const& component
+ Component const& /*component*/
           , Iterator& first, Iterator const& last
- , Context& context, Skipper const& skipper
- , Attribute& attr)
+ , Context& /*context*/, Skipper const& skipper
+ , Attribute& /*attr*/)
         {
             qi::skip(first, last, skipper);
             return Parser::test(first, last);
@@ -66,10 +66,10 @@
           , typename Iterator, typename Context
           , typename Skipper, typename Attribute>
         static bool parse(
- Component const& component
+ Component const& /*component*/
           , Iterator& first, Iterator const& last
- , Context& context, Skipper const& skipper
- , Attribute& attr)
+ , Context& /*context*/, Skipper const& skipper
+ , Attribute& /*attr*/)
         {
             qi::skip(first, last, skipper);
 

Modified: trunk/boost/spirit/home/qi/skip.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/skip.hpp (original)
+++ trunk/boost/spirit/home/qi/skip.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -26,7 +26,7 @@
     }
 
     template <typename Iterator>
- inline void skip(Iterator& first, Iterator const& last, unused_type)
+ inline void skip(Iterator&, Iterator const&, unused_type)
     {
     }
 }}}

Modified: trunk/boost/spirit/home/support/argument.hpp
==============================================================================
--- trunk/boost/spirit/home/support/argument.hpp (original)
+++ trunk/boost/spirit/home/support/argument.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -167,17 +167,50 @@
         }
     };
 
- namespace arg_names
+ struct lexer_state
     {
+ typedef mpl::true_ no_nullary;
 
+ template <typename Env>
+ struct result
+ {
+ typedef typename
+ mpl::at_c<typename Env::args_type, 3>::type::state_type
+ type;
+ };
+
+ template <typename Env>
+ typename result<Env>::type
+ eval(Env const& env) const
+ {
+ return fusion::at_c<3>(env.args()).state;
+ }
+ };
+
+ namespace arg_names
+ {
+ // _0 refers to the whole attribute as generated by the lhs parser
         phoenix::actor<attribute_context> const _0 = attribute_context();
-
+
+ // _1, _2, ... refer to the attributes of the single components the lhs
+ // parser is composed of
         phoenix::actor<argument<0> > const _1 = argument<0>();
         phoenix::actor<argument<1> > const _2 = argument<1>();
         phoenix::actor<argument<2> > const _3 = argument<2>();
 
+ // 'pass' may be used to make a match fail in retrospective
         phoenix::actor<phoenix::argument<2> > const pass = phoenix::argument<2>();
 
+ // 'id' may be used in a lexer semantic action to refer to the token id
+ // of a matched token
+ phoenix::actor<phoenix::argument<1> > const id = phoenix::argument<1>();
+
+ // 'state' may be used in a lexer semantic action to refer to the
+ // current lexer state
+ phoenix::actor<lexer_state> const state = lexer_state();
+
+ // _val refers to the |return| value of a rule
+ // _r0, _r1, ... refer to the rule arguments
         phoenix::actor<attribute<0> > const _val = attribute<0>();
         phoenix::actor<attribute<0> > const _r0 = attribute<0>();
         phoenix::actor<attribute<1> > const _r1 = attribute<1>();
@@ -187,6 +220,7 @@
         BOOST_PP_REPEAT_FROM_TO(
             3, SPIRIT_ARG_LIMIT, SPIRIT_DECLARE_ARG, _)
 
+ // _a, _b, ... refer to the local variables of a rule
         phoenix::actor<local_var<0> > const _a = local_var<0>();
         phoenix::actor<local_var<1> > const _b = local_var<1>();
         phoenix::actor<local_var<2> > const _c = local_var<2>();

Modified: trunk/boost/spirit/home/support/as_variant.hpp
==============================================================================
--- trunk/boost/spirit/home/support/as_variant.hpp (original)
+++ trunk/boost/spirit/home/support/as_variant.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -14,6 +14,11 @@
 #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
 #include <boost/variant/variant_fwd.hpp>
+#include <boost/mpl/fold.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/push_back.hpp>
+#include <boost/mpl/contains.hpp>
+#include <boost/type_traits/is_same.hpp>
 
 namespace boost { namespace spirit { namespace detail
 {
@@ -50,6 +55,22 @@
 #undef BOOST_FUSION_NEXT_CALL_ITERATOR
 #undef BOOST_FUSION_VALUE_OF_ITERATOR
 
+ template <typename Sequence>
+ struct generate_variant
+ {
+ // build a variant generator being able to generate a variant holding
+ // all of the types as given in the typelist
+ typedef typename
+ detail::as_variant<fusion::result_of::size<Sequence>::value>
+ gen;
+
+ // use this generator to create the actual variant
+ typedef typename gen::template apply<
+ typename fusion::result_of::begin<Sequence>::type
+ >::type
+ type;
+ };
+
 }}}
 
 namespace boost { namespace spirit
@@ -57,11 +78,25 @@
     template <typename Sequence>
     struct as_variant
     {
- typedef typename
- detail::as_variant<fusion::result_of::size<Sequence>::value>
- gen;
- typedef typename gen::
- template apply<typename fusion::result_of::begin<Sequence>::type>::type
+ // make sure each of the types occurs only once in the type list
+ typedef typename
+ mpl::fold<
+ Sequence, mpl::vector<>,
+ mpl::if_<
+ mpl::contains<mpl::_1, mpl::_2>,
+ mpl::_1, mpl::push_back<mpl::_1, mpl::_2>
+ >
+ >::type
+ new_sequence;
+
+ // if there is only one type in the list of types we strip off the
+ // variant all together
+ typedef typename
+ mpl::eval_if<
+ mpl::equal_to<mpl::size<new_sequence>, mpl::int_<1> >,
+ mpl::deref<mpl::front<Sequence> >,
+ detail::generate_variant<new_sequence>
+ >::type
         type;
     };
 }}

Modified: trunk/boost/spirit/home/support/detail/action_dispatch.hpp
==============================================================================
--- trunk/boost/spirit/home/support/detail/action_dispatch.hpp (original)
+++ trunk/boost/spirit/home/support/detail/action_dispatch.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -53,7 +53,7 @@
     template <typename RT, typename A0
       , typename Attribute, typename Context>
     bool action_dispatch(RT(*f)(A0)
- , Attribute& attr, Context& context)
+ , Attribute& attr, Context&)
     {
         f(attr);
         return true;
@@ -61,7 +61,7 @@
 
     template <typename RT, typename Attribute, typename Context>
     bool action_dispatch(RT(*f)()
- , Attribute& attr, Context& context)
+ , Attribute&, Context&)
     {
         f();
         return true;

Modified: trunk/boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/detail/buf_id_check_policy.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -76,7 +76,7 @@
             }
 
             template <typename MultiPass>
- static void destroy(MultiPass& mp)
+ static void destroy(MultiPass&)
             {}
 
         protected:

Modified: trunk/boost/spirit/home/support/iterators/detail/combine_policies.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/detail/combine_policies.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/detail/combine_policies.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -344,7 +344,7 @@
       : Storage
     {
         multi_pass_unique() {}
- multi_pass_unique(T const& /*x*/) {}
+ multi_pass_unique(T const&) {}
 
         template <typename MultiPass>
         static void destroy(MultiPass& mp)

Modified: trunk/boost/spirit/home/support/iterators/detail/first_owner_policy.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/detail/first_owner_policy.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/detail/first_owner_policy.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -49,7 +49,7 @@
             // to, so don't swap first_. swap is only called from operator=
 
             template <typename MultiPass>
- static bool is_unique(MultiPass const& mp)
+ static bool is_unique(MultiPass const&)
             {
                 return false; // no way to know, so always return false
             }

Modified: trunk/boost/spirit/home/support/iterators/detail/input_iterator_policy.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/detail/input_iterator_policy.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/detail/input_iterator_policy.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -77,7 +77,7 @@
 
             // test, whether we reached the end of the underlying stream
             template <typename MultiPass>
- static bool input_at_eof(MultiPass const& mp, value_type const& t)
+ static bool input_at_eof(MultiPass const& mp, value_type const&)
             {
                 return mp.input == T();
             }
@@ -97,7 +97,7 @@
         template <typename T>
         struct shared
         {
- explicit shared(T x) {}
+ explicit shared(T) {}
 
             // no shared data elements
         };

Modified: trunk/boost/spirit/home/support/iterators/detail/lex_input_policy.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/detail/lex_input_policy.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/detail/lex_input_policy.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -33,7 +33,7 @@
 
         protected:
             unique() {}
- explicit unique(T x) {}
+ explicit unique(T) {}
 
         public:
             template <typename MultiPass>
@@ -51,13 +51,13 @@
 
             // test, whether we reached the end of the underlying stream
             template <typename MultiPass>
- static bool input_at_eof(MultiPass const& mp, value_type const& t)
+ static bool input_at_eof(MultiPass const&, value_type const& t)
             {
                 return 0 == t;
             }
 
             template <typename MultiPass>
- static bool input_is_valid(MultiPass const& mp, value_type const& t)
+ static bool input_is_valid(MultiPass const&, value_type const& t)
             {
                 return -1 != t;
             }
@@ -67,7 +67,7 @@
         template <typename T>
         struct shared
         {
- explicit shared(T x) {}
+ explicit shared(T) {}
 
             // no shared data elements
         };

Modified: trunk/boost/spirit/home/support/iterators/detail/multi_pass.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/detail/multi_pass.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/detail/multi_pass.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -58,12 +58,12 @@
         default_input_policy() {}
         
         template <typename Functor>
- default_input_policy(Functor const& x) {}
+ default_input_policy(Functor const&) {}
         
         template <typename MultiPass>
- static void destroy(MultiPass& mp) {}
+ static void destroy(MultiPass&) {}
         
- void swap(default_input_policy& /*x*/) {}
+ void swap(default_input_policy&) {}
         
         template <typename MultiPass, typename TokenType>
         static TokenType& advance_input(MultiPass& mp, TokenType& curtok);
@@ -78,12 +78,12 @@
     struct default_ownership_policy
     {
         template <typename MultiPass>
- static void destroy(MultiPass& mp) {}
+ static void destroy(MultiPass&) {}
 
         void swap(default_ownership_policy&) {}
 
         template <typename MultiPass>
- static void clone(MultiPass& mp) {}
+ static void clone(MultiPass&) {}
 
         template <typename MultiPass>
         static bool release(MultiPass& mp);
@@ -95,7 +95,7 @@
     struct default_storage_policy
     {
         template <typename MultiPass>
- static void destroy(MultiPass& mp) {}
+ static void destroy(MultiPass&) {}
 
         void swap(default_storage_policy&) {}
 
@@ -103,10 +103,10 @@
         static typename MultiPass::reference dereference(MultiPass const& mp);
         
         template <typename MultiPass>
- static void increment(MultiPass& mp) {}
+ static void increment(MultiPass&) {}
         
         template <typename MultiPass>
- static void clear_queue(MultiPass& mp) {}
+ static void clear_queue(MultiPass&) {}
 
         template <typename MultiPass>
         static bool is_eof(MultiPass const& mp);
@@ -121,7 +121,7 @@
     struct default_checking_policy
     {
         template <typename MultiPass>
- static void destroy(MultiPass& mp) {}
+ static void destroy(MultiPass&) {}
 
         void swap(default_checking_policy&) {}
 

Modified: trunk/boost/spirit/home/support/iterators/detail/no_check_policy.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/detail/no_check_policy.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/detail/no_check_policy.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -31,7 +31,7 @@
             static void clear_queue(MultiPass&) {}
 
             template <typename MultiPass>
- static void destroy(MultiPass& mp) {}
+ static void destroy(MultiPass&) {}
         };
 
         ///////////////////////////////////////////////////////////////////////

Modified: trunk/boost/spirit/home/support/iterators/detail/ref_counted_policy.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/detail/ref_counted_policy.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/detail/ref_counted_policy.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -25,7 +25,7 @@
         ///////////////////////////////////////////////////////////////////////
         struct unique // : detail::default_ownership_policy
         {
- void swap(unique& x) {}
+ void swap(unique&) {}
 
             // clone is called when a copy of the iterator is made, so
             // increment the ref-count.
@@ -54,7 +54,7 @@
             }
 
             template <typename MultiPass>
- static void destroy(MultiPass& mp)
+ static void destroy(MultiPass&)
             {}
         };
 

Modified: trunk/boost/spirit/home/support/iterators/detail/split_functor_input_policy.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/detail/split_functor_input_policy.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/detail/split_functor_input_policy.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -71,10 +71,10 @@
 
         protected:
             unique() {}
- explicit unique(Functor const& x) {}
+ explicit unique(Functor const&) {}
 
         public:
- void swap(unique& x) {}
+ void swap(unique&) {}
 
             // get the next token
             template <typename MultiPass>

Modified: trunk/boost/spirit/home/support/iterators/detail/split_std_deque_policy.hpp
==============================================================================
--- trunk/boost/spirit/home/support/iterators/detail/split_std_deque_policy.hpp (original)
+++ trunk/boost/spirit/home/support/iterators/detail/split_std_deque_policy.hpp 2008-04-26 16:12:12 EDT (Sat, 26 Apr 2008)
@@ -145,7 +145,7 @@
             }
             
             template <typename MultiPass>
- static void destroy(MultiPass& mp)
+ static void destroy(MultiPass&)
             {}
 
         protected:


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