Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60139 - branches/quickbook-1.5-spirit2
From: daniel_james_at_[hidden]
Date: 2010-03-03 18:31:09


Author: danieljames
Date: 2010-03-03 18:31:08 EST (Wed, 03 Mar 2010)
New Revision: 60139
URL: http://svn.boost.org/trac/boost/changeset/60139

Log:
Split up the block and phrase grammars
Added:
   branches/quickbook-1.5-spirit2/block_grammar.hpp (contents, props changed)
   branches/quickbook-1.5-spirit2/block_markup_grammar.cpp
      - copied, changed from r60138, /branches/quickbook-1.5-spirit2/block_grammar.cpp
   branches/quickbook-1.5-spirit2/phrase_grammar.hpp (contents, props changed)
   branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp (contents, props changed)
Text files modified:
   branches/quickbook-1.5-spirit2/Jamfile.v2 | 2
   branches/quickbook-1.5-spirit2/block_grammar.cpp | 414 ---------------------------------------
   branches/quickbook-1.5-spirit2/block_markup_grammar.cpp | 161 --------------
   branches/quickbook-1.5-spirit2/phrase_grammar.cpp | 284 ---------------------------
   4 files changed, 19 insertions(+), 842 deletions(-)

Modified: branches/quickbook-1.5-spirit2/Jamfile.v2
==============================================================================
--- branches/quickbook-1.5-spirit2/Jamfile.v2 (original)
+++ branches/quickbook-1.5-spirit2/Jamfile.v2 2010-03-03 18:31:08 EST (Wed, 03 Mar 2010)
@@ -29,9 +29,11 @@
     collector.cpp
     template.cpp
     phrase_grammar.cpp
+ phrase_markup_grammar.cpp
     phrase_actions.cpp
     phrase_image.cpp
     block_grammar.cpp
+ block_markup_grammar.cpp
     block_actions.cpp
     block_list.cpp
     doc_info_grammar.cpp

Modified: branches/quickbook-1.5-spirit2/block_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_grammar.cpp 2010-03-03 18:31:08 EST (Wed, 03 Mar 2010)
@@ -9,23 +9,16 @@
 =============================================================================*/
 
 #include <boost/spirit/include/qi_core.hpp>
-#include <boost/spirit/include/qi_eol.hpp>
-#include <boost/spirit/include/qi_eps.hpp>
 #include <boost/spirit/include/qi_attr.hpp>
-#include <boost/spirit/include/qi_attr_cast.hpp>
-#include <boost/spirit/include/qi_repeat.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_fusion.hpp>
+#include <boost/spirit/include/qi_eps.hpp>
+#include <boost/spirit/include/qi_eol.hpp>
 #include <boost/fusion/include/adapt_struct.hpp>
-#include "grammars.hpp"
-#include "block.hpp"
+#include "block_grammar.hpp"
 #include "template.hpp"
 #include "actions.hpp"
 #include "parse_utils.hpp"
 #include "code.hpp"
 #include "misc_rules.hpp"
