$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r65031 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2010-08-26 16:57:49
Author: danieljames
Date: 2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
New Revision: 65031
URL: http://svn.boost.org/trac/boost/changeset/65031
Log:
Separate grammar compilation.
Added:
   trunk/tools/quickbook/src/block_grammar.cpp   (contents, props changed)
      - copied, changed from r65030, /trunk/tools/quickbook/src/block.hpp
   trunk/tools/quickbook/src/doc_info_grammar.cpp   (contents, props changed)
      - copied, changed from r65030, /trunk/tools/quickbook/src/doc_info.hpp
   trunk/tools/quickbook/src/grammar.hpp   (contents, props changed)
   trunk/tools/quickbook/src/phrase_grammar.cpp   (contents, props changed)
      - copied, changed from r65030, /trunk/tools/quickbook/src/phrase.hpp
   trunk/tools/quickbook/src/phrase_grammar.hpp   (contents, props changed)
Removed:
   trunk/tools/quickbook/src/block.hpp
   trunk/tools/quickbook/src/doc_info.hpp
   trunk/tools/quickbook/src/phrase.hpp
Text files modified: 
   trunk/tools/quickbook/src/Jamfile.v2           |     3 +                                       
   trunk/tools/quickbook/src/actions.cpp          |     7 +-                                      
   trunk/tools/quickbook/src/block_grammar.cpp    |    77 ++++++++++++++--------------            
   trunk/tools/quickbook/src/doc_info_grammar.cpp |    58 +++++++++++----------                   
   trunk/tools/quickbook/src/phrase_grammar.cpp   |   106 ++++++++++++++++++++++----------------- 
   trunk/tools/quickbook/src/quickbook.cpp        |    56 --------------------                    
   trunk/tools/quickbook/src/syntax_highlight.cpp |     6 +-                                      
   trunk/tools/quickbook/src/syntax_highlight.hpp |     2                                         
   8 files changed, 140 insertions(+), 175 deletions(-)
Modified: trunk/tools/quickbook/src/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/src/Jamfile.v2	(original)
+++ trunk/tools/quickbook/src/Jamfile.v2	2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
@@ -28,6 +28,9 @@
     template_stack.cpp
     markups.cpp
     syntax_highlight.cpp
+    block_grammar.cpp
+    phrase_grammar.cpp
+    doc_info_grammar.cpp
     /boost//program_options
     /boost//filesystem
     : #<define>QUICKBOOK_NO_DATES
Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp	(original)
+++ trunk/tools/quickbook/src/actions.cpp	2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
@@ -22,8 +22,7 @@
 #include "./utils.hpp"
 #include "./markups.hpp"
 #include "./actions_class.hpp"
-#include "./block.hpp"
-#include "./phrase.hpp"
+#include "./grammar.hpp"
 #include "./code_snippet.hpp"
 
 namespace quickbook
@@ -764,7 +763,7 @@
                 //  do a phrase level parse
                 iterator first(body.content.begin(), body.content.end(), body.position);
                 iterator last(body.content.end(), body.content.end());
-                bool r = boost::spirit::classic::parse(first, last, phrase_p).full;
+                bool r = quickbook::parse(first, last, phrase_p).full;
                 actions.phrase.swap(result);
                 return r;
             }
@@ -779,7 +778,7 @@
                 std::string content = body.content + "\n\n";
                 iterator first(content.begin(), content.end(), body.position);
                 iterator last(content.end(), content.end());
-                bool r = boost::spirit::classic::parse(first, last, block_p).full;
+                bool r = quickbook::parse(first, last, block_p).full;
                 actions.inside_paragraph();
                 actions.out.swap(result);
                 return r;
