$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r57769 - in branches/quickbook-1.5-spirit2: . detail
From: daniel_james_at_[hidden]
Date: 2009-11-18 18:09:33
Author: danieljames
Date: 2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
New Revision: 57769
URL: http://svn.boost.org/trac/boost/changeset/57769
Log:
Compile most of the grammars seperatly.
Added:
   branches/quickbook-1.5-spirit2/detail/block.cpp   (contents, props changed)
   branches/quickbook-1.5-spirit2/detail/code_snippet.cpp   (contents, props changed)
   branches/quickbook-1.5-spirit2/detail/doc_info.cpp   (contents, props changed)
   branches/quickbook-1.5-spirit2/detail/phrase.cpp   (contents, props changed)
   branches/quickbook-1.5-spirit2/grammars.hpp   (contents, props changed)
Text files modified: 
   branches/quickbook-1.5-spirit2/Jamfile.v2           |     4                                         
   branches/quickbook-1.5-spirit2/block.hpp            |   823 ++++++++++++++++++--------------------  
   branches/quickbook-1.5-spirit2/code_snippet.hpp     |   315 +++++---------                          
   branches/quickbook-1.5-spirit2/detail/actions.cpp   |     3                                         
   branches/quickbook-1.5-spirit2/detail/actions.hpp   |    26 +                                       
   branches/quickbook-1.5-spirit2/detail/quickbook.cpp |     3                                         
   branches/quickbook-1.5-spirit2/doc_info.hpp         |   310 ++++++-------                           
   branches/quickbook-1.5-spirit2/phrase.hpp           |   853 ++++++++++++++++++--------------------- 
   branches/quickbook-1.5-spirit2/syntax_highlight.hpp |     2                                         
   9 files changed, 1098 insertions(+), 1241 deletions(-)
Modified: branches/quickbook-1.5-spirit2/Jamfile.v2
==============================================================================
--- branches/quickbook-1.5-spirit2/Jamfile.v2	(original)
+++ branches/quickbook-1.5-spirit2/Jamfile.v2	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -27,6 +27,10 @@
     detail/collector.cpp
     detail/template_stack.cpp
     detail/markups.cpp
+    detail/phrase.cpp
+    detail/block.cpp
+    detail/doc_info.cpp
+    detail/code_snippet.cpp
     /boost//program_options
     /boost//filesystem
     : #<define>QUICKBOOK_NO_DATES
Modified: branches/quickbook-1.5-spirit2/block.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block.hpp	(original)
+++ branches/quickbook-1.5-spirit2/block.hpp	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -12,7 +12,7 @@
 
 #include "./detail/quickbook.hpp"
 #include "./detail/utils.hpp"
-#include "./phrase.hpp"
+#include "./grammars.hpp"
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_confix.hpp>
 #include <boost/spirit/include/classic_chset.hpp>