-#include "rule_store.hpp"
 
 BOOST_FUSION_ADAPT_STRUCT(
     quickbook::paragraph,
@@ -40,94 +33,11 @@
     (std::string, content)
 )
 
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::title,
- (quickbook::raw_source, raw)
- (std::string, content)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::begin_section,
- (boost::optional<std::string>, id)
- (quickbook::title, content)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::end_section,
- (quickbook::file_position, position)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::heading,
- (int, level)
- (quickbook::title, content)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::def_macro,
- (std::string, macro_identifier)
- (std::string, content)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::define_template,
- (std::string, id)
- (std::vector<std::string>, params)
- (quickbook::template_value, body)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::template_value,
- (quickbook::file_position, position)
- (std::string, content)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::variablelist,
- (std::string, title)
- (std::vector<quickbook::varlistentry>, entries)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::table,
- (boost::optional<std::string>, id)
- (std::string, title)
- (std::vector<quickbook::table_row>, rows)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::xinclude,
- (std::string, path)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::import,
- (std::string, path)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::include,
- (boost::optional<std::string>, id)
- (std::string, path)
-)
-
 namespace quickbook
 {
     namespace qi = boost::spirit::qi;
     namespace ph = boost::phoenix;
 
- struct block_grammar::rules
- {
- rules(quickbook::actions& actions_);
-
- quickbook::actions& actions;
- bool no_eols;
- phrase_grammar common;
-
- rule_store store_;
- qi::rule<iterator> start_;
- };
-
     block_grammar::block_grammar(quickbook::actions& actions_)
         : block_grammar::base_type(start, "block")
         , rules_pimpl(new rules(actions_))
@@ -138,31 +48,13 @@
     block_grammar::rules::rules(quickbook::actions& actions_)
         : actions(actions_), no_eols(true), common(actions, no_eols)
     {
+ init_block_markup();
+
         qi::rule<iterator>& blocks = store_.create();
- qi::rule<iterator>& block_markup = store_.create();
- qi::rule<iterator, quickbook::begin_section()>& begin_section = store_.create();
- qi::rule<iterator, quickbook::end_section()>& end_section = store_.create();
- qi::rule<iterator, quickbook::heading()>& heading = store_.create();
- qi::rule<iterator, quickbook::formatted()>& paragraph_block = store_.create();
- qi::rule<iterator, quickbook::formatted()>& blockquote = store_.create();
- qi::rule<iterator, quickbook::formatted()>& preformatted = store_.create();
- qi::rule<iterator, quickbook::def_macro()>& def_macro = store_.create();
- qi::rule<iterator, quickbook::table()>& table = store_.create();
- qi::rule<iterator, quickbook::variablelist()>& variablelist = store_.create();
- qi::rule<iterator, quickbook::xinclude()>& xinclude = store_.create();
- qi::rule<iterator, quickbook::include()>& include = store_.create();
- qi::rule<iterator, quickbook::import()>& import = store_.create();
- qi::rule<iterator, quickbook::define_template()>& define_template = store_.create();
         qi::rule<iterator, quickbook::code()>& code = store_.create();
         qi::rule<iterator, quickbook::list()>& list = store_.create();
         qi::rule<iterator, quickbook::hr()>& hr = store_.create();
         qi::rule<iterator, quickbook::paragraph()>& paragraph = store_.create();
- qi::rule<iterator, quickbook::title()>& title_phrase = store_.create();
- qi::rule<iterator, std::string()>& inside_paragraph = store_.create();
- qi::rule<iterator, std::string()>& phrase_attr = store_.create();
- qi::rule<iterator>& phrase_end = store_.create();
- qi::rule<iterator, boost::optional<std::string>()>& element_id = store_.create();
- qi::rule<iterator>& error = store_.create();
 
         start_ =
             blocks >> blank
@@ -179,234 +71,6 @@
             )
             ;
 
- block_markup =
- '[' >> space
- >> ( begin_section
- | end_section
- | heading
- | paragraph_block
- | blockquote
- | preformatted
- | def_macro
- | table
- | variablelist
- | xinclude
- | include
- | import
- | define_template
- ) [actions.process]
- >> ( (space >> ']' >> +eol)
- | error
- )
- ;
-
- begin_section =
- "section"
- >> hard_space
- >> element_id
- >> title_phrase
- ;
-
- end_section =
- position
- >> "endsect"
- >> qi::attr(nothing())
- ;
-
- qi::symbols<char, int>& heading_symbol = store_.create();
- heading = heading_symbol >> hard_space >> title_phrase;
-
- heading_symbol.add
- ("h1", 1)
- ("h2", 2)
- ("h3", 3)
- ("h4", 4)
- ("h5", 5)
- ("h6", 6)
- ("heading", -1);
-
- qi::symbols<char, quickbook::formatted_type>& paragraph_blocks = store_.create();
-
- paragraph_block =
- paragraph_blocks >> hard_space >> inside_paragraph
- ;
-
- paragraph_blocks.add
- ("blurb", formatted_type("blurb"))
- ("warning", formatted_type("warning"))
- ("caution", formatted_type("caution"))
- ("important", formatted_type("important"))
- ("note", formatted_type("note"))
- ("tip", formatted_type("tip"))
- ;
-
- blockquote =
- ':'
- >> blank
- >> qi::attr(formatted_type("blockquote"))
- >> inside_paragraph
- ;
-
- preformatted %=
- "pre"
- >> hard_space [ph::ref(no_eols) = false]
- >> -eol
- >> qi::attr(formatted_type("preformatted"))
- >> phrase_attr
- >> qi::eps [ph::ref(no_eols) = true]
- ;
-
- def_macro =
- "def"
- >> hard_space
- >> macro_identifier
- >> blank
- >> phrase_attr
- ;
-
- qi::rule<iterator, quickbook::table_row()>& table_row = store_.create();
- qi::rule<iterator, quickbook::table_cell()>& table_cell = store_.create();
- qi::rule<iterator, quickbook::formatted()>& table_cell_body = store_.create();
-
- table =
- "table"
- >> (&(*qi::blank >> qi::eol) | hard_space)
- >> ((qi::eps(qbk_since(105u)) >> element_id) | qi::eps)
- >> (&(*qi::blank >> qi::eol) | space)
- >> *(qi::char_ - eol)
- >> +eol
- >> *table_row
- ;
-
- table_row =
- space
- >> '['
- >> ( *table_cell >> ']' >> space
- | error >> qi::attr(quickbook::table_row())
- )
- ;
-
- table_cell =
- space
- >> '['
- >> ( table_cell_body >> ']' >> space
- | error >> qi::attr(quickbook::table_cell())
- )
- ;
-
- table_cell_body =
- qi::attr(formatted_type("cell"))
- >> inside_paragraph
- ;
-
- qi::rule<iterator, quickbook::varlistentry()>& varlistentry = store_.create();
- qi::rule<iterator, quickbook::formatted()>& varlistterm = store_.create();
- qi::rule<iterator, quickbook::formatted()>& varlistterm_body = store_.create();
- qi::rule<iterator, quickbook::formatted()>& varlistitem = store_.create();
- qi::rule<iterator, quickbook::formatted()>& varlistitem_body = store_.create();
-
- variablelist =
- "variablelist"
- >> (&(*qi::blank >> qi::eol) | hard_space)
- >> *(qi::char_ - eol)
- >> +eol
- >> *varlistentry
- ;
-
- varlistentry =
- space
- >> '['
- >> ( varlistterm
- >> +varlistitem
- >> ']'
- >> space
- | error >> qi::attr(quickbook::varlistentry())
- )
- ;
-
- varlistterm =
- space
- >> '['
- >> ( varlistterm_body >> ']' >> space
- | error >> qi::attr(quickbook::formatted())
- )
- ;
-
- varlistterm_body =
- qi::attr(formatted_type("varlistterm"))
- >> phrase_attr
- ;
-
- varlistitem =
- space
- >> '['
- >> ( varlistitem_body >> ']' >> space
- | error >> qi::attr(quickbook::formatted())
- )
- ;
-
- varlistitem_body =
- qi::attr(formatted_type("varlistitem"))
- >> inside_paragraph
- ;
-
- // TODO: Why do these use phrase_end? It doesn't make any sense.
- xinclude =
- "xinclude"
- >> hard_space
- >> *(qi::char_ - phrase_end)
- >> qi::attr(nothing())
- ;
-
- include =
- "include"
- >> hard_space
- >> -(
- ':'
- >> *((qi::alnum | '_') - qi::space)
- >> space
- )
- >> *(qi::char_ - phrase_end)
- ;
-
- import =
- "import"
- >> hard_space
- >> *(qi::char_ - phrase_end)
- >> qi::attr(nothing())
- ;
-
- qi::rule<iterator, std::string()>& template_id = store_.create();
- qi::rule<iterator, quickbook::template_value()>& template_body = store_.create();
- qi::rule<iterator>& template_body_recurse = store_.create();
-
- define_template =
- "template"
- >> hard_space
- >> template_id
- >> -(
- space
- >> '['
- >> *(space >> template_id)
- >> space
- >> ']'
- )
- >> template_body
- ;
-
- template_body =
- position
- >> qi::raw[template_body_recurse]
- ;
-
- template_body_recurse =
- *( ('[' >> template_body_recurse >> ']')
- | (qi::char_ - ']')
- )
- >> space
- >> &qi::lit(']')
- ;
-
         // Blocks indicated by text layout (indentation, leading characters etc.)
 
         qi::rule<iterator>& code_line = store_.create();
@@ -491,73 +155,5 @@
             "variablelist", "import", "template", "warning", "caution",
             "important", "note", "tip", ":"
             ;
-
- // Block contents
-
- // Used when the title is used both to generate the title text and
- // possibly to generate an id (based on the raw source).
- title_phrase =
- qi::raw[
- phrase_attr [ph::at_c<1>(qi::_val) = qi::_1]
- ] [ph::at_c<0>(qi::_val) = qi::_1]
- ;
-
- qi::rule<iterator, quickbook::formatted()>& inside_paragraph2 = store_.create();
-
- inside_paragraph =
- qi::eps [actions.phrase_push]
- >> inside_paragraph2 [actions.process]
- >> *( eol
- >> eol
- >> inside_paragraph2 [actions.process]
- )
- >> qi::eps [actions.phrase_pop]
- ;
-
- inside_paragraph2 =
- qi::attr(formatted_type("paragraph"))
- >> phrase_attr;
-
- phrase_attr =
- qi::eps [actions.phrase_push]
- >> *( common
- | comment
- | (qi::char_ - phrase_end) [actions.process]
- )
- >> qi::eps [actions.phrase_pop]
- ;
-
- // Make sure that we don't go past a single block, except when
- // preformatted.
- phrase_end =
- ']' | qi::eps(ph::ref(no_eols)) >> eol >> eol
- ;
-
- // Identifiers
-
- qi::rule<iterator, std::string()>& element_id_part = store_.create();
-
- element_id =
- ( ':'
- >> -(qi::eps(qbk_since(105u)) >> space)
- >> (
- element_id_part
- | qi::omit[
- qi::raw[qi::eps] [actions.element_id_warning]
- ]
- )
- )
- | qi::eps
- ;
-
- element_id_part = +(qi::alnum | qi::char_('_'));
-
- template_id
- = (qi::alpha | '_') >> *(qi::alnum | '_')
- | qi::repeat(1)[qi::punct - qi::char_("[]")]
- ;
-
- error =
- qi::raw[qi::eps] [actions.error];
     }
 }