Deleted: trunk/tools/quickbook/src/block.hpp
==============================================================================
--- trunk/tools/quickbook/src/block.hpp	2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,481 +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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP
-
-#include "./quickbook.hpp"
-#include "./utils.hpp"
-#include "./phrase.hpp"
-#include <boost/spirit/include/classic_core.hpp>
-#include <boost/spirit/include/classic_confix.hpp>
-#include <boost/spirit/include/classic_chset.hpp>
-#include <boost/spirit/include/classic_assign_actor.hpp>
-#include <boost/spirit/include/classic_if.hpp>
-#include <boost/spirit/include/classic_symbols.hpp>
-
-namespace quickbook
-{
-    using namespace boost::spirit::classic;
-
-    struct block_grammar : grammar<block_grammar>
-    {
-        block_grammar(quickbook::actions& actions_, bool skip_initial_spaces = false)
-            : actions(actions_), skip_initial_spaces(skip_initial_spaces) { }
-
-        template <typename Scanner>
-        struct definition
-        {
-            definition(block_grammar const& self)
-                : no_eols(true)
-                , common(self.actions, no_eols)
-            {
-                using detail::var;
-                quickbook::actions& actions = self.actions;
-
-                if (self.skip_initial_spaces)
-                {
-                    start_ =
-                        *(blank_p | comment) >> blocks >> blank
-                        ;
-                }
-                else
-                {
-                    start_ =
-                        blocks >> blank
-                        ;
-                }
-
-                blocks =
-                   *(   block_markup
-                    |   code
-                    |   list                            [actions.list]
-                    |   hr                              [actions.hr]
-                    |   +eol
-                    |   paragraph                       [actions.inside_paragraph]
-                                                        [actions.write_paragraphs]
-                    )
-                    ;
-
-                space =
-                    *(space_p | comment)
-                    ;
-
-                blank =
-                    *(blank_p | comment)
-                    ;
-
-                eol = blank >> eol_p
-                    ;
-
-                phrase_end =
-                    ']' |
-                    if_p(var(no_eols))
-                    [
-                        eol >> *blank_p >> eol_p
-                                                        // Make sure that we don't go
-                    ]                                   // past a single block, except
-                    ;                                   // when preformatted.
-
-                hard_space =
-                    (eps_p - (alnum_p | '_')) >> space  // must not be preceded by
-                    ;                                   // alpha-numeric or underscore
-
-                comment =
-                    "[/" >> *(dummy_block | (anychar_p - ']')) >> ']'
-                    ;
-
-                dummy_block =
-                    '[' >> *(dummy_block | (anychar_p - ']')) >> ']'
-                    ;
-
-                hr =
-                    str_p("----")
-                    >> *(anychar_p - eol)
-                    >> +eol
-                    ;
-
-                block_markup =
-                        '[' >> space
-                    >>  (   begin_section
-                        |   end_section
-                        |   headings
-                        |   blurb
-                        |   blockquote
-                        |   admonition
-                        |   preformatted
-                        |   def_macro
-                        |   table
-                        |   variablelist
-                        |   xinclude
-                        |   include
-                        |   import
-                        |   template_
-                        )
-                    >>  (   (space >> ']' >> +eol)
-                        |   eps_p                       [actions.error]
-                        )
-                    ;
-                
-                element_id =
-                        ':'
-                    >>
-                        (
-                            if_p(qbk_since(105u))       [space]
-                        >>  (+(alnum_p | '_'))          [assign_a(actions.element_id)]
-                        |   eps_p                       [actions.element_id_warning]
-                                                        [assign_a(actions.element_id)]
-                        )
-                    | eps_p                             [assign_a(actions.element_id)]
-                    ;
-                
-                element_id_1_5 =
-                        if_p(qbk_since(105u)) [
-                            element_id
-                        ]
-                        .else_p [
-                            eps_p                       [assign_a(actions.element_id)]
-                        ]
-                        ;
-
-                element_id_1_6 =
-                        if_p(qbk_since(106u)) [
-                            element_id
-                        ]
-                        .else_p [
-                            eps_p                       [assign_a(actions.element_id)]
-                        ]
-                        ;
-
-                begin_section =
-                       "section"
-                    >> hard_space
-                    >> element_id
-                    >> space
-                    >> phrase                           [actions.begin_section]
-                    ;
-
-                end_section =
-                    str_p("endsect")                    [actions.end_section]
-                    ;
-
-                headings =
-                    h1 | h2 | h3 | h4 | h5 | h6 | h
-                    ;
-
-                h = "heading" >> hard_space >> element_id_1_6 >> space >> phrase   [actions.h];
-                h1 = "h1" >> hard_space >> element_id_1_6 >> space >> phrase       [actions.h1];
-                h2 = "h2" >> hard_space >> element_id_1_6 >> space >> phrase       [actions.h2];
-                h3 = "h3" >> hard_space >> element_id_1_6 >> space >> phrase       [actions.h3];
-                h4 = "h4" >> hard_space >> element_id_1_6 >> space >> phrase       [actions.h4];
-                h5 = "h5" >> hard_space >> element_id_1_6 >> space >> phrase       [actions.h5];
-                h6 = "h6" >> hard_space >> element_id_1_6 >> space >> phrase       [actions.h6];
-
-                static const bool true_ = true;
-                static const bool false_ = false;
-
-                inside_paragraph =
-                    phrase                              [actions.inside_paragraph]
-                    >> *(
-                        +eol >> phrase                  [actions.inside_paragraph]
-                    )
-                    ;
-
-                blurb =
-                    "blurb" >> hard_space
-                    >> inside_paragraph                 [actions.blurb]
-                    >> eps_p
-                    ;
-
-                blockquote =
-                    ':' >> blank >>
-                    inside_paragraph                    [actions.blockquote]
-                    ;
-
-                admonition =
-                    "warning" >> blank >>
-                    inside_paragraph                    [actions.warning]
-                    |
-                    "caution" >> blank >>
-                    inside_paragraph                    [actions.caution]
-                    |
-                    "important" >> blank >>
-                    inside_paragraph                    [actions.important]
-                    |
-                    "note" >> blank >>
-                    inside_paragraph                    [actions.note]
-                    |
-                    "tip" >> blank >>
-                    inside_paragraph                    [actions.tip]
-                    ;
-
-                preformatted =
-                    "pre" >> hard_space                 [assign_a(no_eols, false_)]
-                    >> !eol >> phrase                   [actions.preformatted]
-                    >> eps_p                            [assign_a(no_eols, true_)]
-                    ;
-
-                macro_identifier =
-                    +(anychar_p - (space_p | ']'))
-                    ;
-
-                def_macro =
-                    "def" >> hard_space
-                    >> macro_identifier                 [actions.macro_identifier]
-                    >> blank >> phrase                  [actions.macro_definition]
-                    ;
-
-                identifier =
-                    (alpha_p | '_') >> *(alnum_p | '_')
-                    ;
-
-                template_id =
-                    identifier | (punct_p - (ch_p('[') | ']'))
-                    ;
-
-                template_ =
-                    "template"
-                    >> hard_space
-                    >> template_id                      [assign_a(actions.template_identifier)]
-                                                        [clear_a(actions.template_info)]
-                    >>
-                    !(
-                        space >> '['
-                        >> *(
-                                space >> template_id    [push_back_a(actions.template_info)]
-                            )
-                        >> space >> ']'
-                    )
-                    >>  (   eps_p(*blank_p >> eol_p)    [assign_a(actions.template_block, true_)]
-                        |   eps_p                       [assign_a(actions.template_block, false_)]
-                        )
-                    >>  template_body                   [actions.template_body]
-                    ;
-
-                template_body =
-                   *(('[' >> template_body >> ']') | (anychar_p - ']'))
-                    >> eps_p(space >> ']')
-                    >> space
-                    ;
-
-                variablelist =
-                    "variablelist"
-                    >>  (eps_p(*blank_p >> eol_p) | hard_space)
-                    >>  (*(anychar_p - eol))            [assign_a(actions.table_title)]
-                    >>  +eol
-                    >>  *varlistentry
-                    >>  eps_p                           [actions.variablelist]
-                    ;
-
-                varlistentry =
-                    space
-                    >>  ch_p('[')                       [actions.start_varlistentry]
-                    >>
-                    (
-                        (
-                            varlistterm                 [actions.start_varlistitem]
-                            >>  (   +varlistitem
-                                |   eps_p               [actions.error]
-                                )                       [actions.end_varlistitem]
-                            >>  ch_p(']')               [actions.end_varlistentry]
-                            >>  space
-                        )
-                        | eps_p                         [actions.error]
-                    )
-                    ;
-
-                varlistterm =
-                    space
-                    >>  ch_p('[')                       [actions.start_varlistterm]
-                    >>
-                    (
-                        (
-                            phrase
-                            >>  ch_p(']')               [actions.end_varlistterm]
-                            >>  space
-                        )
-                        | eps_p                         [actions.error]
-                    )
-                    ;
-
-                varlistitem =
-                    space
-                    >>  ch_p('[')
-                    >>
-                    (
-                        (
-                            inside_paragraph
-                            >>  ch_p(']')
-                            >>  space
-                        )
-                        | eps_p                         [actions.error]
-                    )
-                    ;
-
-                table =
-                    "table"
-                    >>  (eps_p(*blank_p >> eol_p) | hard_space)
-                    >> element_id_1_5
-                    >>  (eps_p(*blank_p >> eol_p) | space)
-                    >>  (*(anychar_p - eol))            [assign_a(actions.table_title)]
-                    >>  +eol
-                    >>  *table_row
-                    >>  eps_p                           [actions.table]
-                    ;
-
-                table_row =
-                    space
-                    >>  ch_p('[')                       [actions.start_row]
-                    >>
-                    (
-                        (
-                            *table_cell
-                            >>  ch_p(']')               [actions.end_row]
-                            >>  space
-                        )
-                        | eps_p                         [actions.error]
-                    )
-                    ;
-
-                table_cell =
-                    space
-                    >>  ch_p('[')                       [actions.start_cell]
-                    >>
-                    (
-                        (
-                            inside_paragraph
-                            >>  ch_p(']')               [actions.end_cell]
-                            >>  space
-                        )
-                        | eps_p                         [actions.error]
-                    )
-                    ;
-
-                xinclude =
-                       "xinclude"
-                    >> hard_space
-                    >> (*(anychar_p -
-                            phrase_end))                [actions.xinclude]
-                    ;
-
-                import =
-                       "import"
-                    >> hard_space
-                    >> (*(anychar_p -
-                            phrase_end))                [actions.import]
-                    ;
-
-                include =
-                       "include"
-                    >> hard_space
-                    >>
-                   !(
-                        ':'
-                        >> (*((alnum_p | '_') - space_p))[assign_a(actions.include_doc_id)]
-                        >> space
-                    )
-                    >> (*(anychar_p -
-                            phrase_end))                [actions.include]
-                    ;
-
-                code =
-                    (
-                        code_line
-                        >> *(*blank_line >> code_line)
-                    )                                   [actions.code]
-                    >> *eol
-                    ;
-
-                code_line =
-                    blank_p >> *(anychar_p - eol_p) >> eol_p
-                    ;
-
-                blank_line =
-                    *blank_p >> eol_p
-                    ;
-
-                list =
-                    eps_p(ch_p('*') | '#') >>
-                   +(
-                        (*blank_p
-                        >> (ch_p('*') | '#'))           [actions.list_format]
-                        >> *blank_p
-                        >> list_item
-                    )                                   [actions.list_item]
-                    ;
-
-                list_item =
-                   *(   common
-                    |   (anychar_p -
-                            (   eol_p >> *blank_p >> eps_p(ch_p('*') | '#')
-                            |   (eol >> eol)
-                            )
-                        )                               [actions.plain_char]
-                    )
-                    >> +eol
-                    ;
-
-                paragraph_end_markups =
-                    "section", "endsect", "h1", "h2", "h3", "h4", "h5", "h6",
-                    "blurb", ":", "pre", "def", "table", "include", "xinclude",
-                    "variablelist", "import", "template", "warning", "caution",
-                    "important", "note", "tip", ":"
-                    ;
-
-                paragraph_end =
-                    '[' >> space >> paragraph_end_markups >> hard_space | eol >> *blank_p >> eol_p
-                    ;
-
-                paragraph =
-                   +(   common
-                    |   (anychar_p -                    // Make sure we don't go past
-                            paragraph_end               // a single block.
-                        )                               [actions.plain_char]
-                    )
-                    >> (eps_p('[') | +eol)
-                    ;
-
-                phrase =
-                   *(   common
-                    |   comment
-                    |   (anychar_p -
-                            phrase_end)                 [actions.plain_char]
-                    )
-                    ;
-            }
-
-            bool no_eols;
-
-            rule<Scanner>   start_, blocks, block_markup, code, code_line, blank_line,
-                            paragraph, space, blank, comment, headings, h, h1, h2,
-                            h3, h4, h5, h6, hr, blurb, blockquote, admonition,
-                            phrase, list, phrase_end, ordered_list, def_macro,
-                            macro_identifier, table, table_row, variablelist,
-                            varlistentry, varlistterm, varlistitem, table_cell,
-                            preformatted, list_item, begin_section, end_section,
-                            xinclude, include, hard_space, eol, paragraph_end,
-                            template_, template_id, template_formal_arg,
-                            template_body, identifier, dummy_block, import,
-                            inside_paragraph,
-                            element_id, element_id_1_5, element_id_1_6;
-
-            symbols<>       paragraph_end_markups;
-
-            phrase_grammar common;
-
-            rule<Scanner> const&
-            start() const { return start_; }
-        };
-
-        quickbook::actions& actions;
-        bool const skip_initial_spaces;
-    };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP
Copied: trunk/tools/quickbook/src/block_grammar.cpp (from r65030, /trunk/tools/quickbook/src/block.hpp)
==============================================================================
--- /trunk/tools/quickbook/src/block.hpp	(original)
+++ trunk/tools/quickbook/src/block_grammar.cpp	2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
@@ -7,32 +7,52 @@
     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_BLOCK_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP
 
+#include "./phrase_grammar.hpp"
 #include "./quickbook.hpp"
 #include "./utils.hpp"
-#include "./phrase.hpp"
-#include <boost/spirit/include/classic_core.hpp>
+#include "./actions_class.hpp"
 #include <boost/spirit/include/classic_confix.hpp>
 #include <boost/spirit/include/classic_chset.hpp>
 #include <boost/spirit/include/classic_assign_actor.hpp>
 #include <boost/spirit/include/classic_if.hpp>
 #include <boost/spirit/include/classic_symbols.hpp>
+#include <boost/spirit/include/classic_clear_actor.hpp>
 
 namespace quickbook
 {
     using namespace boost::spirit::classic;
 
-    struct block_grammar : grammar<block_grammar>
-    {
-        block_grammar(quickbook::actions& actions_, bool skip_initial_spaces = false)
-            : actions(actions_), skip_initial_spaces(skip_initial_spaces) { }
-
         template <typename Scanner>
-        struct definition
+        struct block_grammar::definition
         {
-            definition(block_grammar const& self)
+            definition(block_grammar const&);
+
+            bool no_eols;
+
+            rule<Scanner>   start_, blocks, block_markup, code, code_line, blank_line,
+                            paragraph, space, blank, comment, headings, h, h1, h2,
+                            h3, h4, h5, h6, hr, blurb, blockquote, admonition,
+                            phrase, list, phrase_end, ordered_list, def_macro,
+                            macro_identifier, table, table_row, variablelist,
+                            varlistentry, varlistterm, varlistitem, table_cell,
+                            preformatted, list_item, begin_section, end_section,
+                            xinclude, include, hard_space, eol, paragraph_end,
+                            template_, template_id, template_formal_arg,
+                            template_body, identifier, dummy_block, import,
+                            inside_paragraph,
+                            element_id, element_id_1_5, element_id_1_6;
+
+            symbols<>       paragraph_end_markups;
+
+            phrase_grammar common;
+
+            rule<Scanner> const&
+            start() const { return start_; }
+        };
+
+            template <typename Scanner>
+            block_grammar::definition<Scanner>::definition(block_grammar const& self)
                 : no_eols(true)
                 , common(self.actions, no_eols)
             {
@@ -450,32 +470,13 @@
                     ;
             }
 
-            bool no_eols;
-
-            rule<Scanner>   start_, blocks, block_markup, code, code_line, blank_line,
-                            paragraph, space, blank, comment, headings, h, h1, h2,
-                            h3, h4, h5, h6, hr, blurb, blockquote, admonition,
-                            phrase, list, phrase_end, ordered_list, def_macro,
-                            macro_identifier, table, table_row, variablelist,
-                            varlistentry, varlistterm, varlistitem, table_cell,
-                            preformatted, list_item, begin_section, end_section,
-                            xinclude, include, hard_space, eol, paragraph_end,
-                            template_, template_id, template_formal_arg,
-                            template_body, identifier, dummy_block, import,
-                            inside_paragraph,
-                            element_id, element_id_1_5, element_id_1_6;
-
-            symbols<>       paragraph_end_markups;
-
-            phrase_grammar common;
-
-            rule<Scanner> const&
-            start() const { return start_; }
-        };
+    template <typename Iterator, typename Grammar>
+    parse_info<Iterator> parse(Iterator& first, Iterator last, Grammar& g)
+    {
+        return boost::spirit::classic::parse(first, last, g);
+    }
 
-        quickbook::actions& actions;
-        bool const skip_initial_spaces;
-    };
+    void instantiate_block_grammar(quickbook::iterator i, block_grammar& g) {
+        parse(i, i, g);
+    }
 }
