Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61335 - in trunk/libs/spirit/example/scheme: input support
From: joel_at_[hidden]
Date: 2010-04-17 08:16:54


Author: djowel
Date: 2010-04-17 08:16:53 EDT (Sat, 17 Apr 2010)
New Revision: 61335
URL: http://svn.boost.org/trac/boost/changeset/61335

Log:
installing the line_pos_iterator
Text files modified:
   trunk/libs/spirit/example/scheme/input/parse_sexpr_impl.hpp | 46 +++++++++++++++++++++++++++++----------
   trunk/libs/spirit/example/scheme/support/line_pos_iterator.hpp | 9 ++++---
   2 files changed, 39 insertions(+), 16 deletions(-)

Modified: trunk/libs/spirit/example/scheme/input/parse_sexpr_impl.hpp
==============================================================================
--- trunk/libs/spirit/example/scheme/input/parse_sexpr_impl.hpp (original)
+++ trunk/libs/spirit/example/scheme/input/parse_sexpr_impl.hpp 2010-04-17 08:16:53 EDT (Sat, 17 Apr 2010)
@@ -25,9 +25,15 @@
         // no white space skipping in the stream!
         is.unsetf(std::ios::skipws);
 
- typedef boost::spirit::basic_istream_iterator<Char> iterator_type;
- iterator_type first(is);
- iterator_type last;
+ typedef
+ boost::spirit::basic_istream_iterator<Char>
+ stream_iterator_type;
+ stream_iterator_type sfirst(is);
+ stream_iterator_type slast;
+
+ typedef line_pos_iterator<stream_iterator_type> iterator_type;
+ iterator_type first(sfirst);
+ iterator_type last(slast);
 
         scheme::input::sexpr<iterator_type> p;
         scheme::input::sexpr_white_space<iterator_type> ws;
@@ -43,9 +49,15 @@
         // no white space skipping in the stream!
         is.unsetf(std::ios::skipws);
 
- typedef boost::spirit::basic_istream_iterator<Char> iterator_type;
- iterator_type first(is);
- iterator_type last;
+ typedef
+ boost::spirit::basic_istream_iterator<Char>
+ stream_iterator_type;
+ stream_iterator_type sfirst(is);
+ stream_iterator_type slast;
+
+ typedef line_pos_iterator<stream_iterator_type> iterator_type;
+ iterator_type first(sfirst);
+ iterator_type last(slast);
 
         scheme::input::sexpr<iterator_type> p;
         scheme::input::sexpr_white_space<iterator_type> ws;
@@ -59,35 +71,45 @@
     typename boost::disable_if<boost::is_base_of<std::ios_base, Range>, bool>::type
     parse_sexpr(Range const& rng, utree& result)
     {
- typedef typename Range::const_iterator iterator_type;
+ typedef
+ line_pos_iterator<typename Range::const_iterator>
+ iterator_type;
 
         scheme::input::sexpr<iterator_type> p;
         scheme::input::sexpr_white_space<iterator_type> ws;
 
+ iterator_type first(rng.begin());
+ iterator_type last(rng.end());
+
         using boost::spirit::qi::phrase_parse;
- return phrase_parse(rng.begin(), rng.end(), p, ws, result);
+ return phrase_parse(first, last, p, ws, result);
     }
 
     template <typename Range>
     typename boost::disable_if<boost::is_base_of<std::ios_base, Range>, bool>::type
     parse_sexpr_list(Range const& rng, utree& result)
     {
- typedef typename Range::const_iterator iterator_type;
+ typedef
+ line_pos_iterator<typename Range::const_iterator>
+ iterator_type;
 
         scheme::input::sexpr<iterator_type> p;
         scheme::input::sexpr_white_space<iterator_type> ws;
 
+ iterator_type first(rng.begin());
+ iterator_type last(rng.end());
+
         using boost::spirit::qi::phrase_parse;
- return phrase_parse(rng.begin(), rng.end(), +p, ws, result);
+ return phrase_parse(first, last, +p, ws, result);
     }
 
     ///////////////////////////////////////////////////////////////////////////
- inline bool parse_sexpr(utree const& in, utree& result)
+ bool parse_sexpr(utree const& in, utree& result)
     {
         return parse_sexpr(in.as<utf8_string_range>(), result);
     }
 
- inline bool parse_sexpr_list(utree const& in, utree& result)
+ bool parse_sexpr_list(utree const& in, utree& result)
     {
         return parse_sexpr_list(in.as<utf8_string_range>(), result);
     }

Modified: trunk/libs/spirit/example/scheme/support/line_pos_iterator.hpp
==============================================================================
--- trunk/libs/spirit/example/scheme/support/line_pos_iterator.hpp (original)
+++ trunk/libs/spirit/example/scheme/support/line_pos_iterator.hpp 2010-04-17 08:16:53 EDT (Sat, 17 Apr 2010)
@@ -32,11 +32,11 @@
     public:
 
         line_pos_iterator()
- : line_pos_iterator::iterator_adaptor_()
+ : line_pos_iterator::iterator_adaptor_(),
             line(0), prev(0) {}
 
         explicit line_pos_iterator(Iterator base)
- : node_iter::iterator_adaptor_(base)
+ : line_pos_iterator::iterator_adaptor_(base),
             line(0), prev(0) {}
 
         std::size_t position() const
@@ -49,7 +49,8 @@
         friend class boost::iterator_core_access;
         void increment()
         {
- typename Iterator::reference ref = *(this->base());
+ typename std::iterator_traits<Iterator>::reference
+ ref = *(this->base());
             switch (ref)
             {
                 case '\r':
@@ -67,7 +68,7 @@
         }
 
         std::size_t line;
- typename Iterator::value_type prev;
+ typename std::iterator_traits<Iterator>::value_type prev;
     };
 
     ///////////////////////////////////////////////////////////////////////////


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