Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55164 - in trunk/boost/spirit/home/qi: . detail directive
From: hartmut.kaiser_at_[hidden]
Date: 2009-07-30 14:42:09


Author: hkaiser
Date: 2009-07-25 21:09:56 EDT (Sat, 25 Jul 2009)
New Revision: 55164
URL: http://svn.boost.org/trac/boost/changeset/55164

Log:
Spirit: factored out unused_skipper
Added:
   trunk/boost/spirit/home/qi/detail/unused_skipper.hpp (contents, props changed)
Text files modified:
   trunk/boost/spirit/home/qi/directive/lexeme.hpp | 11 ++---------
   trunk/boost/spirit/home/qi/directive/skip.hpp | 22 +++-------------------
   trunk/boost/spirit/home/qi/skip_over.hpp | 9 ++++-----
   3 files changed, 9 insertions(+), 33 deletions(-)

Added: trunk/boost/spirit/home/qi/detail/unused_skipper.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/qi/detail/unused_skipper.hpp 2009-07-25 21:09:56 EDT (Sat, 25 Jul 2009)
@@ -0,0 +1,43 @@
+// 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_UNUSED_SKIPPER_JUL_25_2009_0921AM)
+#define BOOST_SPIRIT_QI_UNUSED_SKIPPER_JUL_25_2009_0921AM
+
+#include <boost/spirit/home/support/unused.hpp>
+
+namespace boost { namespace spirit { namespace qi { namespace detail
+{
+ template <typename Skipper>
+ struct unused_skipper : unused_type
+ {
+ unused_skipper(Skipper const& skipper)
+ : skipper(skipper) {}
+ Skipper const& skipper;
+ };
+
+ // If a surrounding lexeme[] directive was specified, the current
+ // skipper is of the type unused_skipper. In this case we
+ // re-activate the skipper which was active before the skip[]
+ // directive.
+ template <typename Skipper, typename Default>
+ inline Skipper const&
+ get_skipper(unused_skipper<Skipper> const& u, Default const&)
+ {
+ return u.skipper;
+ }
+
+ // If no surrounding lexeme[] directive was specified we activate
+ // a default skipper to use.
+ template <typename Skipper, typename Default>
+ inline Default const&
+ get_skipper(Skipper const&, Default const& d)
+ {
+ return d;
+ }
+
+}}}}
+
+#endif

Modified: trunk/boost/spirit/home/qi/directive/lexeme.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/directive/lexeme.hpp (original)
+++ trunk/boost/spirit/home/qi/directive/lexeme.hpp 2009-07-25 21:09:56 EDT (Sat, 25 Jul 2009)
@@ -14,6 +14,7 @@
 #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/detail/unused_skipper.hpp>
 #include <boost/spirit/home/support/unused.hpp>
 #include <boost/spirit/home/support/common_terminals.hpp>
 #include <boost/spirit/home/support/attributes.hpp>
@@ -34,14 +35,6 @@
     using spirit::lexeme;
     using spirit::lexeme_type;
 
- template <typename Skipper>
- struct unused_skipper : unused_type
- {
- unused_skipper(Skipper const& skipper)
- : skipper(skipper) {}
- Skipper const& skipper;
- };
-
     template <typename Subject>
     struct lexeme_directive : unary_parser<lexeme_directive<Subject> >
     {
@@ -65,7 +58,7 @@
         {
             qi::skip_over(first, last, skipper);
             return subject.parse(first, last, context
- , unused_skipper<Skipper>(skipper), attr);
+ , detail::unused_skipper<Skipper>(skipper), attr);
         }
 
         template <typename Context>

Modified: trunk/boost/spirit/home/qi/directive/skip.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/directive/skip.hpp (original)
+++ trunk/boost/spirit/home/qi/directive/skip.hpp 2009-07-25 21:09:56 EDT (Sat, 25 Jul 2009)
@@ -17,6 +17,7 @@
 #include <boost/spirit/home/qi/operator/kleene.hpp>
 #include <boost/spirit/home/qi/directive/lexeme.hpp>
 #include <boost/spirit/home/qi/skip_over.hpp>
+#include <boost/spirit/home/qi/detail/unused_skipper.hpp>
 #include <boost/spirit/home/support/container.hpp>
 #include <boost/spirit/home/support/common_terminals.hpp>
 #include <boost/spirit/home/support/attributes.hpp>
@@ -52,24 +53,6 @@
     using spirit::skip;
     using spirit::skip_type;
 
- template <typename Skipper>
- struct unused_skipper;
-
- namespace detail
- {
- template <typename Skipper>
- inline Skipper const& get_skipper(unused_skipper<Skipper> const& u)
- {
- return u.skipper;
- }
-
- template <typename Skipper>
- inline Skipper const& get_skipper(Skipper const& u)
- {
- return u;
- }
- }
-
     template <typename Subject>
     struct reskip_parser : unary_parser<reskip_parser<Subject> >
     {
@@ -92,7 +75,8 @@
           , Context& context, Skipper const& u // --> The skipper is reintroduced
           , Attribute& attr) const
         {
- return subject.parse(first, last, context, detail::get_skipper(u), attr);
+ return subject.parse(first, last, context
+ , detail::get_skipper(u), attr);
         }
 
         template <typename Context>

Modified: trunk/boost/spirit/home/qi/skip_over.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/skip_over.hpp (original)
+++ trunk/boost/spirit/home/qi/skip_over.hpp 2009-07-25 21:09:56 EDT (Sat, 25 Jul 2009)
@@ -12,7 +12,7 @@
 #endif
 
 #include <boost/spirit/home/support/unused.hpp>
-#include <boost/spirit/home/support/unused.hpp>
+#include <boost/spirit/home/qi/detail/unused_skipper.hpp>
 
 namespace boost { namespace spirit { namespace qi
 {
@@ -33,13 +33,12 @@
     {
     }
 
- template <typename Skipper>
- struct unused_skipper;
-
     template <typename Iterator, typename Skipper>
- inline void skip_over(Iterator&, Iterator const&, unused_skipper<Skipper> const&)
+ inline void skip_over(Iterator&, Iterator const&
+ , detail::unused_skipper<Skipper> const&)
     {
     }
+
 }}}
 
 #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