-
-#endif // BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP
Deleted: trunk/tools/quickbook/src/doc_info.hpp
==============================================================================
--- trunk/tools/quickbook/src/doc_info.hpp	2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,216 +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_DOC_INFO_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP
-
-#include "./phrase.hpp"
-#include "./quickbook.hpp"
-#include <boost/spirit/include/classic_core.hpp>
-#include <boost/spirit/include/classic_actor.hpp>
-#include <boost/spirit/include/classic_loops.hpp>
-#include <boost/spirit/include/classic_symbols.hpp>
-
-namespace quickbook
-{
-    using namespace boost::spirit::classic;
-
-    struct doc_info_grammar
-    : public grammar<doc_info_grammar>
-    {
-        doc_info_grammar(quickbook::actions& actions)
-            : actions(actions) {}
-
-        template <typename Scanner>
-        struct definition
-        {
-            typedef uint_parser<int, 10, 1, 2>  uint2_t;
-
-            definition(doc_info_grammar const& self)
-                : unused(false), common(self.actions, unused)
-            {
-                quickbook::actions& actions = self.actions;
-
-                doc_types =
-                    "book", "article", "library", "chapter", "part"
-                  , "appendix", "preface", "qandadiv", "qandaset"
-                  , "reference", "set"
-                ;
-                
-                doc_info =
-                    space
-                    >> '[' >> space
-                    >> (doc_types >> eps_p)         [assign_a(actions.doc_type)]
-                    >> hard_space
-                    >>  (  *(~eps_p(ch_p('[') | ']' | eol_p) >> char_)
-                        )                           [actions.extract_doc_title]
-                    >>  !(
-                            space >> '[' >>
-                                quickbook_version
-                            >> space >> ']'
-                        )
-                    >>
-                        *(
-                            space >> '[' >>
-                            (
-                              doc_version
-                            | doc_id
-                            | doc_dirname
-                            | doc_copyright         [push_back_a(actions.doc_copyrights, actions.copyright)]
-                            | doc_purpose
-                            | doc_category
-                            | doc_authors
-                            | doc_license
-                            | doc_last_revision
-                            | doc_source_mode
-                            )
-                            >> space >> ']' >> +eol_p
-                        )
-                    >> space >> ']' >> +eol_p
-                    ;
-
-                quickbook_version =
-                        "quickbook" >> hard_space
-                    >>  (   uint_p                  [assign_a(qbk_major_version)]
-                            >> '.' 
-                            >>  uint2_t()           [assign_a(qbk_minor_version)]
-                        )
-                    ;
-
-                doc_version =
-                        "version" >> hard_space
-                    >> (*(~eps_p(']') >> char_))    [actions.extract_doc_version]
-                    ;
-
-                // TODO: Restrictions on doc_id?
-                doc_id =
-                        "id" >> hard_space
-                    >> (*(~eps_p(']') >> char_))    [actions.extract_doc_id]
-                    ;
-
-                // TODO: Restrictions on doc_dirname?
-                doc_dirname =
-                        "dirname" >> hard_space
-                    >> (*(~eps_p(']') >> char_))    [actions.extract_doc_dirname]
-                    ;
-
-                doc_copyright =
-                        "copyright" >> hard_space   [clear_a(actions.copyright.first)]
-                    >> +( repeat_p(4)[digit_p]      [push_back_a(actions.copyright.first)]
-                          >> space
-                        )
-                    >> space
-                    >> (*(~eps_p(']') >> char_))    [actions.extract_copyright_second]
-                    ;
-
-                doc_purpose =
-                        "purpose" >> hard_space
-                    >> phrase                       [actions.extract_doc_purpose]
-                    ;
-
-                doc_category =
-                        "category" >> hard_space
-                    >> (*(~eps_p(']') >> char_))    [actions.extract_doc_category]
-                                                    [push_back_a(actions.doc_categories, actions.doc_category)]
-                    ;
-
-                doc_author =
-                        '[' >> space
-                    >>  (*(~eps_p(',') >> char_))   [actions.extract_name_second] // surname
-                    >>  ',' >> space
-                    >>  (*(~eps_p(']') >> char_))   [actions.extract_name_first] // firstname
-                    >>  ']'
-                    ;
-
-                doc_authors =
-                        "authors"
-                    >>  hard_space
-                    >>  doc_author                  [push_back_a(actions.doc_authors, actions.name)]
-                    >>  space
-                    >>  *(  !(ch_p(',') >> space)
-                        >>  doc_author              [push_back_a(actions.doc_authors, actions.name)]
-                        >>  space
-                        )
-                    ;
-
-                doc_license =
-                        "license" >> hard_space
-                    >> phrase                       [actions.extract_doc_license]
-                    ;
-
-                doc_last_revision =
-                        "last-revision" >> hard_space
-                    >> (*(~eps_p(']') >> char_))    [actions.extract_doc_last_revision]
-                    ;
-
-                doc_source_mode =
-                        "source-mode" >> hard_space
-                    >>  (
-                           str_p("c++") 
-                        |  "python"
-                        |  "teletype"
-                        )                           [assign_a(actions.source_mode)]
-                    ;
-
-                comment =
-                    "[/" >> *(anychar_p - ']') >> ']'
-                    ;
-
-                space =
-                    *(space_p | comment)
-                    ;
-
-                hard_space =
-                    (eps_p - (alnum_p | '_')) >> space  // must not be preceded by
-                    ;                                   // alpha-numeric or underscore
-
-                phrase =
-                   *(   common
-                    |   comment
-                    |   (anychar_p - ']')           [actions.plain_char]
-                    )
-                    ;
-
-                char_ =
-                        str_p("\\n")                [actions.break_]
-                    |   "\\ "                       // ignore an escaped space
-                    |   '\\' >> punct_p             [actions.raw_char]
-                    |   "\\u" >> repeat_p(4) [chset<>("0-9a-fA-F")]
-                                                    [actions.escape_unicode]
-                    |   "\\U" >> repeat_p(8) [chset<>("0-9a-fA-F")]
-                                                    [actions.escape_unicode]
-                    |   (
-                            ("'''" >> !eol_p)       [actions.escape_pre]
-                        >>  *(anychar_p - "'''")    [actions.raw_char]
-                        >>  str_p("'''")            [actions.escape_post]
-                        )
-                    |   anychar_p                   [actions.plain_char]
-                    ;
-            }
-
-            bool unused;
-            std::string category;
-            rule<Scanner>   doc_info, doc_title, doc_version, doc_id, doc_dirname,
-                            doc_copyright, doc_purpose, doc_category, doc_authors,
-                            doc_author, comment, space, hard_space, doc_license,
-                            doc_last_revision, doc_source_mode, phrase, quickbook_version,
-                            char_;
-            phrase_grammar common;
-            symbols<> doc_types;
-
-            rule<Scanner> const&
-            start() const { return doc_info; }
-        };
-
-        quickbook::actions& actions;
-    };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP
-
Copied: trunk/tools/quickbook/src/doc_info_grammar.cpp (from r65030, /trunk/tools/quickbook/src/doc_info.hpp)
==============================================================================
--- /trunk/tools/quickbook/src/doc_info.hpp	(original)
+++ trunk/tools/quickbook/src/doc_info_grammar.cpp	2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
@@ -7,32 +7,43 @@
     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_DOC_INFO_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP
 
-#include "./phrase.hpp"
+#include "./phrase_grammar.hpp"
 #include "./quickbook.hpp"
+#include "./actions_class.hpp"
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_actor.hpp>
 #include <boost/spirit/include/classic_loops.hpp>
 #include <boost/spirit/include/classic_symbols.hpp>
+#include <boost/spirit/include/classic_chset.hpp>
 
 namespace quickbook
 {
     using namespace boost::spirit::classic;
 
-    struct doc_info_grammar
-    : public grammar<doc_info_grammar>
-    {
-        doc_info_grammar(quickbook::actions& actions)
-            : actions(actions) {}
-
         template <typename Scanner>
-        struct definition
+        struct doc_info_grammar::definition
         {
+            definition(doc_info_grammar const&);
+
             typedef uint_parser<int, 10, 1, 2>  uint2_t;
 
-            definition(doc_info_grammar const& self)
+            bool unused;
+            std::string category;
+            rule<Scanner>   doc_info, doc_title, doc_version, doc_id, doc_dirname,
+                            doc_copyright, doc_purpose, doc_category, doc_authors,
+                            doc_author, comment, space, hard_space, doc_license,
+                            doc_last_revision, doc_source_mode, phrase, quickbook_version,
+                            char_;
+            phrase_grammar common;
+            symbols<> doc_types;
+
+            rule<Scanner> const&
+            start() const { return doc_info; }
+        };
+
+            template <typename Scanner>
+            doc_info_grammar::definition<Scanner>::definition(doc_info_grammar const& self)
                 : unused(false), common(self.actions, unused)
             {
                 quickbook::actions& actions = self.actions;
@@ -194,23 +205,14 @@
                     ;
             }
 
-            bool unused;
-            std::string category;
-            rule<Scanner>   doc_info, doc_title, doc_version, doc_id, doc_dirname,
-                            doc_copyright, doc_purpose, doc_category, doc_authors,
-                            doc_author, comment, space, hard_space, doc_license,
-                            doc_last_revision, doc_source_mode, phrase, quickbook_version,
-                            char_;
-            phrase_grammar common;
-            symbols<> doc_types;
 
-            rule<Scanner> const&
-            start() const { return doc_info; }
-        };
+    template <typename Iterator, typename Grammar>
+    parse_info<Iterator> parse(Iterator& first, Iterator last, Grammar& g)
+    {
+        return boost::spirit::classic::parse(first, last, g);
+    }
 
-        quickbook::actions& actions;
-    };
+    void instantiate_doc_info_grammar(quickbook::iterator i, doc_info_grammar& g) {
+        parse(i, i, g);
+    }
 }
