Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60352 - trunk/libs/spirit/example/qi/scheme
From: joel_at_[hidden]
Date: 2010-03-08 11:01:00


Author: djowel
Date: 2010-03-08 11:00:59 EST (Mon, 08 Mar 2010)
New Revision: 60352
URL: http://svn.boost.org/trac/boost/changeset/60352

Log:
final tweaks for today
Text files modified:
   trunk/libs/spirit/example/qi/scheme/sexpr.hpp | 6 +++---
   trunk/libs/spirit/example/qi/scheme/sexpr_test.cpp | 9 ++++++---
   trunk/libs/spirit/example/qi/scheme/simple_print.hpp | 16 ++++++++--------
   trunk/libs/spirit/example/qi/scheme/utree.hpp | 24 +++++++++++++++++-------
   trunk/libs/spirit/example/qi/scheme/utree_test.cpp | 1 +
   5 files changed, 35 insertions(+), 21 deletions(-)

Modified: trunk/libs/spirit/example/qi/scheme/sexpr.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/scheme/sexpr.hpp (original)
+++ trunk/libs/spirit/example/qi/scheme/sexpr.hpp 2010-03-08 11:00:59 EST (Mon, 08 Mar 2010)
@@ -40,6 +40,7 @@
     using boost::spirit::qi::int_;
     using boost::spirit::qi::hex;
     using boost::spirit::qi::oct;
+ using boost::spirit::qi::bool_;
     using boost::spirit::qi::no_case;
     using boost::spirit::qi::lexeme;
     using boost::spirit::qi::lit;
@@ -153,8 +154,7 @@
             list = '(' >> *start >> ')';
 
             atom = number [_val = _1]
- | lit("true") [_val = true]
- | lit("false") [_val = false]
+ | bool_ [_val = _1]
                     | string [_val = _1]
                     | symbol [_val = _1]
                     ;
@@ -172,7 +172,7 @@
         rule<Iterator, unicode, white_space<Iterator>, utree()> start, list;
         rule<Iterator, unicode, utree()> atom, number;
         rule<Iterator, unicode, std::string()> symbol;
- string<Iterator> string;
+ scheme::string<Iterator> string;
     };
 }
 