Added: branches/quickbook-1.5-spirit2/block_grammar.hpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/block_grammar.hpp 2010-03-03 18:31:08 EST (Wed, 03 Mar 2010)
@@ -0,0 +1,33 @@
+/*=============================================================================
+ Copyright (c) 2002 2004 2006Joel de Guzman
+ Copyright (c) 2004 Eric Niebler
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#include "grammars.hpp"
+#include "block.hpp"
+#include "rule_store.hpp"
+
+namespace quickbook
+{
+ namespace qi = boost::spirit::qi;
+
+ struct block_grammar::rules
+ {
+ rules(quickbook::actions& actions_);
+
+ quickbook::actions& actions;
+ bool no_eols;
+ phrase_grammar common;
+
+ rule_store store_;
+ qi::rule<iterator> start_;
+ qi::rule<iterator> block_markup;
+
+ void init_block_markup();
+ };
+}
\ No newline at end of file

Copied: branches/quickbook-1.5-spirit2/block_markup_grammar.cpp (from r60138, /branches/quickbook-1.5-spirit2/block_grammar.cpp)
==============================================================================
--- /branches/quickbook-1.5-spirit2/block_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_markup_grammar.cpp 2010-03-03 18:31:08 EST (Wed, 03 Mar 2010)
@@ -9,36 +9,19 @@
 =============================================================================*/
 
 #include <boost/spirit/include/qi_core.hpp>
-#include <boost/spirit/include/qi_eol.hpp>
-#include <boost/spirit/include/qi_eps.hpp>
 #include <boost/spirit/include/qi_attr.hpp>