-
-#endif // BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP
-
Added: trunk/tools/quickbook/src/grammar.hpp
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/src/grammar.hpp	2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
@@ -0,0 +1,83 @@
+/*=============================================================================
+    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)
+=============================================================================*/
+#if !defined(BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP)
+#define BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP
+
+#include <boost/spirit/include/classic_core.hpp>
+#include "./actions.hpp"
+
+namespace quickbook
+{
+    using namespace boost::spirit::classic;
+
+    struct doc_info_grammar
+    : public grammar<doc_info_grammar>
+    {
+        doc_info_grammar(quickbook::actions& actions)
+            : actions(actions) {}
+
+        template <typename Scanner>
+        struct definition;
+
+        quickbook::actions& actions;
+    };
+
+    struct block_grammar : grammar<block_grammar>
+    {
+        block_grammar(quickbook::actions& actions_, bool skip_initial_spaces = false)
+            : actions(actions_), skip_initial_spaces(skip_initial_spaces) { }
+
+        template <typename Scanner>
+        struct definition;
+
+        quickbook::actions& actions;
+        bool const skip_initial_spaces;
+    };
+
+    struct phrase_grammar : grammar<phrase_grammar>
+    {
+        phrase_grammar(quickbook::actions& actions, bool& no_eols)
+            : no_eols(no_eols), actions(actions) {}
+
+        template <typename Scanner>
+        struct definition;
+
+        bool& no_eols;
+        quickbook::actions& actions;
+    };
+
+    struct simple_phrase_grammar : public grammar<simple_phrase_grammar >
+    {
+        simple_phrase_grammar(quickbook::actions& actions)
+            : actions(actions) {}
+
+        template <typename Scanner>
+        struct definition;
+
+        quickbook::actions& actions;
+    };
+
+    struct command_line_grammar
+        : public grammar<command_line_grammar>
+    {
+        command_line_grammar(quickbook::actions& actions)
+            : actions(actions) {}
+
+        template <typename Scanner>
+        struct definition;
+
+        quickbook::actions& actions;
+    };
+
+    template <typename Iterator, typename Grammar>
+    parse_info<Iterator> parse(Iterator&, Iterator, Grammar&);
+}
+
+#endif
\ No newline at end of file
Deleted: trunk/tools/quickbook/src/phrase.hpp
==============================================================================
--- trunk/tools/quickbook/src/phrase.hpp	2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
+++ (empty file)
@@ -1,539 +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_PHRASE_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
-
-#include "./quickbook.hpp"
-#include "./actions_class.hpp"
-#include "utils.hpp"
-#include <boost/spirit/include/classic_core.hpp>
-#include <boost/spirit/include/classic_confix.hpp>
-#include <boost/spirit/include/classic_chset.hpp>
-#include <boost/spirit/include/classic_assign_actor.hpp>
-#include <boost/spirit/include/classic_clear_actor.hpp>
-#include <boost/spirit/include/classic_if.hpp>
-#include <boost/spirit/include/classic_loops.hpp>
-
-namespace quickbook
-{
-    using namespace boost::spirit::classic;
-
-    template <typename Rule, typename Action>
-    inline void
-    simple_markup(
-        Rule& simple
-      , char mark
-      , Action const& action
-      , Rule const& close
-    )
-    {
-        simple =
-            mark >>
-            (
-                (
-                    graph_p                     // A single char. e.g. *c*
-                    >> eps_p(mark
-                        >> (space_p | punct_p | end_p))
-                                                // space_p, punct_p or end_p
-                )                               // must follow mark
-            |
-                (   graph_p >>                  // graph_p must follow mark
-                    *(anychar_p -
-                        (   (graph_p >> mark)   // Make sure that we don't go
-                        |   close               // past a single block
-                        )
-                    ) >> graph_p                // graph_p must precede mark
-                    >> eps_p(mark
-                        >> (space_p | punct_p | end_p))
-                                                // space_p, punct_p or end_p
-                )                               // must follow mark
-            )                                   [action]
-            >> mark
-            ;
-    }
-
-    struct phrase_grammar : grammar<phrase_grammar>
-    {
-        phrase_grammar(quickbook::actions& actions, bool& no_eols)
-            : no_eols(no_eols), actions(actions) {}
-
-        template <typename Scanner>
-        struct definition
-        {
-            definition(phrase_grammar const& self)
-            {
-                using detail::var;
-                quickbook::actions& actions = self.actions;
-
-                space =
-                    *(space_p | comment)
-                    ;
-
-                blank =
-                    *(blank_p | comment)
-                    ;
-
-                eol = blank >> eol_p
-                    ;
-
-                phrase_end =
-                    ']' |
-                    if_p(var(self.no_eols))
-                    [
-                        eol >> eol                      // Make sure that we don't go
-                    ]                                   // past a single block, except
-                    ;                                   // when preformatted.
-
-                hard_space =
-                    (eps_p - (alnum_p | '_')) >> space  // must not be preceded by
-                    ;                                   // alpha-numeric or underscore
-
-                comment =
-                    "[/" >> *(dummy_block | (anychar_p - ']')) >> ']'
-                    ;
-
-                dummy_block =
-                    '[' >> *(dummy_block | (anychar_p - ']')) >> ']'
-                    ;
-
-                common =
-                        macro
-                    |   phrase_markup
-                    |   code_block
-                    |   inline_code
-                    |   simple_format
-                    |   escape
-                    |   comment
-                    ;
-
-                macro =
-                    eps_p(actions.macro                 // must not be followed by
-                        >> (eps_p - (alpha_p | '_')))   // alpha or underscore
-                    >> actions.macro                    [actions.do_macro]
-                    ;
-
-                static const bool true_ = true;
-                static const bool false_ = false;
-
-                template_ =
-                    (
-                        ch_p('`')                       [assign_a(actions.template_escape,true_)]
-                        |
-                        eps_p                           [assign_a(actions.template_escape,false_)]
-                    )
-                    >>
-                    ( (
-                        (eps_p(punct_p)
-                            >> actions.templates.scope
-                        )                               [assign_a(actions.template_identifier)]
-                                                        [clear_a(actions.template_args)]
-                        >> !template_args
-                    ) | (
-                        (actions.templates.scope
-                            >> eps_p(hard_space)
-                        )                               [assign_a(actions.template_identifier)]
-                                                        [clear_a(actions.template_args)]
-                        >> space
-                        >> !template_args
-                    ) )
-                    >> eps_p(']')
-                    ;
-
-                template_args =
-                    if_p(qbk_since(105u)) [
-                        template_args_1_5
-                    ].else_p [
-                        template_args_1_4
-                    ]
-                    ;
-
-                template_args_1_4 = template_arg_1_4 >> *(".." >> template_arg_1_4);
-
-                template_arg_1_4 =
-                        (   eps_p(*blank_p >> eol_p)    [assign_a(actions.template_block, true_)]
-                        |   eps_p                       [assign_a(actions.template_block, false_)]
-                        )
-                    >>  template_inner_arg_1_4          [actions.template_arg]
-                    ;
-
-                template_inner_arg_1_4 =
-                    +(brackets_1_4 | (anychar_p - (str_p("..") | ']')))
-                    ;
-
-                brackets_1_4 =
-                    '[' >> template_inner_arg_1_4 >> ']'
-                    ;
-
-                template_args_1_5 = template_arg_1_5 >> *(".." >> template_arg_1_5);
-
-                template_arg_1_5 =
-                        (   eps_p(*blank_p >> eol_p)    [assign_a(actions.template_block, true_)]
-                        |   eps_p                       [assign_a(actions.template_block, false_)]
-                        )
-                    >>  (+(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p("..") | '[' | ']'))))
-                                                        [actions.template_arg]
-                    ;
-
-                template_inner_arg_1_5 =
-                    +(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p('[') | ']')))
-                    ;
-
-                brackets_1_5 =
-                    '[' >> template_inner_arg_1_5 >> ']'
-                    ;
-
-                inline_code =
-                    '`' >>
-                    (
-                       *(anychar_p -
-                            (   '`'
-                            |   (eol >> eol)            // Make sure that we don't go
-                            )                           // past a single block
-                        ) >> eps_p('`')
-                    )                                   [actions.inline_code]
-                    >>  '`'
-                    ;
-
-                code_block =
-                        (
-                            "```" >>
-                            (
-                               *(anychar_p - "```")
-                                    >> eps_p("```")
-                            )                           [actions.code_block]
-                            >>  "```"
-                        )
-                    |   (
-                            "``" >>
-                            (
-                               *(anychar_p - "``")
-                                    >> eps_p("``")
-                            )                           [actions.code_block]
-                            >>  "``"
-                        )
-                    ;
-
-                simple_format =
-                        simple_bold
-                    |   simple_italic
-                    |   simple_underline
-                    |   simple_teletype
-                    ;
-
-                simple_phrase_end = '[' | phrase_end;
-
-                simple_markup(simple_bold,
-                    '*', actions.simple_bold, simple_phrase_end);
-                simple_markup(simple_italic,
-                    '/', actions.simple_italic, simple_phrase_end);
-                simple_markup(simple_underline,
-                    '_', actions.simple_underline, simple_phrase_end);
-                simple_markup(simple_teletype,
-                    '=', actions.simple_teletype, simple_phrase_end);
-
-                phrase =
-                   *(   common
-                    |   comment
-                    |   (anychar_p - phrase_end)        [actions.plain_char]
-                    )
-                    ;
-
-                phrase_markup =
-                        '['
-                    >>  (   cond_phrase
-                        |   image
-                        |   url
-                        |   link
-                        |   anchor
-                        |   source_mode
-                        |   funcref
-                        |   classref
-                        |   memberref
-                        |   enumref
-                        |   macroref
-                        |   headerref
-                        |   conceptref
-                        |   globalref
-                        |   bold
-                        |   italic
-                        |   underline
-                        |   teletype
-                        |   strikethrough
-                        |   quote
-                        |   replaceable
-                        |   footnote
-                        |   template_                   [actions.do_template]
-                        |   str_p("br")                 [actions.break_]
-                        )
-                    >>  ']'
-                    ;
-
-                escape =
-                        str_p("\\ ")                    // ignore an escaped space
-                    |   '\\' >> punct_p                 [actions.raw_char]
-                    |   "\\u" >> repeat_p(4) [chset<>("0-9a-fA-F")]
-                                                        [actions.escape_unicode]
-                    |   "\\U" >> repeat_p(8) [chset<>("0-9a-fA-F")]
-                                                        [actions.escape_unicode]
-                    |   (
-                            ("'''" >> !eol)             [actions.escape_pre]
-                        >>  *(anychar_p - "'''")        [actions.raw_char]
-                        >>  str_p("'''")                [actions.escape_post]
-                        )
-                    ;
-
-                macro_identifier =
-                    +(anychar_p - (space_p | ']'))
-                    ;
-
-                cond_phrase =
-                        '?' >> blank
-                    >>  macro_identifier                [actions.cond_phrase_pre]
-                    >>  (!phrase)                       [actions.cond_phrase_post]
-                    ;
-
-                image =
-                        '$' >> blank                    [clear_a(actions.attributes)]
-                    >>  if_p(qbk_since(105u)) [
-                                (+(
-                                    *space_p
-                                >>  +(anychar_p - (space_p | phrase_end | '['))
-                                ))                       [assign_a(actions.image_fileref)]
-                            >>  hard_space
-                            >>  *(
-                                    '['
-                                >>  (*(alnum_p | '_'))  [assign_a(actions.attribute_name)]
-                                >>  space
-                                >>  (*(anychar_p - (phrase_end | '[')))
-                                                        [actions.attribute]
-                                >>  ']'
-                                >>  space
-                                )
-                        ].else_p [
-                                (*(anychar_p -
-                                    phrase_end))        [assign_a(actions.image_fileref)]
-                        ]
-                    >>  eps_p(']')                      [actions.image]
-                    ;
-                    
-                url =
-                        '@'
-                    >>  (*(anychar_p -
-                            (']' | hard_space)))        [actions.url_pre]
-                    >>  (   eps_p(']')
-                        |   (hard_space >> phrase)
-                        )                               [actions.url_post]
-                    ;
-
-                link =
-                        "link" >> hard_space
-                    >>  (*(anychar_p -
-                            (']' | hard_space)))        [actions.link_pre]
-                    >>  (   eps_p(']')
-                        |   (hard_space >> phrase)
-                        )                               [actions.link_post]
-                    ;
-
-                anchor =
-                        '#'
-                    >>  blank
-                    >>  (   *(anychar_p -
-                                phrase_end)
-                        )                               [actions.anchor]
-                    ;
-
-                funcref =
-                    "funcref" >> hard_space
-                    >>  (*(anychar_p -
-                            (']' | hard_space)))        [actions.funcref_pre]
-                    >>  (   eps_p(']')
-                        |   (hard_space >> phrase)
-                        )                               [actions.funcref_post]
-                    ;
-
-                classref =
-                    "classref" >> hard_space
-                    >>  (*(anychar_p -
-                            (']' | hard_space)))        [actions.classref_pre]
-                    >>  (   eps_p(']')
-                        |   (hard_space >> phrase)
-                        )                               [actions.classref_post]
-                    ;
-
-                memberref =
-                    "memberref" >> hard_space
-                    >>  (*(anychar_p -
-                            (']' | hard_space)))        [actions.memberref_pre]
-                    >>  (   eps_p(']')
-                        |   (hard_space >> phrase)
-                        )                               [actions.memberref_post]
-                    ;
-
-                enumref =
-                    "enumref" >> hard_space
-                    >>  (*(anychar_p -
-                            (']' | hard_space)))        [actions.enumref_pre]
-                    >>  (   eps_p(']')
-                        |   (hard_space >> phrase)
-                        )                               [actions.enumref_post]
-                    ;
-
-                macroref =
-                    "macroref" >> hard_space
-                    >>  (*(anychar_p -
-                            (']' | hard_space)))        [actions.macroref_pre]
-                    >>  (   eps_p(']')
-                        |   (hard_space >> phrase)
-                        )                               [actions.macroref_post]
-                    ;
-
-                headerref =
-                    "headerref" >> hard_space
-                    >>  (*(anychar_p -
-                            (']' | hard_space)))        [actions.headerref_pre]
-                    >>  (   eps_p(']')
-                        |   (hard_space >> phrase)
-                        )                               [actions.headerref_post]
-                    ;
-
-                conceptref =
-                    "conceptref" >> hard_space
-                    >>  (*(anychar_p -
-                            (']' | hard_space)))        [actions.conceptref_pre]
-                    >>  (   eps_p(']')
-                        |   (hard_space >> phrase)
-                        )                               [actions.conceptref_post]
-                    ;
-
-                globalref =
-                    "globalref" >> hard_space
-                    >>  (*(anychar_p -
-                            (']' | hard_space)))        [actions.globalref_pre]
-                    >>  (   eps_p(']')
-                        |   (hard_space >> phrase)
-                        )                               [actions.globalref_post]
-                    ;
-
-                bold =
-                        ch_p('*')                       [actions.bold_pre]
-                    >>  blank >> phrase                 [actions.bold_post]
-                    ;
-
-                italic =
-                        ch_p('\'')                      [actions.italic_pre]
-                    >>  blank >> phrase                 [actions.italic_post]
-                    ;
-
-                underline =
-                        ch_p('_')                       [actions.underline_pre]
-                    >>  blank >> phrase                 [actions.underline_post]
-                    ;
-
-                teletype =
-                        ch_p('^')                       [actions.teletype_pre]
-                    >>  blank >> phrase                 [actions.teletype_post]
-                    ;
-
-                strikethrough =
-                        ch_p('-')                       [actions.strikethrough_pre]
-                    >>  blank >> phrase                 [actions.strikethrough_post]
-                    ;
-
-                quote =
-                        ch_p('"')                       [actions.quote_pre]
-                    >>  blank >> phrase                 [actions.quote_post]
-                    ;
-
-                replaceable =
-                        ch_p('~')                       [actions.replaceable_pre]
-                    >>  blank >> phrase                 [actions.replaceable_post]
-                    ;
-
-                source_mode =
-                    (
-                        str_p("c++")
-                    |   "python"
-                    |   "teletype"
-                    )                                   [assign_a(actions.source_mode)]
-                    ;
-
-                footnote =
-                        str_p("footnote")               [actions.footnote_pre]
-                    >>  blank >> phrase                 [actions.footnote_post]
-                    ;
-            }
-
-            rule<Scanner>   space, blank, comment, phrase, phrase_markup, image,
-                            simple_phrase_end, phrase_end, bold, italic, underline, teletype,
-                            strikethrough, escape, url, common, funcref, classref,
-                            memberref, enumref, macroref, headerref, conceptref, globalref,
-                            anchor, link, hard_space, eol, inline_code, simple_format,
-                            simple_bold, simple_italic, simple_underline,
-                            simple_teletype, source_mode, template_,
-                            quote, code_block, footnote, replaceable, macro,
-                            dummy_block, cond_phrase, macro_identifier, template_args,
-                            template_args_1_4, template_arg_1_4,
-                            template_inner_arg_1_4, brackets_1_4,
-                            template_args_1_5, template_arg_1_5,
-                            template_inner_arg_1_5, brackets_1_5
-                            ;
-
-            rule<Scanner> const&
-            start() const { return common; }
-        };
-
-        bool& no_eols;
-        quickbook::actions& actions;
-    };
-
-    struct simple_phrase_grammar
-    : public grammar<simple_phrase_grammar >
-    {
-        simple_phrase_grammar(quickbook::actions& actions)
-            : actions(actions) {}
-
-        template <typename Scanner>
-        struct definition
-        {
-            definition(simple_phrase_grammar const& self)
-                : unused(false), common(self.actions, unused)
-            {
-                quickbook::actions& actions = self.actions;
-
-                phrase =
-                   *(   common
-                    |   comment
-                    |   (anychar_p - ']')           [actions.plain_char]
-                    )
-                    ;
-
-                comment =
-                    "[/" >> *(dummy_block | (anychar_p - ']')) >> ']'
-                    ;
-
-                dummy_block =
-                    '[' >> *(dummy_block | (anychar_p - ']')) >> ']'
-                    ;
-            }
-
-            bool unused;
-            rule<Scanner> phrase, comment, dummy_block;
-            phrase_grammar common;
-
-            rule<Scanner> const&
-            start() const { return phrase; }
-        };
-
-        quickbook::actions& actions;
-    };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
-
Copied: trunk/tools/quickbook/src/phrase_grammar.cpp (from r65030, /trunk/tools/quickbook/src/phrase.hpp)
==============================================================================
--- /trunk/tools/quickbook/src/phrase.hpp	(original)
+++ trunk/tools/quickbook/src/phrase_grammar.cpp	2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
@@ -7,12 +7,11 @@
     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_PHRASE_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
 
+#include "./phrase_grammar.hpp"
 #include "./quickbook.hpp"
 #include "./actions_class.hpp"
-#include "utils.hpp"
+#include "./utils.hpp"
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_confix.hpp>
 #include <boost/spirit/include/classic_chset.hpp>
@@ -59,15 +58,8 @@
             ;
     }
 
-    struct phrase_grammar : grammar<phrase_grammar>
-    {
-        phrase_grammar(quickbook::actions& actions, bool& no_eols)
-            : no_eols(no_eols), actions(actions) {}
-
-        template <typename Scanner>
-        struct definition
-        {
-            definition(phrase_grammar const& self)
+            template <typename Scanner>
+            phrase_grammar::definition<Scanner>::definition(phrase_grammar const& self)
             {
                 using detail::var;
                 quickbook::actions& actions = self.actions;
@@ -470,37 +462,8 @@
                     ;
             }
 
-            rule<Scanner>   space, blank, comment, phrase, phrase_markup, image,
-                            simple_phrase_end, phrase_end, bold, italic, underline, teletype,
-                            strikethrough, escape, url, common, funcref, classref,
-                            memberref, enumref, macroref, headerref, conceptref, globalref,
-                            anchor, link, hard_space, eol, inline_code, simple_format,
-                            simple_bold, simple_italic, simple_underline,
-                            simple_teletype, source_mode, template_,
-                            quote, code_block, footnote, replaceable, macro,
-                            dummy_block, cond_phrase, macro_identifier, template_args,
-                            template_args_1_4, template_arg_1_4,
-                            template_inner_arg_1_4, brackets_1_4,
-                            template_args_1_5, template_arg_1_5,
-                            template_inner_arg_1_5, brackets_1_5
-                            ;
-
-            rule<Scanner> const&
-            start() const { return common; }
-        };
-
-        bool& no_eols;
-        quickbook::actions& actions;
-    };
-
-    struct simple_phrase_grammar
-    : public grammar<simple_phrase_grammar >
-    {
-        simple_phrase_grammar(quickbook::actions& actions)
-            : actions(actions) {}
-
         template <typename Scanner>
-        struct definition
+        struct simple_phrase_grammar::definition
         {
             definition(simple_phrase_grammar const& self)
                 : unused(false), common(self.actions, unused)
@@ -531,9 +494,60 @@
             start() const { return phrase; }
         };
 
-        quickbook::actions& actions;
-    };
-}
+        template <typename Scanner>
+        struct command_line_grammar::definition
+        {
+            definition(command_line_grammar const& self)
+                : unused(false), common(self.actions, unused)
+            {
+                quickbook::actions& actions = self.actions;
 
-#endif // BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
+                macro =
+                        *space_p
+                    >>  macro_identifier            [actions.macro_identifier]
+                    >>  *space_p
+                    >>  (   '='
+                        >>  *space_p
+                        >>  phrase                  [actions.macro_definition]
+                        >>  *space_p
+                        )
+                    |   eps_p                       [actions.macro_definition]
+                    ;
+
+                macro_identifier =
+                    +(anychar_p - (space_p | ']' | '='))
+                    ;
 
+                phrase =
+                   *(   common
+                    |   (anychar_p - ']')           [actions.plain_char]
+                    )
+                    ;
+            }
+
+            bool unused;
+            rule<Scanner> macro, macro_identifier, phrase;
+            phrase_grammar common;
+
+            rule<Scanner> const&
+            start() const { return macro; }
+        };
+
+    template <typename Iterator, typename Grammar>
+    parse_info<Iterator> parse(Iterator& first, Iterator last, Grammar& g)
+    {
+        return boost::spirit::classic::parse(first, last, g);
+    }
+
+    void instantiate_phrase_grammar(quickbook::iterator i, phrase_grammar& g) {
+        parse(i, i, g);
+    }
+
+    void instantiate_simple_phrase_grammar(quickbook::iterator i, simple_phrase_grammar& g) {
+        parse(i, i, g);
+    }
+
+    void instantiate_command_line_grammar(quickbook::iterator i, command_line_grammar& g) {
+        parse(i, i, g);
+    }
+}
Added: trunk/tools/quickbook/src/phrase_grammar.hpp
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/src/phrase_grammar.hpp	2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
@@ -0,0 +1,45 @@
+/*=============================================================================
+    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_PHRASE_HPP)
+#define BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
+
+#include "./grammar.hpp"
+
+namespace quickbook
+{
+    using namespace boost::spirit::classic;
+
+        template <typename Scanner>
+        struct phrase_grammar::definition
+        {
+            definition(phrase_grammar const& self);
+
+            rule<Scanner>   space, blank, comment, phrase, phrase_markup, image,
+                            simple_phrase_end, phrase_end, bold, italic, underline, teletype,
+                            strikethrough, escape, url, common, funcref, classref,
+                            memberref, enumref, macroref, headerref, conceptref, globalref,
+                            anchor, link, hard_space, eol, inline_code, simple_format,
+                            simple_bold, simple_italic, simple_underline,
+                            simple_teletype, source_mode, template_,
+                            quote, code_block, footnote, replaceable, macro,
+                            dummy_block, cond_phrase, macro_identifier, template_args,
+                            template_args_1_4, template_arg_1_4,
+                            template_inner_arg_1_4, brackets_1_4,
+                            template_args_1_5, template_arg_1_5,
+                            template_inner_arg_1_5, brackets_1_5
+                            ;
+
+            rule<Scanner> const&
+            start() const { return common; }
+        };
+}
+
+#endif // BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
+
Modified: trunk/tools/quickbook/src/quickbook.cpp
==============================================================================
--- trunk/tools/quickbook/src/quickbook.cpp	(original)
+++ trunk/tools/quickbook/src/quickbook.cpp	2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
@@ -7,10 +7,9 @@
     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
     http://www.boost.org/LICENSE_1_0.txt)
 =============================================================================*/