Modified: trunk/libs/spirit/example/qi/scheme/sexpr_test.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/scheme/sexpr_test.cpp (original)
+++ trunk/libs/spirit/example/qi/scheme/sexpr_test.cpp 2010-03-08 11:00:59 EST (Mon, 08 Mar 2010)
@@ -1,4 +1,4 @@
-/*=============================================================================
+/*=============================================================================
     Copyright (c) 2001-2010 Joel de Guzman
 
     Distributed under the Boost Software License, Version 1.0. (See accompanying
@@ -13,6 +13,7 @@
 {
     inline std::ostream& operator<<(std::ostream& out, utree const& x)
     {
+ using ::detail::println;
         println(x);
         return out;
     }
@@ -23,6 +24,8 @@
 ///////////////////////////////////////////////////////////////////////////////
 int main(int argc, char **argv)
 {
+ using ::detail::println;
+
     char const* filename;
     if (argc > 1)
     {
@@ -66,8 +69,8 @@
         std::back_inserter(source_code));
 
     typedef boost::u8_to_u32_iterator<std::string::const_iterator> iterator_type;
- iterator_type first = source_code.begin();
- iterator_type last = source_code.end();
+ iterator_type first(source_code.begin());
+ iterator_type last(source_code.end());
 
     scheme::sexpr<iterator_type> p;
     scheme::white_space<iterator_type> ws;

Modified: trunk/libs/spirit/example/qi/scheme/simple_print.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/scheme/simple_print.hpp (original)
+++ trunk/libs/spirit/example/qi/scheme/simple_print.hpp 2010-03-08 11:00:59 EST (Mon, 08 Mar 2010)
@@ -4,7 +4,7 @@
 #include "utree.hpp"
 #include <iostream>
 
-namespace
+namespace detail
 {
     ///////////////////////////////////////////////////////////////////////////
     // simple utree printing facility prints the utree in a single line
@@ -42,10 +42,10 @@
             for (iterator i = range.begin(); i != range.end(); ++i)
             {
                 if (i != range.begin())
- print(' ');
- print(*i);
+ detail::print(' ');
+ detail::print(*i);
             }
- print(')');
+ detail::print(')');
         }
 
         template <typename Range> // for strings
@@ -55,13 +55,13 @@
             iterator i = range.begin();
             bool const is_symbol = *i == '\0'; // a 0 byte at the beginning signifies a symbol
             if (!is_symbol)
- print('"');
+ detail::print('"');
             else
                 ++i;
             for (; i != range.end(); ++i)
- print(*i);
+ detail::print(*i);
             if (!is_symbol)
- print('"');
+ detail::print('"');
         }
 
         template <typename Iterator>
@@ -84,7 +84,7 @@
 
     inline void println(scheme::utree const& val)
     {
- print(val);
+ detail::print(val);
         std::cout << std::endl;
     }
 }

Modified: trunk/libs/spirit/example/qi/scheme/utree.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/scheme/utree.hpp (original)
+++ trunk/libs/spirit/example/qi/scheme/utree.hpp 2010-03-08 11:00:59 EST (Mon, 08 Mar 2010)
@@ -146,7 +146,7 @@
     // - a (doubly linked) list of utree
     //
     // The utree has minimal memory footprint. The data structure size is
- // 16 bits on a 32-bit platform. Being a container of itself, it can
+ // 16 bytes on a 32-bit platform. Being a container of itself, it can
     // represent tree structures.
     ///////////////////////////////////////////////////////////////////////////
     class utree
@@ -165,7 +165,7 @@
 
         utree();
         explicit utree(bool b);
- explicit utree(unsigned i);
+ explicit utree(unsigned int i);
         explicit utree(int i);
         explicit utree(double d);
         explicit utree(char const* str);
@@ -177,7 +177,7 @@
 
         utree& operator=(utree const& other);
         utree& operator=(bool b);
- utree& operator=(unsigned i);
+ utree& operator=(unsigned int i);
         utree& operator=(int i);
         utree& operator=(double d);
         utree& operator=(char const* s);
@@ -519,6 +519,7 @@
 
     inline void list::pop_front()
     {
+ BOOST_ASSERT(size != 0);
         node* np = first;
         first = first->next;
         first->prev = 0;
@@ -528,6 +529,7 @@
 
     inline void list::pop_back()
     {
+ BOOST_ASSERT(size != 0);
         node* np = last;
         last = last->prev;
         last->next = 0;
@@ -687,6 +689,8 @@
 
             switch (x.get_type())
             {
+ default:
+ BOOST_ASSERT(false); // can't happen
                 case type::nil_type:
                     typename UTreeX::nil arg;
                     return f(arg);
@@ -698,7 +702,8 @@
                     return f(x.d);
                 case type::list_type:
                     return f(list_range(iterator(x.l.first), iterator(0)));
- default:
+ case type::heap_string_type:
+ case type::small_string_type:
                     return f(string_range(x.s.str(), x.s.str() + x.s.size()));
             }
         }
@@ -723,6 +728,8 @@
 
             switch (x.get_type())
             {
+ default:
+ BOOST_ASSERT(false); // can't happen
                 case type::nil_type:
                     typename UTreeX::nil x_;
                     return visit_impl::apply(y, detail::bind(f, x_));
@@ -736,7 +743,8 @@
                     return visit_impl::apply(
                         y, detail::bind<F, list_range>(f,
                         list_range(iterator(x.l.first), iterator(0))));
- default:
+ case type::heap_string_type:
+ case type::small_string_type:
                     return visit_impl::apply(y, detail::bind(
                         f, string_range(x.s.str(), x.s.str() + x.s.size())));
             }
@@ -773,7 +781,7 @@
         set_type(type::bool_type);
     }
 
- inline utree::utree(unsigned i) : i(i)
+ inline utree::utree(unsigned int i) : i(i)
     {
         set_type(type::int_type);
     }
@@ -831,7 +839,7 @@
         return *this;
     }
 
- inline utree& utree::operator=(unsigned i_)
+ inline utree& utree::operator=(unsigned int i_)
     {
         free();
         i = i_;
@@ -1144,6 +1152,8 @@
             case type::list_type:
                 l.free();
                 break;
+ default:
+ break;
         };
     }
 

Modified: trunk/libs/spirit/example/qi/scheme/utree_test.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/scheme/utree_test.cpp (original)
+++ trunk/libs/spirit/example/qi/scheme/utree_test.cpp 2010-03-08 11:00:59 EST (Mon, 08 Mar 2010)
@@ -6,6 +6,7 @@
 {
     using scheme::utree;
     using scheme::ulist;
+ using ::detail::println;
 
     {
         // test the size


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