-#include <boost/spirit/include/qi_attr_cast.hpp>
-#include <boost/spirit/include/qi_repeat.hpp>
+#include <boost/spirit/include/qi_eps.hpp>
+#include <boost/spirit/include/qi_eol.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
 #include <boost/spirit/include/phoenix_fusion.hpp>
 #include <boost/fusion/include/adapt_struct.hpp>
-#include "grammars.hpp"
-#include "block.hpp"
+#include "block_grammar.hpp"
 #include "template.hpp"
 #include "actions.hpp"
 #include "parse_utils.hpp"
 #include "code.hpp"
 #include "misc_rules.hpp"
-#include "rule_store.hpp"
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::paragraph,
- (std::string, content)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::list_item,
- (quickbook::file_position, position)
- (std::string, indent)
- (char, mark)
- (std::string, content)
-)
 
 BOOST_FUSION_ADAPT_STRUCT(
     quickbook::title,
@@ -116,30 +99,8 @@
     namespace qi = boost::spirit::qi;
     namespace ph = boost::phoenix;
 
- struct block_grammar::rules
+ void block_grammar::rules::init_block_markup()
     {
- rules(quickbook::actions& actions_);
-
- quickbook::actions& actions;
- bool no_eols;
- phrase_grammar common;
-
- rule_store store_;
- qi::rule<iterator> start_;
- };
-
- block_grammar::block_grammar(quickbook::actions& actions_)
- : block_grammar::base_type(start, "block")
- , rules_pimpl(new rules(actions_))
- , start(rules_pimpl->start_) {}
-
- block_grammar::~block_grammar() {}
-
- block_grammar::rules::rules(quickbook::actions& actions_)
- : actions(actions_), no_eols(true), common(actions, no_eols)
- {
- qi::rule<iterator>& blocks = store_.create();
- qi::rule<iterator>& block_markup = store_.create();
         qi::rule<iterator, quickbook::begin_section()>& begin_section = store_.create();
         qi::rule<iterator, quickbook::end_section()>& end_section = store_.create();
         qi::rule<iterator, quickbook::heading()>& heading = store_.create();
@@ -153,10 +114,6 @@
         qi::rule<iterator, quickbook::include()>& include = store_.create();
         qi::rule<iterator, quickbook::import()>& import = store_.create();
         qi::rule<iterator, quickbook::define_template()>& define_template = store_.create();
- qi::rule<iterator, quickbook::code()>& code = store_.create();
- qi::rule<iterator, quickbook::list()>& list = store_.create();
- qi::rule<iterator, quickbook::hr()>& hr = store_.create();
- qi::rule<iterator, quickbook::paragraph()>& paragraph = store_.create();
         qi::rule<iterator, quickbook::title()>& title_phrase = store_.create();
         qi::rule<iterator, std::string()>& inside_paragraph = store_.create();
         qi::rule<iterator, std::string()>& phrase_attr = store_.create();
@@ -164,21 +121,6 @@
         qi::rule<iterator, boost::optional<std::string>()>& element_id = store_.create();
         qi::rule<iterator>& error = store_.create();
 
- start_ =
- blocks >> blank
- ;
-
- blocks =
- +( block_markup
- | code [actions.process]
- | list [actions.process]
- | hr [actions.process]
- | comment >> *eol
- | paragraph [actions.process]
- | eol
- )
- ;
-
         block_markup =
                 '[' >> space
>> ( begin_section
@@ -376,9 +318,9 @@
>> qi::attr(nothing())
             ;
 
- qi::rule<iterator, std::string()>& template_id = store_.create();
         qi::rule<iterator, quickbook::template_value()>& template_body = store_.create();
         qi::rule<iterator>& template_body_recurse = store_.create();
+ qi::rule<iterator, std::string()>& template_id = store_.create();
 
         define_template =
                 "template"
@@ -407,89 +349,9 @@
>> &qi::lit(']')
             ;
 
- // Blocks indicated by text layout (indentation, leading characters etc.)
-
- qi::rule<iterator>& code_line = store_.create();
-
- code =
- position
- >> qi::raw[
- code_line
- >> *(*eol >> code_line)
- ]
- >> +eol
- >> qi::attr(true)
- ;
-
- code_line =
- qi::char_(" \t")
- >> *(qi::char_ - eol)
- >> eol
- ;
-
- qi::rule<iterator, quickbook::list_item()>& list_item = store_.create();
- qi::rule<iterator, std::string()>& list_item_content = store_.create();
-
- list =
- &qi::char_("*#")
- >> +list_item
- ;
-
- list_item =
- position
- >> *qi::blank
- >> qi::char_("*#")
- >> qi::omit[*qi::blank]
- >> list_item_content
- ;
-
- list_item_content =
- qi::eps[actions.phrase_push] >>
- *( common
- | (qi::char_ -
- ( qi::eol >> *qi::blank >> &(qi::char_('*') | '#')
- | (eol >> eol)
- )
- ) [actions.process]
- )
- >> +eol
- >> qi::eps[actions.phrase_pop]
- ;
-
- hr =
- qi::omit[
- "----"
- >> *(qi::char_ - eol)
- >> +eol
- ] >> qi::attr(quickbook::hr())
- ;
-
- qi::rule<iterator, std::string()>& paragraph_content = store_.create();
- qi::rule<iterator>& paragraph_end = store_.create();
- qi::symbols<>& paragraph_end_markups = store_.create();
-
- paragraph = paragraph_content >> qi::attr(nothing());
-
- paragraph_content =
- qi::eps [actions.phrase_push]
- >> *( common
- | (qi::char_ - // Make sure we don't go past
- paragraph_end // a single block.
- ) [actions.process]
- )
- >> qi::eps [actions.phrase_pop]
- >> (&qi::lit('[') | +eol)
- ;
-
- paragraph_end =
- '[' >> space >> paragraph_end_markups >> hard_space | eol >> 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", ":"
+ template_id
+ = (qi::alpha | '_') >> *(qi::alnum | '_')
+ | qi::repeat(1)[qi::punct - qi::char_("[]")]
             ;
 
         // Block contents
@@ -552,12 +414,7 @@
 
         element_id_part = +(qi::alnum | qi::char_('_'));
 
- template_id
- = (qi::alpha | '_') >> *(qi::alnum | '_')
- | qi::repeat(1)[qi::punct - qi::char_("[]")]
- ;
-
         error =
             qi::raw[qi::eps] [actions.error];
     }
-}
+}
\ No newline at end of file