+#include "./grammar.hpp"
 #include "./quickbook.hpp"
 #include "./actions_class.hpp"
-#include "./block.hpp"
-#include "./doc_info.hpp"
 #include "./post_process.hpp"
 #include "./utils.hpp"
 #include "./input_path.hpp"
@@ -45,59 +44,6 @@
     std::vector<std::string> include_path;
     std::vector<std::string> preset_defines;
 
-    ///////////////////////////////////////////////////////////////////////////
-    //
-    //  Parse the macros passed as command line parameters
-    //
-    ///////////////////////////////////////////////////////////////////////////
-    struct command_line_grammar
-        : public grammar<command_line_grammar>
-    {
-        command_line_grammar(quickbook::actions& actions)
-            : actions(actions) {}
-
-        template <typename Scanner>
-        struct definition
-        {
-            definition(command_line_grammar const& self)
-                : unused(false), common(self.actions, unused)
-            {
-                quickbook::actions& actions = self.actions;
-
-                macro =
-                        *space_p
-                    >>  macro_identifier            [actions.macro_identifier]
-                    >>  *space_p
-                    >>  (   '='
-                        >>  *space_p
-                        >>  phrase                  [actions.macro_definition]
-                        >>  *space_p
-                        )
-                    |   eps_p                       [actions.macro_definition]
-                    ;
-
-                macro_identifier =
-                    +(anychar_p - (space_p | ']' | '='))
-                    ;
-
-                phrase =
-                   *(   common
-                    |   (anychar_p - ']')           [actions.plain_char]
-                    )
-                    ;
-            }
-
-            bool unused;
-            rule<Scanner> macro, macro_identifier, phrase;
-            phrase_grammar common;
-
-            rule<Scanner> const&
-            start() const { return macro; }
-        };
-
-        quickbook::actions& actions;
-    };
-
     static void set_macros(actions& actor)
     {
         quickbook::command_line_grammar grammar(actor);
Modified: trunk/tools/quickbook/src/syntax_highlight.cpp
==============================================================================
--- trunk/tools/quickbook/src/syntax_highlight.cpp	(original)
+++ trunk/tools/quickbook/src/syntax_highlight.cpp	2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
@@ -49,17 +49,17 @@
         if (source_mode == "c++")
         {
             cpp_p_type cpp_p(temp, macro, do_macro_action(temp), escape_actions);
-            parse(first, last, cpp_p);
+            boost::spirit::classic::parse(first, last, cpp_p);
         }
         else if (source_mode == "python")
         {
             python_p_type python_p(temp, macro, do_macro_action(temp), escape_actions);
-            parse(first, last, python_p);
+            boost::spirit::classic::parse(first, last, python_p);
         }
         else if (source_mode == "teletype")
         {
             teletype_p_type teletype_p(temp, macro, do_macro_action(temp), escape_actions);
-            parse(first, last, teletype_p);
+            boost::spirit::classic::parse(first, last, teletype_p);
         }
         else
         {
Modified: trunk/tools/quickbook/src/syntax_highlight.hpp
==============================================================================
--- trunk/tools/quickbook/src/syntax_highlight.hpp	(original)
+++ trunk/tools/quickbook/src/syntax_highlight.hpp	2010-08-26 16:57:45 EDT (Thu, 26 Aug 2010)
@@ -15,7 +15,7 @@
 #include <boost/spirit/include/classic_chset.hpp>
 #include <boost/spirit/include/classic_symbols.hpp>
 #include <boost/spirit/include/classic_loops.hpp>
-#include "./phrase.hpp"
+#include "./phrase_grammar.hpp"
 
 namespace quickbook
 {