Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61082 - branches/quickbook-1.5-spirit2
From: daniel_james_at_[hidden]
Date: 2010-04-05 15:45:20


Author: danieljames
Date: 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
New Revision: 61082
URL: http://svn.boost.org/trac/boost/changeset/61082

Log:
Combine the main grammars into a single object.
Added:
   branches/quickbook-1.5-spirit2/code_snippet_grammar.hpp (contents, props changed)
   branches/quickbook-1.5-spirit2/grammar.cpp (contents, props changed)
   branches/quickbook-1.5-spirit2/grammar.hpp (contents, props changed)
   branches/quickbook-1.5-spirit2/grammar_impl.hpp
      - copied, changed from r61081, /branches/quickbook-1.5-spirit2/phrase_grammar.hpp
Removed:
   branches/quickbook-1.5-spirit2/block_grammar.hpp
   branches/quickbook-1.5-spirit2/grammars.hpp
Text files modified:
   branches/quickbook-1.5-spirit2/Jamfile.v2 | 1
   branches/quickbook-1.5-spirit2/block_actions.cpp | 2
   branches/quickbook-1.5-spirit2/block_grammar.cpp | 17 ++---------
   branches/quickbook-1.5-spirit2/block_markup_grammar.cpp | 5 ++-
   branches/quickbook-1.5-spirit2/code_snippet_actions.cpp | 2
   branches/quickbook-1.5-spirit2/code_snippet_grammar.cpp | 2
   branches/quickbook-1.5-spirit2/doc_info_grammar.cpp | 57 +++++++++++++++------------------------
   branches/quickbook-1.5-spirit2/grammar_impl.hpp | 40 +++++++++++++++++++--------
   branches/quickbook-1.5-spirit2/phrase_grammar.cpp | 49 +++++----------------------------
   branches/quickbook-1.5-spirit2/phrase_grammar.hpp | 23 ---------------
   branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp | 2
   branches/quickbook-1.5-spirit2/quickbook.cpp | 9 ++---
   branches/quickbook-1.5-spirit2/syntax_highlight_grammar.cpp | 7 ++--
   branches/quickbook-1.5-spirit2/template.cpp | 10 +++---
   14 files changed, 83 insertions(+), 143 deletions(-)

Modified: branches/quickbook-1.5-spirit2/Jamfile.v2
==============================================================================
--- branches/quickbook-1.5-spirit2/Jamfile.v2 (original)
+++ branches/quickbook-1.5-spirit2/Jamfile.v2 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -28,6 +28,7 @@
     post_process.cpp
     collector.cpp
     template.cpp
+ grammar.cpp
     phrase_grammar.cpp
     phrase_markup_grammar.cpp
     phrase_actions.cpp

Modified: branches/quickbook-1.5-spirit2/block_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_actions.cpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -15,7 +15,7 @@
 #include "actions.hpp"
 #include "state.hpp"
 #include "quickbook.hpp"
-#include "grammars.hpp"
+#include "code_snippet_grammar.hpp"
 #include "code_snippet_types.hpp"
 #include "utils.hpp"
 

Modified: branches/quickbook-1.5-spirit2/block_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_grammar.cpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -13,7 +13,8 @@
 #include <boost/spirit/include/qi_eps.hpp>
 #include <boost/spirit/include/qi_eol.hpp>
 #include <boost/fusion/include/adapt_struct.hpp>
-#include "block_grammar.hpp"
+#include "grammar_impl.hpp"
+#include "block.hpp"
 #include "template.hpp"
 #include "actions.hpp"
 #include "code.hpp"
@@ -37,25 +38,15 @@
     namespace qi = boost::spirit::qi;
     namespace ph = boost::phoenix;
 