@@ -24,435 +24,404 @@
 {
     using namespace boost::spirit::classic;
 
-    template <typename Actions, bool skip_initial_spaces = false>
-    struct block_grammar : grammar<block_grammar<Actions> >
+    template <typename Actions, bool skip_initial_spaces>
+    template <typename Scanner>
+    block_grammar<Actions, skip_initial_spaces>::
+        definition<Scanner>::definition(block_grammar const& self)
+        : no_eols(true)
+        , common(self.actions, no_eols)
     {
-        block_grammar(Actions& actions_)
-            : actions(actions_) {}
+        using detail::var;
+        Actions& actions = self.actions;
 
-        template <typename Scanner>
-        struct definition
+        if (skip_initial_spaces)
         {
-            definition(block_grammar const& self)
-                : no_eols(true)
-                , common(self.actions, no_eols)
-            {
-                using detail::var;
-                Actions& actions = self.actions;
-
-                if (skip_initial_spaces)
-                {
-                    start_ =
-                        *(space_p | comment) >> blocks >> blank
-                        ;
-                }
-                else
-                {
-                    start_ =
-                        blocks >> blank
-                        ;
-                }
-
-                blocks =
-                   +(   block_markup
-                    |   code
-                    |   list                            [actions.list]
-                    |   hr                              [actions.hr]
-                    |   comment >> *eol
-                    |   paragraph                       [actions.paragraph]
-                    |   eol
-                    )
-                    ;
-
-                space =
-                    *(space_p | comment)
-                    ;
-
-                blank =
-                    *(blank_p | comment)
-                    ;
-
-                eol = blank >> eol_p
-                    ;
-
-                phrase_end =
-                    ']' |
-                    if_p(var(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 - ']')) >> ']'
-                    ;
-
-                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)]
-                        ]
-                        ;
-
-                begin_section =
-                       "section"
-                    >> hard_space
-                    >> element_id
-                    >> phrase                           [actions.begin_section]
-                    ;
-
-                end_section =
-                    str_p("endsect")                    [actions.end_section]
-                    ;
-
-                headings =
-                    h1 | h2 | h3 | h4 | h5 | h6 | h
-                    ;
-
-                h = "heading" >> hard_space >> phrase   [actions.h];
-                h1 = "h1" >> hard_space >> phrase       [actions.h1];
-                h2 = "h2" >> hard_space >> phrase       [actions.h2];
-                h3 = "h3" >> hard_space >> phrase       [actions.h3];
-                h4 = "h4" >> hard_space >> phrase       [actions.h4];
-                h5 = "h5" >> hard_space >> phrase       [actions.h5];
-                h6 = "h6" >> hard_space >> phrase       [actions.h6];
-
-                static const bool true_ = true;
-                static const bool false_ = false;
-
-                inside_paragraph =
-                    phrase                              [actions.inside_paragraph]
-                    >> *(
-                        eol >> 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        [push_back_a(actions.template_info)]
-                    >>
-                    !(
-                        space >> '['
-                        >> *(
-                                space >> template_id    [push_back_a(actions.template_info)]
-                            )
-                        >> space >> ']'
-                    )
-                    >> template_body                    [actions.template_body]
-                    ;
-
-                template_body =
-                   *(('[' >> template_body >> ']') | (anychar_p - ']'))
-                    >> space >> eps_p(']')
-                    ;
-
-                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
-                            >> +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('[')                       [actions.start_varlistitem]
-                    >>
-                    (
-                        (
-                            inside_paragraph
-                            >>  ch_p(']')               [actions.end_varlistitem]
-                            >>  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
-                        >> *(*eol >> code_line)
-                    )                                   [actions.code]
-                    >> +eol
-                    ;
-
-                code_line =
-                    ((ch_p(' ') | '\t'))
-                    >> *(anychar_p - eol) >> eol
-                    ;
-
-                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 >> eol
-                    ;
-
-                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,
-                            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;
-
-            symbols<>       paragraph_end_markups;
-
-            phrase_grammar<Actions> common;
-
-            rule<Scanner> const&
-            start() const { return start_; }
-        };
-
-        Actions&   actions;
-    };
+            start_ =
+                *(space_p | comment) >> blocks >> blank
+                ;
+        }
+        else
+        {
+            start_ =
+                blocks >> blank
+                ;
+        }
+        
+        blocks =
+           +(   block_markup
+            |   code
+            |   list                            [actions.list]
+            |   hr                              [actions.hr]
+            |   comment >> *eol
+            |   paragraph                       [actions.paragraph]
+            |   eol
+            )
+            ;
+
+        space =
+            *(space_p | comment)
+            ;
+
+        blank =
+            *(blank_p | comment)
+            ;
+
+        eol = blank >> eol_p
+            ;
+
+        phrase_end =
+            ']' |
+            if_p(var(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 - ']')) >> ']'
+            ;
+
+        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)]
+                ]
+                ;
+
+        begin_section =
+               "section"
+            >> hard_space
+            >> element_id
+            >> phrase                           [actions.begin_section]
+            ;
+
+        end_section =
+            str_p("endsect")                    [actions.end_section]
+            ;
+
+        headings =
+            h1 | h2 | h3 | h4 | h5 | h6 | h
+            ;
+
+        h = "heading" >> hard_space >> phrase   [actions.h];
+        h1 = "h1" >> hard_space >> phrase       [actions.h1];
+        h2 = "h2" >> hard_space >> phrase       [actions.h2];
+        h3 = "h3" >> hard_space >> phrase       [actions.h3];
+        h4 = "h4" >> hard_space >> phrase       [actions.h4];
+        h5 = "h5" >> hard_space >> phrase       [actions.h5];
+        h6 = "h6" >> hard_space >> phrase       [actions.h6];
+
+        static const bool true_ = true;
+        static const bool false_ = false;
+
+        inside_paragraph =
+            phrase                              [actions.inside_paragraph]
+            >> *(
+                eol >> 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        [push_back_a(actions.template_info)]
+            >>
+            !(
+                space >> '['
+                >> *(
+                        space >> template_id    [push_back_a(actions.template_info)]
+                    )
+                >> space >> ']'
+            )
+            >> template_body                    [actions.template_body]
+            ;
+
+        template_body =
+           *(('[' >> template_body >> ']') | (anychar_p - ']'))
+            >> space >> eps_p(']')
+            ;
+
+        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
+                    >> +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('[')                       [actions.start_varlistitem]
+            >>
+            (
+                (
+                    inside_paragraph
+                    >>  ch_p(']')               [actions.end_varlistitem]
+                    >>  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
+                >> *(*eol >> code_line)
+            )                                   [actions.code]
+            >> +eol
+            ;
+
+        code_line =
+            ((ch_p(' ') | '\t'))
+            >> *(anychar_p - eol) >> eol
+            ;
+
+        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 >> eol
+            ;
+
+        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]
+            )
+            ;
+    }
 }
 
 #endif // BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP
Modified: branches/quickbook-1.5-spirit2/code_snippet.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code_snippet.hpp	(original)
+++ branches/quickbook-1.5-spirit2/code_snippet.hpp	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -12,205 +12,136 @@
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_actor.hpp>
 #include <boost/bind.hpp>