Modified: branches/quickbook-1.5-spirit2/phrase_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_grammar.cpp 2010-03-03 18:31:08 EST (Wed, 03 Mar 2010)
@@ -8,38 +8,17 @@
     http://www.boost.org/LICENSE_1_0.txt)
 =============================================================================*/
 
-#include <map>
 #include <boost/spirit/include/qi_core.hpp>
-#include <boost/spirit/include/qi_symbols.hpp>
 #include <boost/spirit/include/qi_attr.hpp>
 #include <boost/spirit/include/qi_eoi.hpp>
-#include <boost/spirit/include/qi_eol.hpp>
 #include <boost/spirit/include/qi_eps.hpp>
-#include <boost/spirit/include/qi_matches.hpp>
-#include <boost/spirit/include/qi_uint.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
 #include <boost/fusion/include/std_pair.hpp>
 #include <boost/fusion/include/adapt_struct.hpp>
+#include "phrase_grammar.hpp"
 #include "code.hpp"
-#include "phrase.hpp"
-#include "grammars.hpp"
 #include "actions.hpp"
-#include "template.hpp"
-#include "parse_utils.hpp"
 #include "misc_rules.hpp"
-#include "rule_store.hpp"
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::anchor,
- (std::string, id)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::link,
- (quickbook::formatted_type, type)
- (std::string, destination)
- (std::string, content)
-)
 
 BOOST_FUSION_ADAPT_STRUCT(
     quickbook::simple_markup,
@@ -48,44 +27,6 @@
 )
 
 BOOST_FUSION_ADAPT_STRUCT(
- quickbook::break_,
- (quickbook::file_position, position)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::image,
- (quickbook::file_position, position)
- (std::string, image_filename)
- (quickbook::image::attribute_map, attributes)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::cond_phrase,
- (std::string, macro_id)
- (std::string, content)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::call_template,
- (quickbook::file_position, position)
- (bool, escape)
- (quickbook::template_symbol const*, symbol)
- (std::vector<quickbook::template_value>, args)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::template_value,
- (quickbook::file_position, position)
- (std::string, content)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::callout_link,
- (std::string, role)
- (std::string, identifier)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
     quickbook::unicode_char,
     (std::string, value)
 )
