$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r67633 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-01-03 17:10:26
Author: danieljames
Date: 2011-01-03 17:10:21 EST (Mon, 03 Jan 2011)
New Revision: 67633
URL: http://svn.boost.org/trac/boost/changeset/67633
Log:
Move 'no_eols' into actions_class.
Should remove the need to create a new grammar when expanding templates
etc.
Text files modified: 
   trunk/tools/quickbook/src/actions.cpp              |    13 ++++++++++++-                           
   trunk/tools/quickbook/src/actions.hpp              |    16 +++++++++++++++-                        
   trunk/tools/quickbook/src/actions_class.cpp        |     4 ++++                                    
   trunk/tools/quickbook/src/actions_class.hpp        |     3 +++                                     
   trunk/tools/quickbook/src/block_markup_grammar.cpp |     6 +++---                                  
   trunk/tools/quickbook/src/grammar.cpp              |     1 -                                       
   trunk/tools/quickbook/src/grammar_impl.hpp         |     1 -                                       
   trunk/tools/quickbook/src/main_grammar.cpp         |     2 +-                                      
   8 files changed, 38 insertions(+), 8 deletions(-)
Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp	(original)
+++ trunk/tools/quickbook/src/actions.cpp	2011-01-03 17:10:21 EST (Mon, 03 Jan 2011)
@@ -70,7 +70,7 @@
         out << pre << str << post;
     }
 
-    void phrase_action::operator()(iterator first, iterator last) const
+    void phrase_action::operator()() const
     {
         actions.output_pre(phrase);
 
@@ -1496,4 +1496,15 @@
         actions.inside_paragraph();
         return actions.out.str();
     }
+
+    set_no_eols_scoped::set_no_eols_scoped(quickbook::actions& actions)
+        : actions(actions), saved_no_eols(actions.no_eols)
+    {
+        actions.no_eols = false;
+    }
+
+    set_no_eols_scoped::~set_no_eols_scoped()
+    {
+        actions.no_eols = saved_no_eols;
+    }
 }
Modified: trunk/tools/quickbook/src/actions.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions.hpp	(original)
+++ trunk/tools/quickbook/src/actions.hpp	2011-01-03 17:10:21 EST (Mon, 03 Jan 2011)
@@ -109,6 +109,8 @@
             static_cast<Derived*>(this)->success_impl();
             return void_type();
         }
+        
+        void success_impl() {}
     };
 
     struct error_action
@@ -161,7 +163,10 @@
         , post(post)
         , actions(actions) {}
 
-        void operator()(iterator first, iterator last) const;
+        void operator()(iterator first, iterator last) const { return (*this)(); }
+        template <typename T>
+        void operator()(T const&) const { return (*this)(); }
+        void operator()() const;
 
         collector& out;
         collector& phrase;
@@ -947,6 +952,15 @@
 
         quickbook::actions& actions;
     };
+
+    struct set_no_eols_scoped : scoped_action_base<set_no_eols_scoped>
+    {
+        set_no_eols_scoped(quickbook::actions&);
+        ~set_no_eols_scoped();
+
+        quickbook::actions& actions;
+        bool saved_no_eols;
+    };
 }
 
 #ifdef BOOST_MSVC
Modified: trunk/tools/quickbook/src/actions_class.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.cpp	(original)
+++ trunk/tools/quickbook/src/actions_class.cpp	2011-01-03 17:10:21 EST (Mon, 03 Jan 2011)
@@ -68,6 +68,9 @@
         , image_fileref()
         , attribute_name()
         , attributes()
+        , anchors()
+        , saved_anchors()
+        , no_eols(true)
 
     // actions
         , error(error_count)
@@ -99,6 +102,7 @@
         , hr(out, hr_, *this)
         , blurb(out, blurb_pre, blurb_post, *this)
         , blockquote(out, blockquote_pre, blockquote_post, *this)
+        , set_no_eols(*this)
         , preformatted(out, phrase, preformatted_pre, preformatted_post, *this)
         , warning(out, warning_pre, warning_post, *this)
         , caution(out, caution_pre, caution_post, *this)
Modified: trunk/tools/quickbook/src/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.hpp	(original)
+++ trunk/tools/quickbook/src/actions_class.hpp	2011-01-03 17:10:21 EST (Mon, 03 Jan 2011)
@@ -118,6 +118,7 @@
         attribute_map           attributes;
         string_list             anchors;
         string_list             saved_anchors;
+        bool                    no_eols;
 
     // push/pop the states and the streams
         void copy_macros_for_write();
@@ -153,6 +154,8 @@
         header_action           h1, h2, h3, h4, h5, h6;
         markup_action           hr;
         tagged_action           blurb, blockquote;
+        scoped_parser<set_no_eols_scoped>
+                                set_no_eols;
         phrase_action           preformatted;
         tagged_action           warning, caution, important, note, tip;
         space                   space_char;
Modified: trunk/tools/quickbook/src/block_markup_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/block_markup_grammar.cpp	(original)
+++ trunk/tools/quickbook/src/block_markup_grammar.cpp	2011-01-03 17:10:21 EST (Mon, 03 Jan 2011)
@@ -161,9 +161,9 @@
             ;
 
         local.preformatted =
-            space                               [cl::assign_a(no_eols, false_)]
-            >> !eol >> phrase                   [actions.preformatted]
-            >> cl::eps_p                        [cl::assign_a(no_eols, true_)]
+                space
+            >>  !eol
+            >>  actions.set_no_eols[phrase]     [actions.preformatted]
             ;
 
         block_keyword_rules.add
Modified: trunk/tools/quickbook/src/grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/grammar.cpp	(original)
+++ trunk/tools/quickbook/src/grammar.cpp	2011-01-03 17:10:21 EST (Mon, 03 Jan 2011)
@@ -30,7 +30,6 @@
 
     quickbook_grammar::impl::impl(quickbook::actions& a)
         : actions(a)
-        , no_eols(true)
         , store_()
     {
         init_main();
Modified: trunk/tools/quickbook/src/grammar_impl.hpp
==============================================================================
--- trunk/tools/quickbook/src/grammar_impl.hpp	(original)
+++ trunk/tools/quickbook/src/grammar_impl.hpp	2011-01-03 17:10:21 EST (Mon, 03 Jan 2011)
@@ -22,7 +22,6 @@
     struct quickbook_grammar::impl
     {
         quickbook::actions& actions;
-        bool no_eols;
         rule_store store_;
 
         // Main Grammar
Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp	(original)
+++ trunk/tools/quickbook/src/main_grammar.cpp	2011-01-03 17:10:21 EST (Mon, 03 Jan 2011)
@@ -422,7 +422,7 @@
 
         phrase_end =
             ']' |
-            cl::if_p(var(no_eols))
+            cl::if_p(var(actions.no_eols))
             [
                 cl::eol_p >> *cl::blank_p >> cl::eol_p
                                                 // Make sure that we don't go