+#include "./grammars.hpp"
 #include "./detail/template_stack.hpp"
 #include "./detail/actions.hpp"
 
 namespace quickbook
 {
-    struct code_snippet_actions
+    template <typename Scanner>
+    python_code_snippet_grammar::definition<Scanner>::definition(
+        python_code_snippet_grammar const& self)
     {
-        code_snippet_actions(std::vector<template_symbol>& storage,
-                                 std::string const& doc_id,
-                                 char const* source_type)
-            : storage(storage)
-            , doc_id(doc_id)
-            , source_type(source_type)
-        {}
-
-        void pass_thru(iterator first, iterator last);
-        void escaped_comment(iterator first, iterator last);
-        void compile(iterator first, iterator last);
-        void callout(iterator first, iterator last, char const* role);
-        void inline_callout(iterator first, iterator last);
-        void line_callout(iterator first, iterator last);
-
-        std::string code;
-        std::string snippet;
-        std::string id;
-        std::vector<std::string> callouts;
-        std::vector<template_symbol>& storage;
-        std::string const doc_id;
-        char const* const source_type;
-    };
-
-    struct python_code_snippet_grammar
-        : grammar<python_code_snippet_grammar>
+        actions_type& actions = self.actions;
+    
+        start_ =
+            +(
+                    snippet                 [boost::bind(&actions_type::compile, &actions, _1, _2)]
+                |   anychar_p
+            )
+            ;
+
+        identifier =
+            (alpha_p | '_') >> *(alnum_p | '_')
+            ;
+
+        snippet =
+            "#[" >> *space_p
+            >> identifier                   [assign_a(actions.id)]
+            >> (*(code_elements - "#]"))
+            >> "#]"
+            ;
+
+        code_elements =
+                escaped_comment
+            |   ignore
+            |   (anychar_p - "#]")         [boost::bind(&actions_type::pass_thru, &actions, _1, _2)]
+            ;
+
+        ignore =
+                *blank_p >> "#<-"
+                >> (*(anychar_p - "#->"))
+                >> "#->" >> *blank_p >> eol_p
+            |   "\"\"\"<-\"\"\""
+                >> (*(anychar_p - "\"\"\"->\"\"\""))
+                >> "\"\"\"->\"\"\""
+            |   "\"\"\"<-"
+                >> (*(anychar_p - "->\"\"\""))
+                >> "->\"\"\""
+            ;
+
+        escaped_comment =
+                *space_p >> "#`"
+                >> ((*(anychar_p - eol_p))
+                    >> eol_p)               [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
+            |   *space_p >> "\"\"\"`"
+                >> (*(anychar_p - "\"\"\""))    [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
+                >> "\"\"\""
+            ;
+    }
+
+    template <typename Scanner>
+    cpp_code_snippet_grammar::definition<Scanner>::definition(
+        cpp_code_snippet_grammar const& self)
     {
-        typedef code_snippet_actions actions_type;
-  
-        python_code_snippet_grammar(actions_type & actions)
-            : actions(actions)
-        {}
-
-        template <typename Scanner>
-        struct definition
-        {
-            typedef code_snippet_actions actions_type;
-            
-            definition(python_code_snippet_grammar const& self)
-            {
-                actions_type& actions = self.actions;
-            
-                start_ =
-                    +(
-                            snippet                 [boost::bind(&actions_type::compile, &actions, _1, _2)]
-                        |   anychar_p
-                    )
-                    ;
-
-                identifier =
-                    (alpha_p | '_') >> *(alnum_p | '_')
-                    ;
-
-                snippet =
-                    "#[" >> *space_p
-                    >> identifier                   [assign_a(actions.id)]
-                    >> (*(code_elements - "#]"))
-                    >> "#]"
-                    ;
-
-                code_elements =
-                        escaped_comment
-                    |   ignore
-                    |   (anychar_p - "#]")         [boost::bind(&actions_type::pass_thru, &actions, _1, _2)]
-                    ;
-
-                ignore =
-                        *blank_p >> "#<-"
-                        >> (*(anychar_p - "#->"))
-                        >> "#->" >> *blank_p >> eol_p
-                    |   "\"\"\"<-\"\"\""
-                        >> (*(anychar_p - "\"\"\"->\"\"\""))
-                        >> "\"\"\"->\"\"\""
-                    |   "\"\"\"<-"
-                        >> (*(anychar_p - "->\"\"\""))
-                        >> "->\"\"\""
-                    ;
-
-                escaped_comment =
-                        *space_p >> "#`"
-                        >> ((*(anychar_p - eol_p))
-                            >> eol_p)               [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
-                    |   *space_p >> "\"\"\"`"
-                        >> (*(anychar_p - "\"\"\""))    [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
-                        >> "\"\"\""
-                    ;
-            }
-
-            rule<Scanner>
-                start_, snippet, identifier, code_elements, escaped_comment,
-                inline_callout, line_callout, ignore;
-
-            rule<Scanner> const&
-            start() const { return start_; }
-        };
-
-        actions_type& actions;
-    };  
-
-    struct cpp_code_snippet_grammar
-        : grammar<cpp_code_snippet_grammar>
-    {
-        typedef code_snippet_actions actions_type;
-  
-        cpp_code_snippet_grammar(actions_type & actions)
-            : actions(actions)
-        {}
-
-        template <typename Scanner>
-        struct definition
-        {
-            definition(cpp_code_snippet_grammar const& self)
-            {
-                actions_type& actions = self.actions;
-            
-                start_ =
-                    +(
-                            snippet                 [boost::bind(&actions_type::compile, &actions, _1, _2)]
-                        |   anychar_p
-                    )
-                    ;
-
-                identifier =
-                    (alpha_p | '_') >> *(alnum_p | '_')
-                    ;
-
-                snippet =
-                        "//[" >> *space_p
-                        >> identifier                   [assign_a(actions.id)]
-                        >> (*(code_elements - "//]"))
-                        >> "//]"
-                    |
-                        "/*[" >> *space_p
-                        >> identifier                   [assign_a(actions.id)]
-                        >> *space_p >> "*/"
-                        >> (*(code_elements - "/*]*"))
-                        >> "/*]*/"
-                    ;
-
-                code_elements =
-                        escaped_comment
-                    |   ignore
-                    |   line_callout
-                    |   inline_callout
-                    |   (anychar_p - "//]" - "/*]*/")    [boost::bind(&actions_type::pass_thru, &actions, _1, _2)]
-                    ;
-
-                inline_callout =
-                    "/*<"
-                    >> (*(anychar_p - ">*/"))       [boost::bind(&actions_type::inline_callout, &actions, _1, _2)]
-                    >> ">*/"
-                    ;
-
-                line_callout =
-                    "/*<<"
-                    >> (*(anychar_p - ">>*/"))      [boost::bind(&actions_type::line_callout, &actions, _1, _2)]
-                    >> ">>*/"
-                    >> *space_p
-                    ;
-
-                ignore =
-                        *blank_p >> "//<-"
-                        >> (*(anychar_p - "//->"))
-                        >> "//->" >> *blank_p >> eol_p
-                    |   "/*<-*/"
-                        >> (*(anychar_p - "/*->*/"))
-                        >> "/*->*/"
-                    |   "/*<-"
-                        >> (*(anychar_p - "->*/"))
-                        >> "->*/"
-                    ;
-
-                escaped_comment =
-                        *space_p >> "//`"
-                        >> ((*(anychar_p - eol_p))
-                            >> eol_p)               [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
-                    |   *space_p >> "/*`"
-                        >> (*(anychar_p - "*/"))    [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
-                        >> "*/"
-                    ;
-            }
-
-            rule<Scanner>
-                start_, snippet, identifier, code_elements, escaped_comment,
-                inline_callout, line_callout, ignore;
-
-            rule<Scanner> const&
-            start() const { return start_; }
-        };
-
-        actions_type& actions;
-    };
+        actions_type& actions = self.actions;
+    
+        start_ =
+            +(
+                    snippet                 [boost::bind(&actions_type::compile, &actions, _1, _2)]
+                |   anychar_p
+            )
+            ;
+
+        identifier =
+            (alpha_p | '_') >> *(alnum_p | '_')
+            ;
+
+        snippet =
+                "//[" >> *space_p
+                >> identifier                   [assign_a(actions.id)]
+                >> (*(code_elements - "//]"))
+                >> "//]"
+            |
+                "/*[" >> *space_p
+                >> identifier                   [assign_a(actions.id)]
+                >> *space_p >> "*/"
+                >> (*(code_elements - "/*]*"))
+                >> "/*]*/"
+            ;
+
+        code_elements =
+                escaped_comment
+            |   ignore
+            |   line_callout
+            |   inline_callout
+            |   (anychar_p - "//]" - "/*]*/")    [boost::bind(&actions_type::pass_thru, &actions, _1, _2)]
+            ;
+
+        inline_callout =
+            "/*<"
+            >> (*(anychar_p - ">*/"))       [boost::bind(&actions_type::inline_callout, &actions, _1, _2)]
+            >> ">*/"
+            ;
+
+        line_callout =
+            "/*<<"
+            >> (*(anychar_p - ">>*/"))      [boost::bind(&actions_type::line_callout, &actions, _1, _2)]
+            >> ">>*/"
+            >> *space_p
+            ;
+
+        ignore =
+                *blank_p >> "//<-"
+                >> (*(anychar_p - "//->"))
+                >> "//->" >> *blank_p >> eol_p
+            |   "/*<-*/"
+                >> (*(anychar_p - "/*->*/"))
+                >> "/*->*/"
+            |   "/*<-"
+                >> (*(anychar_p - "->*/"))
+                >> "->*/"
+            ;
+
+        escaped_comment =
+                *space_p >> "//`"
+                >> ((*(anychar_p - eol_p))
+                    >> eol_p)               [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
+            |   *space_p >> "/*`"
+                >> (*(anychar_p - "*/"))    [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
+                >> "*/"
+            ;
+    }
 }
 
 #endif // BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_HPP
Modified: branches/quickbook-1.5-spirit2/detail/actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/detail/actions.cpp	(original)
+++ branches/quickbook-1.5-spirit2/detail/actions.cpp	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -19,8 +19,7 @@
 #include "./utils.hpp"
 #include "./markups.hpp"
 #include "./actions_class.hpp"
-#include "../block.hpp"
-#include "../phrase.hpp"
+#include "../grammars.hpp"
 #include "../code_snippet.hpp"
 
 namespace quickbook
Modified: branches/quickbook-1.5-spirit2/detail/actions.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/detail/actions.hpp	(original)
+++ branches/quickbook-1.5-spirit2/detail/actions.hpp	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -820,6 +820,32 @@
         std::string& out;
         collector& phrase;
     };
+
+    struct code_snippet_actions
+    {
+        code_snippet_actions(std::vector<template_symbol>& storage,
+                                 std::string const& doc_id,
+                                 char const* source_type)
+            : storage(storage)
+            , doc_id(doc_id)
+            , source_type(source_type)
+        {}
+
+        void pass_thru(iterator first, iterator last);
+        void escaped_comment(iterator first, iterator last);
+        void compile(iterator first, iterator last);
+        void callout(iterator first, iterator last, char const* role);
+        void inline_callout(iterator first, iterator last);
+        void line_callout(iterator first, iterator last);
+
+        std::string code;
+        std::string snippet;
+        std::string id;
+        std::vector<std::string> callouts;
+        std::vector<template_symbol>& storage;
+        std::string const doc_id;
+        char const* const source_type;
+    };
 }
 
 #ifdef BOOST_MSVC
Added: branches/quickbook-1.5-spirit2/detail/block.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/detail/block.cpp	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,12 @@
+#include "../block.hpp"
+#include "./actions_class.hpp"
+
+namespace quickbook
+{
+    typedef boost::spirit::classic::scanner<iterator> scanner;
+
+    void instantiate_phrase(block_grammar<quickbook::actions>& self)
+    {
+        block_grammar<quickbook::actions>::definition<scanner> definition(self);
+    }
+}
\ No newline at end of file
Added: branches/quickbook-1.5-spirit2/detail/code_snippet.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/detail/code_snippet.cpp	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,14 @@
+#include "../code_snippet.hpp"
+
+namespace quickbook
+{
+    typedef boost::spirit::classic::scanner<iterator> scanner;
+
+    void instantiate_code_snippet(
+        python_code_snippet_grammar& python,
+        cpp_code_snippet_grammar& cpp)
+    {
+        python_code_snippet_grammar::definition<scanner> python_definition(python);
+        cpp_code_snippet_grammar::definition<scanner> cpp_definition(cpp);
+    }
+}
\ No newline at end of file
Added: branches/quickbook-1.5-spirit2/detail/doc_info.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/detail/doc_info.cpp	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,12 @@
+#include "../doc_info.hpp"
+#include "./actions_class.hpp"
+
+namespace quickbook
+{
+    typedef boost::spirit::classic::scanner<iterator> scanner;
+
+    void instantiate_phrase(doc_info_grammar<quickbook::actions>& self)
+    {
+        doc_info_grammar<quickbook::actions>::definition<scanner> definition(self);
+    }
+}
\ No newline at end of file
Added: branches/quickbook-1.5-spirit2/detail/phrase.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/detail/phrase.cpp	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,17 @@
+#include "../phrase.hpp"
+#include "./actions_class.hpp"
+
+namespace quickbook
+{
+    typedef boost::spirit::classic::scanner<iterator> scanner;
+
+    void instantiate_simple_phrase(simple_phrase_grammar<quickbook::actions>& self)
+    {
+        simple_phrase_grammar<quickbook::actions>::definition<scanner> spgd(self);
+    }
+
+    void instantiate_phrase(phrase_grammar<quickbook::actions>& self)
+    {
+        phrase_grammar<quickbook::actions>::definition<scanner> pgd(self);
+    }
+}
\ No newline at end of file
Modified: branches/quickbook-1.5-spirit2/detail/quickbook.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/detail/quickbook.cpp	(original)
+++ branches/quickbook-1.5-spirit2/detail/quickbook.cpp	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -9,8 +9,7 @@
 =============================================================================*/
 #include "./quickbook.hpp"
 #include "./actions_class.hpp"
-#include "../block.hpp"
-#include "../doc_info.hpp"
+#include "../grammars.hpp"
 #include "./post_process.hpp"
 #include "./utils.hpp"
 #include "./input_path.hpp"
Modified: branches/quickbook-1.5-spirit2/doc_info.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info.hpp	(original)
+++ branches/quickbook-1.5-spirit2/doc_info.hpp	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -10,7 +10,7 @@
 #if !defined(BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP)
 #define BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP
 
-#include "./phrase.hpp"
+#include "./grammars.hpp"
 #include "./detail/quickbook.hpp"
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_actor.hpp>
@@ -22,176 +22,150 @@
     using namespace boost::spirit::classic;
 
     template <typename Actions>
-    struct doc_info_grammar
-    : public grammar<doc_info_grammar<Actions> >
+    template <typename Scanner>
+    doc_info_grammar<Actions>::
+        definition<Scanner>::definition(doc_info_grammar const& self)
+        : unused(false), common(self.actions, unused)
     {
-        doc_info_grammar(Actions& actions)
-            : actions(actions) {}
+        Actions& actions = self.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)
-            {
-                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
-                    >>  (  *(anychar_p -
-                            (ch_p('[') | ']' | eol_p)
-                            )
-                        )                           [assign_a(actions.doc_title)]
-                    >>  !(
-                            space >> '[' >>
-                                quickbook_version
-                            >> space >> ']'
-                        )
-                    >>
-                        *(
-                            space >> '[' >>
-                            (
-                              doc_version
-                            | doc_id
-                            | doc_dirname
-                            | doc_copyright         [push_back_a(actions.doc_copyrights, copyright)]
-                            | doc_purpose           [actions.extract_doc_purpose]
-                            | doc_category
-                            | doc_authors
-                            | doc_license           [actions.extract_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
-                    >> (*(anychar_p - ']'))         [assign_a(actions.doc_version)]
-                    ;
-
-                doc_id =
-                        "id" >> hard_space
-                    >> (*(anychar_p - ']'))         [assign_a(actions.doc_id)]
-                    ;
-
-                doc_dirname =
-                        "dirname" >> hard_space
-                    >> (*(anychar_p - ']'))         [assign_a(actions.doc_dirname)]
-                    ;
-
-                doc_copyright =
-                        "copyright" >> hard_space   [clear_a(copyright.first)]
-                    >> +( repeat_p(4)[digit_p]      [push_back_a(copyright.first)]
-                          >> space
-                        )
-                    >> space
-                    >> (*(anychar_p - ']'))         [assign_a(copyright.second)]
-                    ;
-
-                doc_purpose =
-                        "purpose" >> hard_space
-                    >> phrase                       [assign_a(actions.doc_purpose_1_1)]
-                    ;
-
-                doc_category =
-                        "category" >> hard_space
-                    >> (*(anychar_p - ']'))         [assign_a(actions.doc_category)]
-                    ;
-
-                doc_author =
-                        space
-                    >>  '[' >> space
-                    >>  (*(anychar_p - ','))        [assign_a(name.second)] // surname
-                    >>  ',' >> space
-                    >>  (*(anychar_p - ']'))        [assign_a(name.first)] // firstname
-                    >>  ']'
-                    ;
-
-                doc_authors =
-                        "authors" >> hard_space
-                    >> doc_author                   [push_back_a(actions.doc_authors, name)]
-                    >> *(   ','
-                            >>  doc_author          [push_back_a(actions.doc_authors, name)]
-                        )
-                    ;
-
-                doc_license =
-                        "license" >> hard_space
-                    >> phrase                       [assign_a(actions.doc_license_1_1)]
-                    ;
-
-                doc_last_revision =
-                        "last-revision" >> hard_space
-                    >> (*(anychar_p - ']'))         [assign_a(actions.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]
+        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
+            >>  (  *(anychar_p -
+                    (ch_p('[') | ']' | eol_p)
                     )
-                    ;
-            }
-
-            bool unused;
-            std::pair<std::string, std::string> name;
-            std::pair<std::vector<std::string>, std::string> copyright;
-            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;
-            phrase_grammar<Actions> common;
-            symbols<> doc_types;
-
-            rule<Scanner> const&
-            start() const { return doc_info; }
-        };
-
-        Actions& actions;
-    };
+                )                           [assign_a(actions.doc_title)]
+            >>  !(
+                    space >> '[' >>
+                        quickbook_version
+                    >> space >> ']'
+                )
+            >>
+                *(
+                    space >> '[' >>
+                    (
+                      doc_version
+                    | doc_id
+                    | doc_dirname
+                    | doc_copyright         [push_back_a(actions.doc_copyrights, copyright)]
+                    | doc_purpose           [actions.extract_doc_purpose]
+                    | doc_category
+                    | doc_authors
+                    | doc_license           [actions.extract_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
+            >> (*(anychar_p - ']'))         [assign_a(actions.doc_version)]
+            ;
+
+        doc_id =
+                "id" >> hard_space
+            >> (*(anychar_p - ']'))         [assign_a(actions.doc_id)]
+            ;
+
+        doc_dirname =
+                "dirname" >> hard_space
+            >> (*(anychar_p - ']'))         [assign_a(actions.doc_dirname)]
+            ;
+
+        doc_copyright =
+                "copyright" >> hard_space   [clear_a(copyright.first)]
+            >> +( repeat_p(4)[digit_p]      [push_back_a(copyright.first)]
+                  >> space
+                )
+            >> space
+            >> (*(anychar_p - ']'))         [assign_a(copyright.second)]
+            ;
+
+        doc_purpose =
+                "purpose" >> hard_space
+            >> phrase                       [assign_a(actions.doc_purpose_1_1)]
+            ;
+
+        doc_category =
+                "category" >> hard_space
+            >> (*(anychar_p - ']'))         [assign_a(actions.doc_category)]
+            ;
+
+        doc_author =
+                space
+            >>  '[' >> space
+            >>  (*(anychar_p - ','))        [assign_a(name.second)] // surname
+            >>  ',' >> space
+            >>  (*(anychar_p - ']'))        [assign_a(name.first)] // firstname
+            >>  ']'
+            ;
+
+        doc_authors =
+                "authors" >> hard_space
+            >> doc_author                   [push_back_a(actions.doc_authors, name)]
+            >> *(   ','
+                    >>  doc_author          [push_back_a(actions.doc_authors, name)]
+                )
+            ;
+
+        doc_license =
+                "license" >> hard_space
+            >> phrase                       [assign_a(actions.doc_license_1_1)]
+            ;
+
+        doc_last_revision =
+                "last-revision" >> hard_space
+            >> (*(anychar_p - ']'))         [assign_a(actions.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]
+            )
+            ;
+    }
 }
 
 #endif // BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP
Added: branches/quickbook-1.5-spirit2/grammars.hpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/grammars.hpp	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -0,0 +1,205 @@
+/*=============================================================================
+    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/classic_core.hpp>
+#include <boost/spirit/include/classic_symbols.hpp>
+#include <boost/spirit/include/classic_numerics.hpp>
+#include <boost/spirit/include/classic_iterator.hpp>
+
+namespace quickbook
+{
+    using namespace boost::spirit::classic;
+
+    template <typename Actions>
+    struct phrase_grammar : grammar<phrase_grammar<Actions> >
+    {
+        phrase_grammar(Actions& actions, bool& no_eols)
+            : no_eols(no_eols), actions(actions) {}
+
+        template <typename Scanner>
+        struct definition
+        {
+            definition(phrase_grammar const& self);
+
+            rule<Scanner>   space, blank, comment, phrase, phrase_markup, image,
+                            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, 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;
+        Actions& actions;
+    };
+
+    template <typename Actions>
+    struct simple_phrase_grammar
+    : public grammar<simple_phrase_grammar<Actions> >
+    {
+        simple_phrase_grammar(Actions& actions)
+            : actions(actions) {}
+
+        template <typename Scanner>
+        struct definition
+        {
+            definition(simple_phrase_grammar const& self);
+
+            bool unused;
+            rule<Scanner> phrase, comment, dummy_block;
+            phrase_grammar<Actions> common;
+
+            rule<Scanner> const&
+            start() const { return phrase; }
+        };
+
+        Actions& actions;
+    };
+
+    template <typename Actions, bool skip_initial_spaces = false>
+    struct block_grammar : grammar<block_grammar<Actions> >
+    {
+        block_grammar(Actions& actions_)
+            : actions(actions_) {}
+
+        template <typename Scanner>
+        struct definition
+        {
+            definition(block_grammar const& self);
+
+            bool no_eols;
+
+            rule<Scanner>   start_, blocks, block_markup, code, code_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;
+
+            symbols<>       paragraph_end_markups;
+
+            phrase_grammar<Actions> common;
+
+            rule<Scanner> const&
+            start() const { return start_; }
+        };
+
+        Actions&   actions;
+    };
+
+    template <typename Actions>
+    struct doc_info_grammar
+    : public grammar<doc_info_grammar<Actions> >
+    {
+        doc_info_grammar(Actions& actions)
+            : actions(actions) {}
+
+        template <typename Scanner>
+        struct definition
+        {
+            typedef uint_parser<int, 10, 1, 2>  uint2_t;
+
+            definition(doc_info_grammar const& self);
+            bool unused;
+            std::pair<std::string, std::string> name;
+            std::pair<std::vector<std::string>, std::string> copyright;
+            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;
+            phrase_grammar<Actions> common;
+            symbols<> doc_types;
+
+            rule<Scanner> const&
+            start() const { return doc_info; }
+        };
+
+        Actions& actions;
+    };
+
+    // TODO: Duplice definition:
+    
+    typedef position_iterator<std::string::const_iterator> iterator;
+
+    struct code_snippet_actions;
+
+    struct python_code_snippet_grammar
+        : grammar<python_code_snippet_grammar>
+    {
+        typedef code_snippet_actions actions_type;
+  
+        python_code_snippet_grammar(actions_type & actions)
+            : actions(actions)
+        {}
+
+        template <typename Scanner>
+        struct definition
+        {
+            typedef code_snippet_actions actions_type;
+            
+            definition(python_code_snippet_grammar const& self);
+
+            rule<Scanner>
+                start_, snippet, identifier, code_elements, escaped_comment,
+                inline_callout, line_callout, ignore;
+
+            rule<Scanner> const&
+            start() const { return start_; }
+        };
+
+        actions_type& actions;
+    };  
+
+    struct cpp_code_snippet_grammar
+        : grammar<cpp_code_snippet_grammar>
+    {
+        typedef code_snippet_actions actions_type;
+  
+        cpp_code_snippet_grammar(actions_type & actions)
+            : actions(actions)
+        {}
+
+        template <typename Scanner>
+        struct definition
+        {
+            definition(cpp_code_snippet_grammar const& self);
+
+            rule<Scanner>
+                start_, snippet, identifier, code_elements, escaped_comment,
+                inline_callout, line_callout, ignore;
+
+            rule<Scanner> const&
+            start() const { return start_; }
+        };
+
+        actions_type& actions;
+    };
+}
+
+#endif // BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP
+
+
Modified: branches/quickbook-1.5-spirit2/phrase.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase.hpp	(original)
+++ branches/quickbook-1.5-spirit2/phrase.hpp	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -10,8 +10,9 @@
 #if !defined(BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP)
 #define BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
 
+#include "./grammars.hpp"
 #include "./detail/quickbook.hpp"
-#include "detail/utils.hpp"
+#include "./detail/utils.hpp"
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_confix.hpp>
 #include <boost/spirit/include/classic_chset.hpp>
@@ -58,472 +59,426 @@
     }
 
     template <typename Actions>
-    struct phrase_grammar : grammar<phrase_grammar<Actions> >
+    template <typename Scanner>
+    phrase_grammar<Actions>::definition<Scanner>::definition(
+        phrase_grammar const& self)
     {
-        phrase_grammar(Actions& actions, bool& no_eols)
-            : no_eols(no_eols), actions(actions) {}
+        using detail::var;
+        Actions& actions = self.actions;
 
-        template <typename Scanner>
-        struct definition
-        {
-            definition(phrase_grammar const& self)
-            {
-                using detail::var;
-                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]
-                    ;
+        space =
+            *(space_p | comment)
+            ;
 
-                static const bool true_ = true;
-                static const bool false_ = false;
+        blank =
+            *(blank_p | comment)
+            ;
 
-                template_ =
-                    (
-                        ch_p('`')                       [assign_a(actions.template_escape,true_)]
-                        |
-                        eps_p                           [assign_a(actions.template_escape,false_)]
-                    )
-                    >>
-                    ( (
-                        (eps_p(punct_p)
-                            >> actions.templates.scope
-                        )                               [push_back_a(actions.template_info)]
-                        >> !template_args
-                    ) | (
-                        (actions.templates.scope
-                            >> eps_p
-                        )                               [push_back_a(actions.template_info)]
-                        >> !(hard_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                    [push_back_a(actions.template_info)]
-                    >> *(
-                            ".." >> template_arg_1_4    [push_back_a(actions.template_info)]
-                        )
-                    ;
+        eol = blank >> eol_p
+            ;
 
-                template_arg_1_4 =
-                    +(brackets_1_4 | (anychar_p - (str_p("..") | ']')))
-                    ;
-
-                brackets_1_4 =
-                    '[' >> +template_arg_1_4 >> ']'
-                    ;
-
-                template_args_1_5 =
-                    template_arg_1_5                    [push_back_a(actions.template_info)]
-                    >> *(
-                            ".." >> template_arg_1_5    [push_back_a(actions.template_info)]
-                        )
-                    ;
+        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
+                )                               [push_back_a(actions.template_info)]
+                >> !template_args
+            ) | (
+                (actions.templates.scope
+                    >> eps_p
+                )                               [push_back_a(actions.template_info)]
+                >> !(hard_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                    [push_back_a(actions.template_info)]
+            >> *(
+                    ".." >> template_arg_1_4    [push_back_a(actions.template_info)]
+                )
+            ;
+
+        template_arg_1_4 =
+            +(brackets_1_4 | (anychar_p - (str_p("..") | ']')))
+            ;
+
+        brackets_1_4 =
+            '[' >> +template_arg_1_4 >> ']'
+            ;
+
+        template_args_1_5 =
+            template_arg_1_5                    [push_back_a(actions.template_info)]
+            >> *(
+                    ".." >> template_arg_1_5    [push_back_a(actions.template_info)]
+                )
+            ;
 
-                template_arg_1_5 =
-                    +(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p("..") | '[' | ']')))
-                    ;
-
-                template_inner_arg_1_5 =
-                    +(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p('[') | ']')))
-                    ;
-
-                brackets_1_5 =
-                    '[' >> +template_inner_arg_1_5 >> ']'
-                    ;
+        template_arg_1_5 =
+            +(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p("..") | '[' | ']')))
+            ;
 
-                inline_code =
-                    '`' >>
+        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 -
-                            (   '`'
-                            |   (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]
-                            >>  "``"
-                        )
-                    ;
+                       *(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_markup(simple_bold,
-                    '*', actions.simple_bold, phrase_end);
-                simple_markup(simple_italic,
-                    '/', actions.simple_italic, phrase_end);
-                simple_markup(simple_underline,
-                    '_', actions.simple_underline, phrase_end);
-                simple_markup(simple_teletype,
-                    '=', actions.simple_teletype, 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_]
-                        )
-                    >>  ']'
-                    ;
+        simple_format =
+                simple_bold
+            |   simple_italic
+            |   simple_underline
+            |   simple_teletype
+            ;
+
+        simple_markup(simple_bold,
+            '*', actions.simple_bold, phrase_end);
+        simple_markup(simple_italic,
+            '/', actions.simple_italic, phrase_end);
+        simple_markup(simple_underline,
+            '_', actions.simple_underline, phrase_end);
+        simple_markup(simple_teletype,
+            '=', actions.simple_teletype, 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("\\n")                    [actions.break_]
-                    |   "\\ "                           // ignore an escaped char
-                    |   '\\' >> punct_p                 [actions.raw_char]
-                    |   (
-                            ("'''" >> !eol)             [actions.escape_pre]
-                        >>  *(anychar_p - "'''")        [actions.raw_char]
-                        >>  str_p("'''")                [actions.escape_post]
+        escape =
+                str_p("\\n")                    [actions.break_]
+            |   "\\ "                           // ignore an escaped char
+            |   '\\' >> punct_p                 [actions.raw_char]
+            |   (
+                    ("'''" >> !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]
+            ;
 
-                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]
-                    ;
+        link =
+                "link" >> hard_space
+            >>  (*(anychar_p -
+                    (']' | hard_space)))        [actions.link_pre]
+            >>  (   eps_p(']')
+                |   (hard_space >> phrase)
+                )                               [actions.link_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,
-                            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, 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;
-        Actions& actions;
-    };
+        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]
+            ;
+    }
 
     template <typename Actions>
-    struct simple_phrase_grammar
-    : public grammar<simple_phrase_grammar<Actions> >
+    template <typename Scanner>
+    simple_phrase_grammar<Actions>::definition<Scanner>::definition(
+        simple_phrase_grammar const& self)
+        : unused(false), common(self.actions, unused)
     {
-        simple_phrase_grammar(Actions& actions)
-            : actions(actions) {}
+        Actions& actions = self.actions;
+
+        phrase =
+           *(   common
+            |   comment
+            |   (anychar_p - ']')           [actions.plain_char]
+            )
+            ;
 
-        template <typename Scanner>
-        struct definition
-        {
-            definition(simple_phrase_grammar const& self)
-                : unused(false), common(self.actions, unused)
-            {
-                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<Actions> common;
-
-            rule<Scanner> const&
-            start() const { return phrase; }
-        };
+        comment =
+            "[/" >> *(dummy_block | (anychar_p - ']')) >> ']'
+            ;
 
-        Actions& actions;
-    };
+        dummy_block =
+            '[' >> *(dummy_block | (anychar_p - ']')) >> ']'
+            ;
+    }
 }
 
 #endif // BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
Modified: branches/quickbook-1.5-spirit2/syntax_highlight.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/syntax_highlight.hpp	(original)
+++ branches/quickbook-1.5-spirit2/syntax_highlight.hpp	2009-11-18 18:09:31 EST (Wed, 18 Nov 2009)
@@ -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 "./grammars.hpp"
 
 namespace quickbook
 {