@@ -94,17 +35,6 @@
 {
     namespace qi = boost::spirit::qi;
     namespace ph = boost::phoenix;
-
- struct phrase_grammar::rules
- {
- rules(quickbook::actions& actions, bool& no_eols);
-
- quickbook::actions& actions;
- bool& no_eols;
-
- rule_store store_;
- qi::rule<iterator> common;
- };
 
     phrase_grammar::phrase_grammar(quickbook::actions& actions, bool& no_eols)
         : phrase_grammar::base_type(start, "phrase")
@@ -118,24 +48,13 @@
     phrase_grammar::rules::rules(quickbook::actions& actions, bool& no_eols)
         : actions(actions), no_eols(no_eols)
     {
- qi::rule<iterator, std::string()>& phrase = store_.create();
+ init_phrase_markup();
+
         qi::rule<iterator>& macro = store_.create();
- qi::rule<iterator>& phrase_markup = store_.create();
         qi::rule<iterator, quickbook::code()>& code_block = store_.create();
         qi::rule<iterator, quickbook::code()>& inline_code = store_.create();
         qi::rule<iterator, quickbook::simple_markup(), qi::locals<char> >& simple_format = store_.create();
         qi::rule<iterator>& escape = store_.create();
- qi::rule<iterator, quickbook::callout_link()>& callout_link = store_.create();
- qi::rule<iterator, quickbook::cond_phrase()>& cond_phrase = store_.create();
- qi::rule<iterator, quickbook::image()>& image = store_.create();
- qi::rule<iterator, quickbook::link()>& url = store_.create();
- qi::rule<iterator, quickbook::link()>& link = store_.create();
- qi::rule<iterator, quickbook::anchor()>& anchor = store_.create();
- qi::symbols<char, quickbook::source_mode>& source_mode = store_.create();
- qi::rule<iterator, quickbook::formatted()>& formatted = store_.create();
- qi::rule<iterator, quickbook::formatted()>& footnote = store_.create();
- qi::rule<iterator, quickbook::call_template()>& call_template = store_.create();
- qi::rule<iterator, quickbook::break_()>& break_ = store_.create();
         qi::rule<iterator>& phrase_end = store_.create();
 
         phrase =
@@ -163,24 +82,6 @@
             ) [actions.process]
             ;
 
- phrase_markup =
- ( '['
- >> ( callout_link
- | cond_phrase
- | image
- | url
- | link
- | anchor
- | source_mode
- | formatted
- | footnote
- | call_template
- | break_
- )
- >> ']'
- ) [actions.process]
- ;
-
         code_block =
                 (
                     "```"
@@ -281,185 +182,6 @@
>> qi::attr(nothing())
             ;
 
- // Don't use this, it's meant to be private.
- callout_link =
- "[callout]"
- >> *~qi::char_(' ')
- >> ' '
- >> *~qi::char_(']')
- >> qi::attr(nothing())
- ;
-
- cond_phrase =
- '?'
- >> blank
- >> macro_identifier
- >> -phrase
- ;
-
- qi::rule<iterator, quickbook::image()>& image_1_4 = store_.create();
- qi::rule<iterator, quickbook::image()>& image_1_5 = store_.create();
- qi::rule<iterator, std::string()>& image_filename = store_.create();
- qi::rule<iterator, quickbook::image::attribute_map()>& image_attributes = store_.create();
- qi::rule<iterator, std::pair<std::string, std::string>()>& image_attribute = store_.create();
- qi::rule<iterator, std::string()>& image_attribute_key = store_.create();
- qi::rule<iterator, std::string()>& image_attribute_value = store_.create();
-
- image =
- (qi::eps(qbk_since(105u)) >> image_1_5) |
- (qi::eps(qbk_before(105u)) >> image_1_4);
-
- image_1_4 =
- position
- >> '$'
- >> blank
- >> *(qi::char_ - phrase_end)
- >> &qi::lit(']')
- ;
-
- image_1_5 =
- position
- >> '$'
- >> blank
- >> image_filename
- >> hard_space
- >> image_attributes
- >> &qi::lit(']')
- ;
-
- image_filename = qi::raw[
- +(qi::char_ - (qi::space | phrase_end | '['))
- >> *(
- +qi::space
- >> +(qi::char_ - (qi::space | phrase_end | '['))
- )];
-
- image_attributes = *(image_attribute >> space);
-
- image_attribute =
- '['
- >> image_attribute_key
- >> space
- >> image_attribute_value
- >> ']'
- ;
-
- image_attribute_key = *(qi::alnum | '_');
- image_attribute_value = *(qi::char_ - (phrase_end | '['));
-
- url =
- '@'
- >> qi::attr("url")
- >> *(qi::char_ - (']' | qi::space))
- >> ( &qi::lit(']')
- | (hard_space >> phrase)
- )
- ;
-
- qi::symbols<char, formatted_type>& link_symbol = store_.create();
-
- link =
- link_symbol
- >> hard_space
- >> *(qi::char_ - (']' | qi::space))
- >> ( &qi::lit(']')
- | (hard_space >> phrase)
- )
- ;
-
- link_symbol.add
- ("link", formatted_type("link"))
- ("funcref", formatted_type("funcref"))
- ("classref", formatted_type("classref"))
- ("memberref", formatted_type("memberref"))
- ("enumref", formatted_type("enumref"))
- ("macroref", formatted_type("macroref"))
- ("headerref", formatted_type("headerref"))
- ("conceptref", formatted_type("conceptref"))
- ("globalref", formatted_type("globalref"))
- ;
-
- anchor =
- '#'
- >> blank
- >> *(qi::char_ - phrase_end)
- >> qi::attr(nothing())
- ;
-
- source_mode.add
- ("c++", quickbook::source_mode("c++"))
- ("python", quickbook::source_mode("python"))
- ("teletype", quickbook::source_mode("teletype"))
- ;
-
- qi::symbols<char, formatted_type>& format_symbol = store_.create();
-
- formatted = format_symbol >> blank >> phrase;
-
- format_symbol.add
- ("*", "bold")
- ("'", "italic")
- ("_", "underline")
- ("^", "teletype")
- ("-", "strikethrough")
- ("\"", "quote")
- ("~", "replaceable")
- ;
-
- footnote =
- "footnote"
- >> qi::attr("footnote")
- >> blank
- >> phrase
- ;
-
- // Template call
-
- qi::rule<iterator, std::vector<quickbook::template_value>()>& template_args = store_.create();
- qi::rule<iterator, quickbook::template_value()>& template_arg_1_4 = store_.create();
- qi::rule<iterator>& brackets_1_4 = store_.create();
- qi::rule<iterator, quickbook::template_value()>& template_arg_1_5 = store_.create();
- qi::rule<iterator>& brackets_1_5 = store_.create();
-
- call_template =
- position
- >> qi::matches['`']
- >> ( // Lookup the template name
- (&qi::punct >> actions.templates.scope)
- | (actions.templates.scope >> hard_space)
- )
- >> template_args
- >> &qi::lit(']')
- ;
-
- template_args =
- qi::eps(qbk_before(105u)) >> -(template_arg_1_4 % "..") |
- qi::eps(qbk_since(105u)) >> -(template_arg_1_5 % "..");
-
- template_arg_1_4 =
- position >>
- qi::raw[+(brackets_1_4 | ~qi::char_(']') - "..")]
- ;
-
- brackets_1_4 =
- '[' >> +(brackets_1_4 | ~qi::char_(']') - "..") >> ']'
- ;
-
- template_arg_1_5 =
- position >>
- qi::raw[+(brackets_1_5 | '\\' >> qi::char_ | ~qi::char_("[]") - "..")]
- ;
-
- brackets_1_5 =
- '[' >> +(brackets_1_5 | '\\' >> qi::char_ | ~qi::char_("[]")) >> ']'
- ;
-
- break_ =
- position
- >> "br"
- >> qi::attr(nothing())
- ;
-
         phrase_end =
             ']' |
             qi::eps(ph::ref(no_eols)) >>

Added: branches/quickbook-1.5-spirit2/phrase_grammar.hpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/phrase_grammar.hpp 2010-03-03 18:31:08 EST (Wed, 03 Mar 2010)
@@ -0,0 +1,39 @@
+/*=============================================================================
+ 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)
+=============================================================================*/
+
+#include <boost/fusion/include/adapt_struct.hpp>
+#include "grammars.hpp"
+#include "phrase.hpp"
+#include "rule_store.hpp"
+
+namespace quickbook
+{
+ namespace qi = boost::spirit::qi;
+
+ struct phrase_grammar::rules
+ {
+ rules(quickbook::actions& actions, bool& no_eols);
+
+ quickbook::actions& actions;
+ bool& no_eols;
+
+ rule_store store_;
+ qi::rule<iterator> common;
+ qi::rule<iterator, std::string()> phrase;
+ qi::rule<iterator> phrase_markup;
+
+ void init_phrase_markup();
+ };
+}
+
+BOOST_FUSION_ADAPT_STRUCT(
+ quickbook::break_,
+ (quickbook::file_position, position)
+)
\ No newline at end of file

Added: branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp 2010-03-03 18:31:08 EST (Wed, 03 Mar 2010)
@@ -0,0 +1,290 @@
+/*=============================================================================
+ 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)
+=============================================================================*/
+
+#include <boost/spirit/include/qi_core.hpp>
+#include <boost/spirit/include/qi_symbols.hpp>
+#include <boost/spirit/include/qi_attr.hpp>
+#include <boost/spirit/include/qi_eps.hpp>
+#include <boost/fusion/include/std_pair.hpp>
+#include "phrase_grammar.hpp"
+#include "actions.hpp"
+#include "template.hpp"
+#include "misc_rules.hpp"
+
+BOOST_FUSION_ADAPT_STRUCT(
+ quickbook::anchor,
+ (std::string, id)
+)
+
+BOOST_FUSION_ADAPT_STRUCT(
+ quickbook::link,
+ (quickbook::formatted_type, type)
+ (std::string, destination)
+ (std::string, content)
+)
+
+BOOST_FUSION_ADAPT_STRUCT(
+ quickbook::image,
+ (quickbook::file_position, position)
+ (std::string, image_filename)
+ (quickbook::image::attribute_map, attributes)
+)
+
+BOOST_FUSION_ADAPT_STRUCT(
+ quickbook::cond_phrase,
+ (std::string, macro_id)
+ (std::string, content)
+)
+
+BOOST_FUSION_ADAPT_STRUCT(
+ quickbook::call_template,
+ (quickbook::file_position, position)
+ (bool, escape)
+ (quickbook::template_symbol const*, symbol)
+ (std::vector<quickbook::template_value>, args)
+)
+
+BOOST_FUSION_ADAPT_STRUCT(
+ quickbook::template_value,
+ (quickbook::file_position, position)
+ (std::string, content)
+)
+
+BOOST_FUSION_ADAPT_STRUCT(
+ quickbook::callout_link,
+ (std::string, role)
+ (std::string, identifier)
+)
+
+namespace quickbook
+{
+ namespace qi = boost::spirit::qi;
+ namespace ph = boost::phoenix;
+
+ void phrase_grammar::rules::init_phrase_markup()
+ {
+ qi::rule<iterator, quickbook::callout_link()>& callout_link = store_.create();
+ qi::rule<iterator, quickbook::cond_phrase()>& cond_phrase = store_.create();
+ qi::rule<iterator, quickbook::image()>& image = store_.create();
+ qi::rule<iterator, quickbook::link()>& url = store_.create();
+ qi::rule<iterator, quickbook::link()>& link = store_.create();
+ qi::rule<iterator, quickbook::anchor()>& anchor = store_.create();
+ qi::symbols<char, quickbook::source_mode>& source_mode = store_.create();
+ qi::rule<iterator, quickbook::formatted()>& formatted = store_.create();
+ qi::rule<iterator, quickbook::formatted()>& footnote = store_.create();
+ qi::rule<iterator, quickbook::call_template()>& call_template = store_.create();
+ qi::rule<iterator, quickbook::break_()>& break_ = store_.create();
+ qi::rule<iterator>& phrase_end = store_.create();
+
+ phrase_markup =
+ ( '['
+ >> ( callout_link
+ | cond_phrase
+ | image
+ | url
+ | link
+ | anchor
+ | source_mode
+ | formatted
+ | footnote
+ | call_template
+ | break_
+ )
+ >> ']'
+ ) [actions.process]
+ ;
+
+ // Don't use this, it's meant to be private.
+ callout_link =
+ "[callout]"
+ >> *~qi::char_(' ')
+ >> ' '
+ >> *~qi::char_(']')
+ >> qi::attr(nothing())
+ ;
+
+ cond_phrase =
+ '?'
+ >> blank
+ >> macro_identifier
+ >> -phrase
+ ;
+
+ qi::rule<iterator, quickbook::image()>& image_1_4 = store_.create();
+ qi::rule<iterator, quickbook::image()>& image_1_5 = store_.create();
+ qi::rule<iterator, std::string()>& image_filename = store_.create();
+ qi::rule<iterator, quickbook::image::attribute_map()>& image_attributes = store_.create();
+ qi::rule<iterator, std::pair<std::string, std::string>()>& image_attribute = store_.create();
+ qi::rule<iterator, std::string()>& image_attribute_key = store_.create();
+ qi::rule<iterator, std::string()>& image_attribute_value = store_.create();
+
+ image =
+ (qi::eps(qbk_since(105u)) >> image_1_5) |
+ (qi::eps(qbk_before(105u)) >> image_1_4);
+
+ image_1_4 =
+ position
+ >> '$'
+ >> blank
+ >> *(qi::char_ - phrase_end)
+ >> &qi::lit(']')
+ ;
+
+ image_1_5 =
+ position
+ >> '$'
+ >> blank
+ >> image_filename
+ >> hard_space
+ >> image_attributes
+ >> &qi::lit(']')
+ ;
+
+ image_filename = qi::raw[
+ +(qi::char_ - (qi::space | phrase_end | '['))
+ >> *(
+ +qi::space
+ >> +(qi::char_ - (qi::space | phrase_end | '['))
+ )];
+
+ image_attributes = *(image_attribute >> space);
+
+ image_attribute =
+ '['
+ >> image_attribute_key
+ >> space
+ >> image_attribute_value
+ >> ']'
+ ;
+
+ image_attribute_key = *(qi::alnum | '_');
+ image_attribute_value = *(qi::char_ - (phrase_end | '['));
+
+ url =
+ '@'
+ >> qi::attr("url")
+ >> *(qi::char_ - (']' | qi::space))
+ >> ( &qi::lit(']')
+ | (hard_space >> phrase)
+ )
+ ;
+
+ qi::symbols<char, formatted_type>& link_symbol = store_.create();
+
+ link =
+ link_symbol
+ >> hard_space
+ >> *(qi::char_ - (']' | qi::space))
+ >> ( &qi::lit(']')
+ | (hard_space >> phrase)
+ )
+ ;
+
+ link_symbol.add
+ ("link", formatted_type("link"))
+ ("funcref", formatted_type("funcref"))
+ ("classref", formatted_type("classref"))
+ ("memberref", formatted_type("memberref"))
+ ("enumref", formatted_type("enumref"))
+ ("macroref", formatted_type("macroref"))
+ ("headerref", formatted_type("headerref"))
+ ("conceptref", formatted_type("conceptref"))
+ ("globalref", formatted_type("globalref"))
+ ;
+
+ anchor =
+ '#'
+ >> blank
+ >> *(qi::char_ - phrase_end)
+ >> qi::attr(nothing())
+ ;
+
+ source_mode.add
+ ("c++", quickbook::source_mode("c++"))
+ ("python", quickbook::source_mode("python"))
+ ("teletype", quickbook::source_mode("teletype"))
+ ;
+
+ qi::symbols<char, formatted_type>& format_symbol = store_.create();
+
+ formatted = format_symbol >> blank >> phrase;
+
+ format_symbol.add
+ ("*", "bold")
+ ("'", "italic")
+ ("_", "underline")
+ ("^", "teletype")
+ ("-", "strikethrough")
+ ("\"", "quote")
+ ("~", "replaceable")
+ ;
+
+ footnote =
+ "footnote"
+ >> qi::attr("footnote")
+ >> blank
+ >> phrase
+ ;
+
+ // Template call
+
+ qi::rule<iterator, std::vector<quickbook::template_value>()>& template_args = store_.create();
+ qi::rule<iterator, quickbook::template_value()>& template_arg_1_4 = store_.create();
+ qi::rule<iterator>& brackets_1_4 = store_.create();
+ qi::rule<iterator, quickbook::template_value()>& template_arg_1_5 = store_.create();
+ qi::rule<iterator>& brackets_1_5 = store_.create();
+
+ call_template =
+ position
+ >> qi::matches['`']
+ >> ( // Lookup the template name
+ (&qi::punct >> actions.templates.scope)
+ | (actions.templates.scope >> hard_space)
+ )
+ >> template_args
+ >> &qi::lit(']')
+ ;
+
+ template_args =
+ qi::eps(qbk_before(105u)) >> -(template_arg_1_4 % "..") |
+ qi::eps(qbk_since(105u)) >> -(template_arg_1_5 % "..");
+
+ template_arg_1_4 =
+ position >>
+ qi::raw[+(brackets_1_4 | ~qi::char_(']') - "..")]
+ ;
+
+ brackets_1_4 =
+ '[' >> +(brackets_1_4 | ~qi::char_(']') - "..") >> ']'
+ ;
+
+ template_arg_1_5 =
+ position >>
+ qi::raw[+(brackets_1_5 | '\\' >> qi::char_ | ~qi::char_("[]") - "..")]
+ ;
+
+ brackets_1_5 =
+ '[' >> +(brackets_1_5 | '\\' >> qi::char_ | ~qi::char_("[]")) >> ']'
+ ;
+
+ break_ =
+ position
+ >> "br"
+ >> qi::attr(nothing())
+ ;
+
+ phrase_end =
+ ']' |
+ qi::eps(ph::ref(no_eols)) >>
+ eol >> eol // Make sure that we don't go
+ ; // past a single block, except
+ // when preformatted.
+ }
+}
\ No newline at end of file


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk