Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68886 - branches/quickbook-filenames/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-02-14 19:23:10


Author: danieljames
Date: 2011-02-14 19:23:07 EST (Mon, 14 Feb 2011)
New Revision: 68886
URL: http://svn.boost.org/trac/boost/changeset/68886

Log:
Remove attributes from scoped_block.
Text files modified:
   branches/quickbook-filenames/tools/quickbook/src/actions.cpp | 14 ++++------
   branches/quickbook-filenames/tools/quickbook/src/actions.hpp | 49 +++++++--------------------------------
   branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp | 4 ++
   branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp | 3 ++
   branches/quickbook-filenames/tools/quickbook/src/block_element_grammar.cpp | 36 ++++++++++------------------
   branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp | 2 +
   branches/quickbook-filenames/tools/quickbook/src/scoped_parser.hpp | 11 +++-----
   7 files changed, 40 insertions(+), 79 deletions(-)

Modified: branches/quickbook-filenames/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions.cpp 2011-02-14 19:23:07 EST (Mon, 14 Feb 2011)
@@ -80,11 +80,11 @@
         ++actions.error_count;
     }
 
- void tagged_action::operator()(std::string const& str) const
+ void tagged_action::operator()(iterator, iterator) const
     {
         if(!actions.output_pre(out)) return;
 
- out << pre << str << post;
+ out << pre << actions.inside_text << post;
     }
 
     void phrase_action::operator()() const
@@ -1249,10 +1249,10 @@
         (*this)(*f);
     }
 
- void col_action::operator()(std::string const& contents) const
+ void col_action::operator()(iterator, iterator) const
     {
         if(actions.suppress) return;
- phrase << start_cell_ << contents << end_cell_;
+ phrase << start_cell_ << actions.inside_text << end_cell_;
         ++span;
     }
 
@@ -1601,12 +1601,10 @@
         actions.out.pop();
     }
 
- std::string const& scoped_block_push::success_impl()
+ void scoped_block_push::success_impl()
     {
- // TODO: This should probably return an empty string
- // if actions.suppress is true.
         actions.inside_paragraph();
- return actions.out.str();
+ actions.inside_text = actions.out.str();
     }
 
     set_no_eols_scoped::set_no_eols_scoped(quickbook::actions& actions)

Modified: branches/quickbook-filenames/tools/quickbook/src/actions.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions.hpp 2011-02-14 19:23:07 EST (Mon, 14 Feb 2011)
@@ -72,44 +72,12 @@
         actions& escape_actions,
         std::string const& source_mode);
 
- template <typename Derived, typename DataT = void>
     struct scoped_action_base
     {
         typedef quickbook::actions data_type;
         
- template <typename T>
- struct result
- {
- typedef cl::match<DataT> type;
- };
-
- template <typename T>
- DataT success(T const&)
- {
- return static_cast<Derived*>(this)->success_impl();
- }
-
- void failure() {
- return static_cast<Derived*>(this)->failure_impl();
- }
-
- void failure_impl() {}
- };
-
- struct void_type {};
-
- template <typename Derived>
- struct scoped_action_base<Derived, void>
- : scoped_action_base<Derived, void_type>
- {
- template <typename T>
- void_type success(T const&)
- {
- static_cast<Derived*>(this)->success_impl();
- return void_type();
- }
-
- void success_impl() {}
+ template <typename T> void success(T const&) {}
+ void failure() {}
     };
 
     struct error_action
@@ -136,7 +104,7 @@
         , post(post)
         , actions(actions) {}
 
- void operator()(std::string const&) const;
+ void operator()(iterator, iterator) const;
 
         collector& out;
         std::string pre;
@@ -309,7 +277,7 @@
         string_symbols const& macro;
     };
 
- struct cond_phrase_push : scoped_action_base<cond_phrase_push>
+ struct cond_phrase_push : scoped_action_base
     {
         cond_phrase_push(quickbook::actions&);
         ~cond_phrase_push();
@@ -714,7 +682,7 @@
         col_action(collector& phrase, unsigned& span, quickbook::actions& actions)
         : phrase(phrase), span(span), actions(actions) {}
 
- void operator()(std::string const&) const;
+ void operator()(iterator, iterator) const;
 
         collector& phrase;
         unsigned& span;
@@ -910,16 +878,17 @@
         quickbook::actions& actions;
     };
 
- struct scoped_block_push : scoped_action_base<scoped_block_push, std::string>
+ struct scoped_block_push : scoped_action_base
     {
         scoped_block_push(quickbook::actions&);
         ~scoped_block_push();
- std::string const& success_impl();
+ template <typename T> void success(T const&) { this->success_impl(); }
+ void success_impl();
 
         quickbook::actions& actions;
     };
 
- struct set_no_eols_scoped : scoped_action_base<set_no_eols_scoped>
+ struct set_no_eols_scoped : scoped_action_base
     {
         set_no_eols_scoped(quickbook::actions&);
         ~set_no_eols_scoped();

Modified: branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp 2011-02-14 19:23:07 EST (Mon, 14 Feb 2011)
@@ -168,7 +168,9 @@
         , end_varlistentry(phrase, end_varlistentry_, *this)
         , start_varlistterm(phrase, start_varlistterm_, *this)
         , end_varlistterm(phrase, end_varlistterm_, *this)
- , varlistitem(phrase, start_varlistitem_, end_varlistitem_, *this)
+ , start_varlistitem(phrase, start_varlistitem_, *this)
+ , varlistitem(phrase, "", "", *this)
+ , end_varlistitem(phrase, end_varlistitem_, *this)
 
         , break_(phrase, *this)
         , macro_identifier(*this)

Modified: branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp 2011-02-14 19:23:07 EST (Mon, 14 Feb 2011)
@@ -104,6 +104,7 @@
         std::stack<string_symbols> macro_stack;
 
     // temporary or global state
+ std::string inside_text;
         std::string element_id;
         std::string table_title;
         unsigned table_span;
@@ -221,7 +222,9 @@
         markup_action end_varlistentry;
         markup_action start_varlistterm;
         markup_action end_varlistterm;
+ markup_action start_varlistitem;
         tagged_action varlistitem;
+ markup_action end_varlistitem;
 
         break_action break_;
         macro_identifier_action macro_identifier;

Modified: branches/quickbook-filenames/tools/quickbook/src/block_element_grammar.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/block_element_grammar.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/block_element_grammar.cpp 2011-02-14 19:23:07 EST (Mon, 14 Feb 2011)
@@ -110,8 +110,7 @@
         elements.add("blurb", element_info(element_info::block, &local.blurb));
 
         local.blurb =
- actions.scoped_block[inside_paragraph]
- [actions.blurb]
+ inside_paragraph [actions.blurb]
             ;
 
         elements.add
@@ -119,8 +118,7 @@
             ;
 
         local.blockquote =
- blank >> actions.scoped_block[inside_paragraph]
- [actions.blockquote]
+ blank >> inside_paragraph [actions.blockquote]
             ;
 
         elements.add
@@ -132,28 +130,23 @@
             ;
 
         local.warning =
- actions.scoped_block[inside_paragraph]
- [actions.warning]
+ inside_paragraph [actions.warning]
             ;
 
         local.caution =
- actions.scoped_block[inside_paragraph]
- [actions.caution]
+ inside_paragraph [actions.caution]
             ;
 
         local.important =
- actions.scoped_block[inside_paragraph]
- [actions.important]
+ inside_paragraph [actions.important]
             ;
 
         local.note =
- actions.scoped_block[inside_paragraph]
- [actions.note]
+ inside_paragraph [actions.note]
             ;
 
         local.tip =
- actions.scoped_block[inside_paragraph]
- [actions.tip]
+ inside_paragraph [actions.tip]
             ;
 
         elements.add
@@ -232,11 +225,10 @@
>>
             (
                 (
- local.varlistterm
- >> ( actions.scoped_block [+local.varlistitem]
- [actions.varlistitem]
+ local.varlistterm [actions.start_varlistitem]
+ >> ( +local.varlistitem [actions.varlistitem]
                         | cl::eps_p [actions.error]
- )
+ ) [actions.end_varlistitem]
>> cl::ch_p(']') [actions.end_varlistentry]
>> space
                 )
@@ -303,11 +295,9 @@
         local.table_cell =
                 space
>> cl::ch_p('[')
- >> ( actions.scoped_block [
- inside_paragraph
- >> cl::ch_p(']')
- >> space
- ] [actions.cell]
+ >> ( inside_paragraph
+ >> cl::ch_p(']')
+ >> space [actions.cell]
                 | cl::eps_p [actions.error]
                 )
             ;

Modified: branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp 2011-02-14 19:23:07 EST (Mon, 14 Feb 2011)
@@ -356,10 +356,12 @@
             ;
 
         inside_paragraph =
+ actions.scoped_block[
             (*( common
             | (cl::anychar_p - phrase_end) [actions.plain_char]
             | (+eol) [actions.inside_paragraph]
             )) [actions.inside_paragraph]
+ ]
             ;
 
         local.phrase_element

Modified: branches/quickbook-filenames/tools/quickbook/src/scoped_parser.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/scoped_parser.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/scoped_parser.hpp 2011-02-14 19:23:07 EST (Mon, 14 Feb 2011)
@@ -13,6 +13,7 @@
 #define BOOST_QUICKBOOK_SCOPED_PARSER_HPP
 
 #include <boost/spirit/include/classic_core.hpp>
+#include <boost/spirit/include/classic_nil.hpp>
 
 namespace quickbook {
     namespace cl = boost::spirit::classic;
@@ -25,12 +26,7 @@
         typedef cl::unary< ParserT, cl::parser< scoped_parser_impl<ScopeT, DataT, ParserT> > > base_t;
 
         template <typename ScannerT>
- struct result :
- ScopeT::template result<
- typename cl::parser_result<ParserT, ScannerT>::type
- >
- {
- };
+ struct result { typedef cl::match<> type; };
 
         scoped_parser_impl(DataT& actions, ParserT const &p)
             : base_t(p)
@@ -48,7 +44,8 @@
                 = this->subject().parse(scan);
 
             if (result) {
- return scan.create_match(result.length(), scope.success(result), save, scan.first);
+ scope.success(result);
+ return scan.create_match(result.length(), cl::nil_t(), save, scan.first);
             }
             else {
                 scope.failure();


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