- block_grammar::block_grammar(quickbook::actions& actions_)
- : block_grammar::base_type(start, "block")
- , rules_pimpl(new rules(actions_))
- , start(rules_pimpl->start_) {}
-
- block_grammar::~block_grammar() {}
-
- block_grammar::rules::rules(quickbook::actions& actions_)
- : actions(actions_), no_eols(true), common(actions, no_eols)
+ void quickbook_grammar::impl::init_block()
     {
- init_block_markup();
-
         qi::rule<iterator>& blocks = store_.create();
         qi::rule<iterator, quickbook::code()>& code = store_.create();
         qi::rule<iterator, quickbook::list()>& list = store_.create();
         qi::rule<iterator, quickbook::hr()>& hr = store_.create();
         qi::rule<iterator, quickbook::paragraph()>& paragraph = store_.create();
 
- start_ =
+ block_start =
             blocks >> blank
             ;
 

Deleted: branches/quickbook-1.5-spirit2/block_grammar.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_grammar.hpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
+++ (empty file)
@@ -1,33 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- Use, modification and distribution is subject to 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)
-=============================================================================*/
-
-#include "grammars.hpp"
-#include "block.hpp"
-#include "rule_store.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
-
- struct block_grammar::rules
- {
- rules(quickbook::actions& actions_);
-
- quickbook::actions& actions;
- bool no_eols;
- phrase_grammar common;
-
- rule_store store_;
- qi::rule<iterator> start_;
- qi::rule<iterator> block_markup;
-
- void init_block_markup();
- };
-}
\ No newline at end of file

Modified: branches/quickbook-1.5-spirit2/block_markup_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_markup_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_markup_grammar.cpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -16,7 +16,8 @@
 #include <boost/spirit/include/phoenix_operator.hpp>
 #include <boost/spirit/include/phoenix_fusion.hpp>
 #include <boost/fusion/include/adapt_struct.hpp>
-#include "block_grammar.hpp"
+#include "grammar_impl.hpp"
+#include "block.hpp"
 #include "template.hpp"
 #include "actions.hpp"
 #include "code.hpp"
@@ -98,7 +99,7 @@
     namespace qi = boost::spirit::qi;
     namespace ph = boost::phoenix;
 
- void block_grammar::rules::init_block_markup()
+ void quickbook_grammar::impl::init_block_markup()
     {
         qi::rule<iterator, quickbook::begin_section()>& begin_section = store_.create();
         qi::rule<iterator, quickbook::end_section()>& end_section = store_.create();

Modified: branches/quickbook-1.5-spirit2/code_snippet_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code_snippet_actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/code_snippet_actions.cpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -16,7 +16,7 @@
 #include <iterator>
 #include <boost/lexical_cast.hpp>
 #include "utils.hpp"
-#include "grammars.hpp"
+#include "grammar.hpp"
 #include "code_snippet_types.hpp"
 #include "template.hpp"
 

Modified: branches/quickbook-1.5-spirit2/code_snippet_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code_snippet_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/code_snippet_grammar.cpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -13,7 +13,7 @@
 #include <boost/spirit/include/qi_attr.hpp>
 #include "fwd.hpp"
 #include "code_snippet_types.hpp"
-#include "grammars.hpp"
+#include "code_snippet_grammar.hpp"
 #include "misc_rules.hpp"
 
 namespace quickbook

Added: branches/quickbook-1.5-spirit2/code_snippet_grammar.hpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/code_snippet_grammar.hpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -0,0 +1,55 @@
+/*=============================================================================
+ Copyright (c) 2002 2004 2006 Joel de Guzman
+ Copyright (c) 2004 Eric Niebler
+ Copyright (c) 2010 Daniel James
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to 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_QUICKBOOK_CODE_SNIPPET_GRAMMARS_HPP)
+#define BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_GRAMMARS_HPP
+
+#include <boost/spirit/include/qi_core.hpp>
+#include <boost/scoped_ptr.hpp>
+#include "fwd.hpp"
+
+namespace quickbook
+{
+ namespace qi = boost::spirit::qi;
+
+ struct python_code_snippet_grammar
+ : qi::grammar<iterator>
+ {
+ typedef code_snippet_actions actions_type;
+
+ python_code_snippet_grammar(actions_type& actions);
+ ~python_code_snippet_grammar();
+
+ struct rules;
+ boost::scoped_ptr<rules> rules_pimpl;
+ qi::rule<iterator> start;
+ private:
+ python_code_snippet_grammar(python_code_snippet_grammar const&);
+ python_code_snippet_grammar& operator=(python_code_snippet_grammar const&);
+ };
+
+ struct cpp_code_snippet_grammar
+ : qi::grammar<iterator>
+ {
+ typedef code_snippet_actions actions_type;
+
+ cpp_code_snippet_grammar(actions_type& actions);
+ ~cpp_code_snippet_grammar();
+
+ struct rules;
+ boost::scoped_ptr<rules> rules_pimpl;
+ qi::rule<iterator> start;
+ private:
+ cpp_code_snippet_grammar(cpp_code_snippet_grammar const&);
+ cpp_code_snippet_grammar& operator=(cpp_code_snippet_grammar const&);
+ };
+}
+
+#endif // BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_GRAMMARS_HPP

Modified: branches/quickbook-1.5-spirit2/doc_info_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/doc_info_grammar.cpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -8,12 +8,6 @@
     http://www.boost.org/LICENSE_1_0.txt)
 =============================================================================*/
 
-#include "doc_info.hpp"
-#include "grammars.hpp"
-#include "actions.hpp"
-#include "state.hpp"
-#include "parse_utils.hpp"
-#include "misc_rules.hpp"
 #include <boost/spirit/include/qi_core.hpp>
 #include <boost/spirit/include/qi_uint.hpp>
 #include <boost/spirit/include/qi_eol.hpp>
@@ -25,6 +19,12 @@
 #include <boost/spirit/include/phoenix_fusion.hpp>
 #include <boost/fusion/include/std_pair.hpp>
 #include <boost/fusion/include/reverse_view.hpp>
+#include "doc_info.hpp"
+#include "grammar_impl.hpp"
+#include "actions.hpp"
+#include "state.hpp"
+#include "parse_utils.hpp"
+#include "misc_rules.hpp"
 
 namespace quickbook
 {
@@ -52,38 +52,25 @@
         qbk_version_n = (qbk_major_version * 100) + qbk_minor_version;
     }
 
- struct doc_info_grammar::rules
+ void quickbook_grammar::impl::init_doc_info()
     {
- rules(quickbook::actions& actions);
-
- quickbook::actions& actions;
- bool unused;
- phrase_grammar common;
- qi::symbols<char> doc_types;
- qi::rule<iterator, doc_info()> doc_info_details;
- qi::rule<iterator, std::pair<unsigned, unsigned>()> quickbook_version;
- qi::rule<iterator, std::string()> phrase;
- qi::rule<iterator, raw_source()> doc_version, doc_id, doc_dirname, doc_category, doc_last_revision;
- qi::rule<iterator, std::string()> doc_source_mode; // TODO: raw_source
- qi::rule<iterator, doc_info::variant_string()> doc_purpose, doc_license;
- qi::rule<iterator, std::pair<std::vector<unsigned int>, std::string>()> doc_copyright;
- qi::rule<iterator, std::vector<std::pair<std::string, std::string> >()> doc_authors;
+ qi::symbols<char>& doc_types = store_.create();
+ qi::rule<iterator, std::pair<unsigned, unsigned>()>& quickbook_version = store_.create();
+ qi::rule<iterator, std::string()>& phrase = store_.create();
+ qi::rule<iterator, raw_source()>& doc_version = store_.create();
+ qi::rule<iterator, raw_source()>& doc_id = store_.create();
+ qi::rule<iterator, raw_source()>& doc_dirname = store_.create();
+ qi::rule<iterator, raw_source()>& doc_category = store_.create();
+ qi::rule<iterator, raw_source()>& doc_last_revision = store_.create();
+ qi::rule<iterator, std::string()>& doc_source_mode = store_.create(); // TODO: raw_source
+ qi::rule<iterator, doc_info::variant_string()>& doc_purpose = store_.create();
+ qi::rule<iterator, doc_info::variant_string()>& doc_license = store_.create();
+ qi::rule<iterator, std::pair<std::vector<unsigned int>, std::string>()>& doc_copyright = store_.create();
+ qi::rule<iterator, std::vector<std::pair<std::string, std::string> >()>& doc_authors = store_.create();
         qi::rule<iterator, boost::fusion::reverse_view<
- std::pair<std::string, std::string> >()> doc_author;
- qi::rule<iterator, quickbook::raw_string()> raw_phrase;
- };
-
- doc_info_grammar::doc_info_grammar(quickbook::actions& actions)
- : doc_info_grammar::base_type(start)
- , rules_pimpl(new rules(actions))
- , start(rules_pimpl->doc_info_details) {}
+ std::pair<std::string, std::string> >()>& doc_author = store_.create();
+ qi::rule<iterator, quickbook::raw_string()>& raw_phrase = store_.create();
 
- doc_info_grammar::~doc_info_grammar() {}
-
-
- doc_info_grammar::rules::rules(quickbook::actions& actions)
- : actions(actions), unused(false), common(actions, unused)
- {
         typedef qi::uint_parser<int, 10, 1, 2> uint2_t;
 
         doc_types =

Added: branches/quickbook-1.5-spirit2/grammar.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/grammar.cpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -0,0 +1,40 @@
+/*=============================================================================
+ Copyright (c) 2002 2004 2006 Joel de Guzman
+ Copyright (c) 2004 Eric Niebler
+ Copyright (c) 2010 Daniel James
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to 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)
+=============================================================================*/
+
+#include "grammar_impl.hpp"
+
+namespace quickbook
+{
+ quickbook_grammar::quickbook_grammar(quickbook::actions& a)
+ : impl_(new impl(a))
+ , phrase(impl_->common, "phrase")
+ , simple_phrase(impl_->simple_phrase, "simple_phrase")
+ , block(impl_->block_start, "block")
+ , doc_info(impl_->doc_info_details, "doc_info")
+ {
+ }
+
+ quickbook_grammar::~quickbook_grammar()
+ {
+ }
+
+ quickbook_grammar::impl::impl(quickbook::actions& a)
+ : actions(a)
+ , no_eols(true)
+ , store_()
+ {
+ init_phrase();
+ init_phrase_markup();
+ init_block();
+ init_block_markup();
+ init_doc_info();
+ }
+}

Added: branches/quickbook-1.5-spirit2/grammar.hpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/grammar.hpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -0,0 +1,41 @@
+/*=============================================================================
+ Copyright (c) 2002 2004 2006 Joel de Guzman
+ Copyright (c) 2004 Eric Niebler
+ Copyright (c) 2010 Daniel James
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to 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_QUICKBOOK_GRAMMARS_HPP)
+#define BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP
+
+#include <boost/spirit/include/qi_core.hpp>
+#include <boost/scoped_ptr.hpp>
+#include "fwd.hpp"
+
+namespace quickbook
+{
+ namespace qi = boost::spirit::qi;
+
+ class quickbook_grammar
+ {
+ public:
+ struct impl;
+
+ private:
+ boost::scoped_ptr<impl> impl_;
+
+ public:
+ qi::grammar<iterator> phrase;
+ qi::grammar<iterator> simple_phrase;
+ qi::grammar<iterator> block;
+ qi::grammar<iterator, quickbook::doc_info()> doc_info;
+
+ quickbook_grammar(quickbook::actions&);
+ ~quickbook_grammar();
+ };
+}
+
+#endif // BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP

Copied: branches/quickbook-1.5-spirit2/grammar_impl.hpp (from r61081, /branches/quickbook-1.5-spirit2/phrase_grammar.hpp)
==============================================================================
--- /branches/quickbook-1.5-spirit2/phrase_grammar.hpp (original)
+++ branches/quickbook-1.5-spirit2/grammar_impl.hpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -1,39 +1,55 @@
 /*=============================================================================
     Copyright (c) 2002 2004 2006 Joel de Guzman
     Copyright (c) 2004 Eric Niebler
+ Copyright (c) 2010 Daniel James
     http://spirit.sourceforge.net/
 
     Use, modification and distribution is subject to 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_QUICKBOOK_GRAMMARS_IMPL_HPP)
+#define BOOST_SPIRIT_QUICKBOOK_GRAMMARS_IMPL_HPP
 
-#include <boost/fusion/include/adapt_struct.hpp>
-#include "grammars.hpp"
-#include "phrase.hpp"
+#include <boost/spirit/include/qi_core.hpp>
+#include <boost/scoped_ptr.hpp>
+#include "fwd.hpp"
 #include "rule_store.hpp"
+#include "grammar.hpp"
 
 namespace quickbook
 {
     namespace qi = boost::spirit::qi;
 
- struct phrase_grammar::rules
+ struct quickbook_grammar::impl
     {
- rules(quickbook::actions& actions, bool& no_eols);
-
         quickbook::actions& actions;
- bool& no_eols;
-
+ bool no_eols;
         rule_store store_;
+
+ // phrase
         qi::rule<iterator> common;
+ qi::rule<iterator> simple_phrase;
         qi::rule<iterator, std::string()> phrase;
         qi::rule<iterator> phrase_markup;
         
+ // block
+ qi::rule<iterator> block_start;
+ qi::rule<iterator> block_markup;
+
+ // doc_info
+ qi::rule<iterator, quickbook::doc_info()> doc_info_details;
+
+ impl(quickbook::actions&);
+
+ private:
+
+ void init_phrase();
         void init_phrase_markup();
+ void init_block();
+ void init_block_markup();
+ void init_doc_info();
     };
 }
 
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::break_,
- (quickbook::file_position, position)
-)
\ No newline at end of file
+#endif // BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP

Deleted: branches/quickbook-1.5-spirit2/grammars.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/grammars.hpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
+++ (empty file)
@@ -1,106 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- Use, modification and distribution is subject to 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_QUICKBOOK_GRAMMARS_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP
-
-#include <boost/spirit/include/qi_core.hpp>
-#include <boost/scoped_ptr.hpp>
-#include "fwd.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
-
- struct phrase_grammar : qi::grammar<iterator>
- {
- phrase_grammar(quickbook::actions& actions, bool& no_eols);
- ~phrase_grammar();
-
- struct rules;
- boost::scoped_ptr<rules> rules_pimpl;
- qi::rule<iterator> start;
- private:
- phrase_grammar(phrase_grammar const&);
- phrase_grammar& operator=(phrase_grammar const&);
- };
-
- struct simple_phrase_grammar : qi::grammar<iterator>
- {
- simple_phrase_grammar(quickbook::actions& actions);
- ~simple_phrase_grammar();
-
- struct rules;
- boost::scoped_ptr<rules> rules_pimpl;
- qi::rule<iterator> start;
- private:
- simple_phrase_grammar(simple_phrase_grammar const&);
- simple_phrase_grammar& operator=(simple_phrase_grammar const&);
- };
-
- struct block_grammar : qi::grammar<iterator>
- {
- block_grammar(quickbook::actions& actions);
- ~block_grammar();
-
- struct rules;
- boost::scoped_ptr<rules> rules_pimpl;
- qi::rule<iterator> start;
- private:
- block_grammar(block_grammar const&);
- block_grammar& operator=(block_grammar const&);
- };
-
- struct doc_info_grammar : qi::grammar<iterator, doc_info()>
- {
- doc_info_grammar(quickbook::actions& actions);
- ~doc_info_grammar();
-
- struct rules;
- boost::scoped_ptr<rules> rules_pimpl;
- qi::rule<iterator, doc_info()> start;
- private:
- doc_info_grammar(doc_info_grammar const&);
- doc_info_grammar& operator=(doc_info_grammar const&);
- };
-
- struct python_code_snippet_grammar
- : qi::grammar<iterator>
- {
- typedef code_snippet_actions actions_type;
-
- python_code_snippet_grammar(actions_type& actions);
- ~python_code_snippet_grammar();
-
- struct rules;
- boost::scoped_ptr<rules> rules_pimpl;
- qi::rule<iterator> start;
- private:
- python_code_snippet_grammar(python_code_snippet_grammar const&);
- python_code_snippet_grammar& operator=(python_code_snippet_grammar const&);
- };
-
- struct cpp_code_snippet_grammar
- : qi::grammar<iterator>
- {
- typedef code_snippet_actions actions_type;
-
- cpp_code_snippet_grammar(actions_type& actions);
- ~cpp_code_snippet_grammar();
-
- struct rules;
- boost::scoped_ptr<rules> rules_pimpl;
- qi::rule<iterator> start;
- private:
- cpp_code_snippet_grammar(cpp_code_snippet_grammar const&);
- cpp_code_snippet_grammar& operator=(cpp_code_snippet_grammar const&);
- };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP

Modified: branches/quickbook-1.5-spirit2/phrase_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_grammar.cpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -36,20 +36,8 @@
     namespace qi = boost::spirit::qi;
     namespace ph = boost::phoenix;
 
- phrase_grammar::phrase_grammar(quickbook::actions& actions, bool& no_eols)
- : phrase_grammar::base_type(start, "phrase")
- , rules_pimpl(new rules(actions, no_eols))
+ void quickbook_grammar::impl::init_phrase()
     {
- start = rules_pimpl->common;
- }
-
- phrase_grammar::~phrase_grammar() {}
-
- phrase_grammar::rules::rules(quickbook::actions& actions, bool& no_eols)
- : actions(actions), no_eols(no_eols)
- {
- init_phrase_markup();
-
         qi::rule<iterator>& macro = store_.create();
         qi::rule<iterator, quickbook::code()>& code_block = store_.create();
         qi::rule<iterator, quickbook::code()>& inline_code = store_.create();
@@ -57,6 +45,13 @@
         qi::rule<iterator>& escape = store_.create();
         qi::rule<iterator>& phrase_end = store_.create();
 
+ simple_phrase =
+ *( common
+ | comment
+ | (qi::char_ - ']') [actions.process]
+ )
+ ;
+
         phrase =
                 qi::eps [actions.phrase_push]
>> *( common
@@ -197,32 +192,4 @@
             ; // past a single block, except
                                                 // when preformatted.
     }
-
- struct simple_phrase_grammar::rules
- {
- rules(quickbook::actions& actions);
-
- quickbook::actions& actions;
- bool unused;
- phrase_grammar common;
- qi::rule<iterator> phrase;
- };
-
- simple_phrase_grammar::simple_phrase_grammar(quickbook::actions& actions)
- : simple_phrase_grammar::base_type(start, "simple_phrase")
- , rules_pimpl(new rules(actions))
- , start(rules_pimpl->phrase) {}
-
- simple_phrase_grammar::~simple_phrase_grammar() {}
-
- simple_phrase_grammar::rules::rules(quickbook::actions& actions)
- : actions(actions), unused(false), common(actions, unused)
- {
- phrase =
- *( common
- | comment
- | (qi::char_ - ']') [actions.process]
- )
- ;
- }
 }

Modified: branches/quickbook-1.5-spirit2/phrase_grammar.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_grammar.hpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_grammar.hpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -9,29 +9,8 @@
 =============================================================================*/
 
 #include <boost/fusion/include/adapt_struct.hpp>
-#include "grammars.hpp"
+#include "grammar_impl.hpp"
 #include "phrase.hpp"
-#include "rule_store.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
-
- struct phrase_grammar::rules
- {
- rules(quickbook::actions& actions, bool& no_eols);
-
- quickbook::actions& actions;
- bool& no_eols;
-
- rule_store store_;
- qi::rule<iterator> common;
- qi::rule<iterator, std::string()> phrase;
- qi::rule<iterator> phrase_markup;
-
- void init_phrase_markup();
- };
-}
 
 BOOST_FUSION_ADAPT_STRUCT(
  quickbook::break_,

Modified: branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -68,7 +68,7 @@
     namespace qi = boost::spirit::qi;
     namespace ph = boost::phoenix;
 
- void phrase_grammar::rules::init_phrase_markup()
+ void quickbook_grammar::impl::init_phrase_markup()
     {
         qi::rule<iterator, quickbook::callout_link()>& callout_link = store_.create();
         qi::rule<iterator, quickbook::cond_phrase()>& cond_phrase = store_.create();

Modified: branches/quickbook-1.5-spirit2/quickbook.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/quickbook.cpp (original)
+++ branches/quickbook-1.5-spirit2/quickbook.cpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -20,7 +20,7 @@
 #include "quickbook.hpp"
 #include "state.hpp"
 #include "actions.hpp"
-#include "grammars.hpp"
+#include "grammar.hpp"
 #include "post_process.hpp"
 #include "utils.hpp"
 #include "input_path.hpp"
@@ -67,8 +67,8 @@
 
         doc_info info;
         actions actor(state_);
- doc_info_grammar l(actor);
- bool success = parse(first, last, l, info);
+ quickbook_grammar g(actor);
+ bool success = parse(first, last, g.doc_info, info);
 
         if (success || ignore_docinfo)
         {
@@ -78,8 +78,7 @@
 
             actor.process(info);
 
- block_grammar g(actor);
- success = parse(first, last, g);
+ success = parse(first, last, g.block);
             if (success && first == last)
             {
                 actor.process(doc_info_post(info));

Modified: branches/quickbook-1.5-spirit2/syntax_highlight_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/syntax_highlight_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/syntax_highlight_grammar.cpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -13,8 +13,8 @@
 #include <boost/spirit/include/qi_string.hpp>
 #include <boost/spirit/include/qi_directive.hpp>
 #include <boost/fusion/include/adapt_struct.hpp>
+#include "grammar.hpp"
 #include "actions.hpp"
-#include "grammars.hpp"
 #include "phrase.hpp"
 #include "utils.hpp"
 #include "syntax_highlight.hpp"
@@ -36,11 +36,10 @@
             : actions(actions) {}
 
         void operator()(boost::iterator_range<iterator> escaped, unused_type, unused_type) const {
- bool unused;
- phrase_grammar common(actions, unused);
+ quickbook_grammar g(actions);
             iterator first = escaped.begin(), last = escaped.end();
             while(first != last) {
- if(!qi::parse(first, last, common)) {
+ if(!qi::parse(first, last, g.phrase)) {
                     actions.process(*first);
                     ++first;
                 }

Modified: branches/quickbook-1.5-spirit2/template.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/template.cpp (original)
+++ branches/quickbook-1.5-spirit2/template.cpp 2010-04-05 15:45:18 EDT (Mon, 05 Apr 2010)
@@ -10,7 +10,7 @@
 #include <boost/spirit/include/qi_symbols.hpp>
 #include "template.hpp"
 #include "phrase_actions.hpp"
-#include "grammars.hpp"
+#include "grammar.hpp"
 #include "state.hpp"
 #include "utils.hpp"
 
@@ -325,19 +325,19 @@
             else if (!is_block)
             {
                 quickbook::actions actions(state);
- simple_phrase_grammar phrase_p(actions);
+ quickbook_grammar g(actions);
 
                 // do a phrase level parse
                 iterator first(body.begin(), body.end(), state.filename.native_file_string().c_str());
                 first.set_position(template_pos);
                 iterator last(body.end(), body.end());
- r = boost::spirit::qi::parse(first, last, phrase_p) && first == last;
+ r = boost::spirit::qi::parse(first, last, g.simple_phrase) && first == last;
                 state.phrase.swap(result);
             }
             else
             {
                 quickbook::actions actions(state);
- block_grammar block_p(actions);
+ quickbook_grammar g(actions);
 
                 // do a block level parse
                 // ensure that we have enough trailing newlines to eliminate
@@ -353,7 +353,7 @@
                 while (first != last && ((*first == '\r') || (*first == '\n')))
                     ++first; // skip initial newlines
 
- r = boost::spirit::qi::parse(first, last, block_p) && first == last;
+ r = boost::spirit::qi::parse(first, last, g.block) && first == last;
                 state.phrase.swap(result);
             }
             


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