Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62843 - branches/quickbook-1.5-spirit2
From: daniel_james_at_[hidden]
Date: 2010-06-12 09:03:50


Author: danieljames
Date: 2010-06-12 09:03:47 EDT (Sat, 12 Jun 2010)
New Revision: 62843
URL: http://svn.boost.org/trac/boost/changeset/62843

Log:
Directly assign members of structs, rather than using fusion.
Removed:
   branches/quickbook-1.5-spirit2/phrase_grammar.hpp
Text files modified:
   branches/quickbook-1.5-spirit2/block_grammar.cpp | 37 ++-----
   branches/quickbook-1.5-spirit2/block_markup_grammar.cpp | 172 ++++++++++++---------------------------
   branches/quickbook-1.5-spirit2/code.hpp | 8 -
   branches/quickbook-1.5-spirit2/code_snippet_grammar.cpp | 52 +++++++----
   branches/quickbook-1.5-spirit2/code_snippet_types.hpp | 19 ----
   branches/quickbook-1.5-spirit2/doc_info_grammar.cpp | 1
   branches/quickbook-1.5-spirit2/parse_types.hpp | 7 -
   branches/quickbook-1.5-spirit2/parse_utils.hpp | 46 ++++++---
   branches/quickbook-1.5-spirit2/phrase_grammar.cpp | 133 ++++++++++++++----------------
   branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp | 80 ++++++------------
   branches/quickbook-1.5-spirit2/syntax_highlight_grammar.cpp | 81 +++++++++---------
   11 files changed, 260 insertions(+), 376 deletions(-)

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-06-12 09:03:47 EDT (Sat, 12 Jun 2010)
@@ -13,26 +13,13 @@
 #include <boost/spirit/include/qi_eps.hpp>
 #include <boost/spirit/include/qi_eol.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/fusion/include/adapt_struct.hpp>
 #include "grammar_impl.hpp"
 #include "block.hpp"
 #include "template.hpp"
 #include "actions.hpp"
 #include "code.hpp"
 #include "misc_rules.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)
-)
+#include "parse_utils.hpp"
 
 namespace quickbook
 {
@@ -87,13 +74,11 @@
         qi::rule<iterator>& code_line = store_.create();
 
         code =
- position
- >> qi::raw[
- code_line
- >> *(*eol >> code_line)
- ]
+ position [member_assign(&quickbook::code::position)]
+ [member_assign(&quickbook::code::block, true)]
+ >> qi::raw[code_line >> *(*eol >> code_line)]
+ [member_assign(&quickbook::code::code)]
>> +eol
- >> qi::attr(true)
             ;
 
         code_line =
@@ -111,11 +96,11 @@
             ;
         
         list_item =
- position
+ position [member_assign(&quickbook::list_item::position)]
+ >> (*qi::blank) [member_assign(&quickbook::list_item::indent)]
+ >> qi::char_("*#") [member_assign(&quickbook::list_item::mark)]
>> *qi::blank
- >> qi::char_("*#")
- >> qi::omit[*qi::blank]
- >> list_item_content
+ >> list_item_content [member_assign(&quickbook::list_item::content)]
             ;
 
         list_item_content =
@@ -143,7 +128,9 @@
         qi::rule<iterator>& paragraph_end = store_.create();
         qi::symbols<>& paragraph_end_markups = store_.create();
 
- paragraph = paragraph_content >> qi::attr(nothing());
+ paragraph =
+ paragraph_content [member_assign(&quickbook::paragraph::content)]
+ ;
 
         paragraph_content =
                 qi::eps [actions.phrase_push]

Modified: branches/quickbook-1.5-spirit2/block_markup_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_markup_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_markup_grammar.cpp 2010-06-12 09:03:47 EDT (Sat, 12 Jun 2010)
@@ -14,85 +14,13 @@
 #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 "grammar_impl.hpp"
 #include "block.hpp"
 #include "template.hpp"
 #include "actions.hpp"
 #include "code.hpp"
 #include "misc_rules.hpp"
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::title,
- (quickbook::raw_source, raw)
- (std::string, content)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::begin_section,
- (boost::optional<quickbook::raw_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<quickbook::raw_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<quickbook::raw_string>, id)
- (std::string, path)
-)
+#include "parse_utils.hpp"
 
 namespace quickbook
 {
@@ -123,14 +51,13 @@
 
         begin_section =
                 space
- >> element_id
- >> title_phrase
+ >> element_id [member_assign(&quickbook::begin_section::id)]
+ >> title_phrase [member_assign(&quickbook::begin_section::content)]
             ;
 
         end_section =
                 space
- >> position
- >> qi::attr(nothing())
+ >> position [member_assign(&quickbook::end_section::position)]
             ;
 
         // Headings
@@ -146,7 +73,11 @@
             ("h6", heading(6) [actions.process])
             ("heading", heading(-1) [actions.process]);
 
- heading = qi::attr(qi::_r1) >> space >> title_phrase;
+ heading =
+ qi::attr(qi::_r1) [member_assign(&quickbook::heading::level)]
+ >> space
+ >> title_phrase [member_assign(&quickbook::heading::content)]
+ ;
         
         // Paragraph Blocks
 
@@ -166,7 +97,9 @@
             ;
 
         paragraph_block =
- qi::attr(qi::_r1) >> space >> inside_paragraph
+ qi::attr(qi::_r1) [member_assign(&quickbook::formatted::type)]
+ >> space
+ >> inside_paragraph [member_assign(&quickbook::formatted::content)]
             ;
 
         // Preformatted
@@ -175,11 +108,11 @@
 
         block_keyword_rules.add("pre", preformatted [actions.process]);
         
- preformatted %=
+ preformatted =
                 space [ph::ref(no_eols) = false]
+ [member_assign(&quickbook::formatted::type, "preformatted")]
>> -eol
- >> qi::attr(formatted_type("preformatted"))
- >> phrase_attr
+ >> phrase_attr [member_assign(&quickbook::formatted::content)]
>> qi::eps [ph::ref(no_eols) = true]
             ;
 
@@ -191,9 +124,9 @@
         
         def_macro =
                 space
- >> macro_identifier
+ >> macro_identifier [member_assign(&quickbook::def_macro::macro_identifier)]
>> blank
- >> phrase_attr
+ >> phrase_attr [member_assign(&quickbook::def_macro::content)]
             ;
 
         // Table
@@ -207,11 +140,14 @@
 
         table =
                 (&(*qi::blank >> qi::eol) | space)
- >> ((qi::eps(qbk_since(105u)) >> element_id) | qi::eps)
+ >> ((
+ qi::eps(qbk_since(105u))
+ >> element_id [member_assign(&quickbook::table::id)]
+ ) | qi::eps)
>> (&(*qi::blank >> qi::eol) | space)
- >> *(qi::char_ - eol)
+ >> (*(qi::char_ - eol)) [member_assign(&quickbook::table::title)]
>> +eol
- >> *table_row
+ >> (*table_row) [member_assign(&quickbook::table::rows)]
             ;
 
         table_row =
@@ -231,8 +167,8 @@
             ;
 
         table_cell_body =
- qi::attr(formatted_type("cell"))
- >> inside_paragraph
+ inside_paragraph [member_assign(&quickbook::formatted::content)]
+ [member_assign(&quickbook::formatted::type, "cell")]
             ;
 
         qi::rule<iterator, quickbook::variablelist()>& variablelist = store_.create();
@@ -246,11 +182,11 @@
 
         variablelist =
                 (&(*qi::blank >> qi::eol) | space)
- >> *(qi::char_ - eol)
+ >> (*(qi::char_ - eol)) [member_assign(&quickbook::variablelist::title)]
>> +eol
- >> *varlistentry
+ >> (*varlistentry) [member_assign(&quickbook::variablelist::entries)]
             ;
-
+
         varlistentry =
                 space
>> '['
@@ -271,8 +207,8 @@
             ;
 
         varlistterm_body =
- qi::attr(formatted_type("varlistterm"))
- >> phrase_attr
+ phrase_attr [member_assign(&quickbook::formatted::content)]
+ [member_assign(&quickbook::formatted::type, "varlistterm")]
             ;
 
         varlistitem =
@@ -284,8 +220,8 @@
             ;
 
         varlistitem_body =
- qi::attr(formatted_type("varlistitem"))
- >> inside_paragraph
+ inside_paragraph [member_assign(&quickbook::formatted::content)]
+ [member_assign(&quickbook::formatted::type, "varlistitem")]
             ;
 
         // xinclude
@@ -297,8 +233,7 @@
         // TODO: Why do these use phrase_end? It doesn't make any sense.
         xinclude =
                 space
- >> *(qi::char_ - phrase_end)
- >> qi::attr(nothing())
+ >> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::xinclude::path)]
             ;
 
         qi::rule<iterator, quickbook::include()>& include = store_.create();
@@ -314,8 +249,8 @@
                     ':'
>> include_id
>> space
- )
- >> *(qi::char_ - phrase_end)
+ ) [member_assign(&quickbook::include::id)]
+ >> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::include::path)]
             ;
 
         include_id = qi::raw[*((qi::alnum | '_') - qi::space)]
@@ -329,13 +264,13 @@
         
         import =
                 space
- >> *(qi::char_ - phrase_end)
- >> qi::attr(nothing())
+ >> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::import::path)]
             ;
 
         // Define Template
 
         qi::rule<iterator, quickbook::define_template()>& define_template = store_.create();
+ qi::rule<iterator, std::vector<std::string>()>& define_template_params = 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();
@@ -344,20 +279,22 @@
 
         define_template =
                 space
- >> template_id
- >> -(
- space
- >> '['
- >> *(space >> template_id)
- >> space
- >> ']'
- )
- >> template_body
+ >> template_id [member_assign(&quickbook::define_template::id)]
+ >> -define_template_params [member_assign(&quickbook::define_template::params)]
+ >> template_body [member_assign(&quickbook::define_template::body)]
+ ;
+
+ define_template_params =
+ space
+ >> '['
+ >> *(space >> template_id)
+ >> space
+ >> ']'
             ;
 
         template_body =
- position
- >> qi::raw[template_body_recurse]
+ position [member_assign(&quickbook::template_value::position)]
+ >> qi::raw[template_body_recurse] [member_assign(&quickbook::template_value::content)]
             ;
 
         template_body_recurse =
@@ -379,8 +316,8 @@
         // 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]
+ phrase_attr [member_assign(&quickbook::title::content)]
+ ] [member_assign(&quickbook::title::raw)]
             ;
 
         qi::rule<iterator, quickbook::formatted()>& inside_paragraph2 = store_.create();
@@ -395,8 +332,9 @@
             ;
 
         inside_paragraph2 =
- qi::attr(formatted_type("paragraph"))
- >> phrase_attr;
+ phrase_attr [member_assign(&quickbook::formatted::content)]
+ [member_assign(&quickbook::formatted::type, "paragraph")]
+ ;
 
         phrase_attr =
                 qi::eps [actions.phrase_push]

Modified: branches/quickbook-1.5-spirit2/code.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code.hpp (original)
+++ branches/quickbook-1.5-spirit2/code.hpp 2010-06-12 09:03:47 EDT (Sat, 12 Jun 2010)
@@ -11,7 +11,6 @@
 #define BOOST_SPIRIT_QUICKBOOK_CODE_HPP
 
 #include <string>
-#include <boost/fusion/include/adapt_struct.hpp>
 #include "fwd.hpp"
 
 namespace quickbook
@@ -28,11 +27,4 @@
         std::string& source_mode);
 }
 
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::code,
- (quickbook::file_position, position)
- (std::string, code)
- (bool, block)
-)
-
 #endif
\ No newline at end of file

Modified: branches/quickbook-1.5-spirit2/code_snippet_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code_snippet_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/code_snippet_grammar.cpp 2010-06-12 09:03:47 EDT (Sat, 12 Jun 2010)
@@ -15,6 +15,7 @@
 #include "code_snippet_types.hpp"
 #include "code_snippet_grammar.hpp"
 #include "misc_rules.hpp"
+#include "parse_utils.hpp"
 
 namespace quickbook
 {
@@ -38,6 +39,8 @@
             identifier;
         qi::rule<iterator, quickbook::escaped_comment()>
             escaped_comment;
+ qi::rule<iterator, std::string()>
+ escaped_comment_body;
     };
 
     python_code_snippet_grammar::python_code_snippet_grammar(actions_type & actions)
@@ -62,10 +65,10 @@
             ;
 
         snippet =
- position
+ position [member_assign(&quickbook::code_snippet::position)]
>> "#["
>> qi::omit[*qi::space]
- >> identifier
+ >> identifier [member_assign(&quickbook::code_snippet::identifier)]
>> qi::omit[*(code_elements - "#]")]
>> "#]"
             ;
@@ -88,19 +91,19 @@
>> "->\"\"\""
             ;
 
- escaped_comment =
+ escaped_comment = escaped_comment_body [member_assign(&quickbook::escaped_comment::content)];
+
+ escaped_comment_body =
                     qi::omit[*qi::space >> "#`"]
>> (
                         *(qi::char_ - qi::eol)
>> qi::eol
                     )
- >> qi::attr(nothing())
             | qi::omit[*qi::space >> "\"\"\"`"]
>> (
                         *(qi::char_ - "\"\"\"")
                     )
>> "\"\"\""
- >> qi::attr(nothing())
             ;
     }
 
@@ -120,8 +123,12 @@
             identifier;
         qi::rule<iterator, quickbook::callout()>
             inline_callout, line_callout;
+ qi::rule<iterator, std::string()>
+ inline_callout_body, line_callout_body;
         qi::rule<iterator, quickbook::escaped_comment()>
             escaped_comment;
+ qi::rule<iterator, std::string()>
+ escaped_comment_body;
     };
 
     cpp_code_snippet_grammar::cpp_code_snippet_grammar(actions_type & actions)
@@ -146,17 +153,17 @@
             ;
 
         snippet =
- position
+ position [member_assign(&quickbook::code_snippet::position)]
>> "//["
>> qi::omit[*qi::space]
- >> identifier
+ >> identifier [member_assign(&quickbook::code_snippet::identifier)]
>> qi::omit[*(code_elements - "//]")]
>> "//]"
             |
- position
+ position [member_assign(&quickbook::code_snippet::position)]
>> "/*["
>> qi::omit[*qi::space]
- >> identifier
+ >> identifier [member_assign(&quickbook::code_snippet::identifier)]
>> qi::omit[*qi::space >> "*/"]
>> qi::omit[*(code_elements - "/*]*")]
>> "/*]*/"
@@ -172,19 +179,26 @@
 
         inline_callout =
                 "/*<"
- >> position
- >> *(qi::char_ - ">*/")
+ >> position [member_assign(&quickbook::callout::position)]
+ [member_assign(&quickbook::callout::role, "callout_bug")]
+ >> inline_callout_body [member_assign(&quickbook::callout::content)]
>> ">*/"
- >> qi::attr("callout_bug")
+ ;
+
+ inline_callout_body =
+ *(qi::char_ - ">*/")
             ;
 
         line_callout =
                 "/*<<"
- >> position
- >> *(qi::char_ - ">>*/")
+ >> position [member_assign(&quickbook::callout::position)]
+ >> line_callout_body [member_assign(&quickbook::callout::content)]
>> ">>*/"
- >> qi::omit[*qi::space]
- >> qi::attr("line_callout_bug")
+ >> qi::omit[*qi::space] [member_assign(&quickbook::callout::role, "line_callout_bug")]
+ ;
+
+ line_callout_body =
+ *(qi::char_ - ">>*/")
             ;
 
         ignore =
@@ -199,21 +213,21 @@
>> "->*/"
             ;
 
- escaped_comment =
+ escaped_comment = escaped_comment_body [member_assign(&quickbook::escaped_comment::content)];
+
+ escaped_comment_body =
                 qi::omit[*qi::space]
>> "//`"
>> (
                     (*(qi::char_ - qi::eol))
>> qi::eol
                 )
- >> qi::attr(nothing())
             | qi::omit[*qi::space]
>> "/*`"
>> (
                     *(qi::char_ - "*/")
                 )
>> "*/"
- >> qi::attr(nothing())
             ;
     }
 }

Modified: branches/quickbook-1.5-spirit2/code_snippet_types.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code_snippet_types.hpp (original)
+++ branches/quickbook-1.5-spirit2/code_snippet_types.hpp 2010-06-12 09:03:47 EDT (Sat, 12 Jun 2010)
@@ -14,7 +14,6 @@
 
 #include <vector>
 #include <string>
-#include <boost/fusion/include/adapt_struct.hpp>
 #include <boost/spirit/include/support_unused.hpp>
 #include "fwd.hpp"
 #include "template.hpp"
@@ -41,24 +40,6 @@
     };
 }
 
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::code_snippet,
- (quickbook::file_position, position)
- (std::string, identifier)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::callout,
- (quickbook::file_position, position)
- (std::string, content)
- (char const*, role)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::escaped_comment,
- (std::string, content)
-)
-
 namespace quickbook
 {
     using boost::spirit::unused_type;

Modified: branches/quickbook-1.5-spirit2/doc_info_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/doc_info_grammar.cpp 2010-06-12 09:03:47 EDT (Sat, 12 Jun 2010)
@@ -17,6 +17,7 @@
 #include <boost/spirit/include/phoenix_container.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
 #include <boost/spirit/include/phoenix_fusion.hpp>
+#include <boost/spirit/include/phoenix_bind.hpp>
 #include <boost/fusion/include/std_pair.hpp>
 #include <boost/fusion/include/reverse_view.hpp>
 #include "doc_info.hpp"

Modified: branches/quickbook-1.5-spirit2/parse_types.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/parse_types.hpp (original)
+++ branches/quickbook-1.5-spirit2/parse_types.hpp 2010-06-12 09:03:47 EDT (Sat, 12 Jun 2010)
@@ -11,7 +11,6 @@
 #define BOOST_SPIRIT_QUICKBOOK_PARSE_TYPES_HPP
 
 #include <string>
-#include <boost/fusion/include/adapt_struct.hpp>
 #include "fwd.hpp"
 
 namespace quickbook
@@ -24,10 +23,4 @@
     };
 }
 
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::formatted,
- (quickbook::formatted_type, type)
- (std::string, content)
-)
-
 #endif
\ No newline at end of file

Modified: branches/quickbook-1.5-spirit2/parse_utils.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/parse_utils.hpp (original)
+++ branches/quickbook-1.5-spirit2/parse_utils.hpp 2010-06-12 09:03:47 EDT (Sat, 12 Jun 2010)
@@ -13,14 +13,12 @@
 #define BOOST_SPIRIT_QUICKBOOK_AS_STRING_HPP
 
 #include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_bind.hpp>
 #include <boost/spirit/include/qi_nonterminal.hpp>
 #include <string>
 
 namespace quickbook
 {
     namespace spirit = boost::spirit;
- namespace ph = boost::phoenix;
 
     // member_assign - action to assign the attribute to a member of the
     // rule's attributte.
@@ -31,12 +29,12 @@
     
         template <typename Context>
         void operator()(Member& attrib, Context& context, bool& pass) const {
- (ph::bind(mem_ptr_, spirit::_val) = attrib)(attrib, context, pass);
+ &(spirit::_val)(attrib,context,pass)->*mem_ptr_ = attrib;
         }
         
         template <typename Attrib, typename Context>
         void operator()(Attrib& attrib, Context& context, bool& pass) const {
- (ph::bind(mem_ptr_, spirit::_val) = attrib)(attrib, context, pass);
+ &(spirit::_val)(attrib,context,pass)->*mem_ptr_ = attrib;
         }
 
         Member Struct::*mem_ptr_;
@@ -48,22 +46,42 @@
     
         template <typename Context>
         void operator()(std::string& attrib, Context& context, bool& pass) const {
- (ph::bind(mem_ptr_, spirit::_val) = attrib)(attrib, context, pass);
+ &(spirit::_val)(attrib,context,pass)->*mem_ptr_ = attrib;
         }
 
         template <typename Attrib, typename Context>
         void operator()(Attrib& attrib, Context& context, bool& pass) const {
- (ph::bind(mem_ptr_, spirit::_val) = std::string(attrib.begin(), attrib.end()))(attrib, context, pass);
+ &(spirit::_val)(attrib,context,pass)->*mem_ptr_ =
+ std::string(attrib.begin(), attrib.end());
         }
         
         std::string Struct::*mem_ptr_;
     };
     
     template <typename Struct, typename Member>
+ struct fixed_member_assign_type {
+ fixed_member_assign_type(Member Struct::*mem_ptr, Member const& m)
+ : mem_ptr_(mem_ptr), m_(m) {}
+
+ template <typename Attrib, typename Context>
+ void operator()(Attrib& attrib, Context& context, bool& pass) const {
+ &(spirit::_val)(attrib,context,pass)->*mem_ptr_ = m_;
+ }
+
+ Member Struct::*mem_ptr_;
+ Member m_;
+ };
+
+ template <typename Struct, typename Member>
     member_assign_type<Struct, Member> member_assign(Member Struct::*mem_ptr) {
         return member_assign_type<Struct, Member>(mem_ptr);
     }
 
+ template <typename Struct, typename Member, typename Value>
+ fixed_member_assign_type<Struct, Member> member_assign(Member Struct::*mem_ptr, Value const& m) {
+ return fixed_member_assign_type<Struct, Member>(mem_ptr, m);
+ }
+
     // member_push - action to push the attribute to a member of the
     // rule's attributte.
 
@@ -73,14 +91,13 @@
     
         template <typename Context>
         void operator()(Member& attrib, Context& context, bool& pass) const {
- ph::bind(mem_ptr_, spirit::_val)(attrib, context, pass)
- .push_back(attrib);
+ (&(spirit::_val)(attrib,context,pass)->*mem_ptr_).push_back(attrib);
         }
         
         template <typename Attrib, typename Context>
         void operator()(Attrib& attrib, Context& context, bool& pass) const {
- ph::bind(mem_ptr_, spirit::_val)(attrib, context, pass)
- .push_back(typename Member::value_type(attrib));
+ (&(spirit::_val)(attrib,context,pass)->*mem_ptr_).push_back(
+ typename Member::value_type(attrib));
         }
 
         Member Struct::*mem_ptr_;
@@ -92,14 +109,13 @@
     
         template <typename Context>
         void operator()(std::string& attrib, Context& context, bool& pass) const {
- ph::bind(mem_ptr_, spirit::_val)(attrib, context, pass)
- .push_back(attrib);
+ (&(spirit::_val)(attrib,context,pass)->*mem_ptr_).push_back(attrib);
         }
 
         template <typename Attrib, typename Context>
         void operator()(Attrib& attrib, Context& context, bool& pass) const {
- ph::bind(mem_ptr_, spirit::_val)(attrib, context, pass)
- .push_back(std::string(attrib.begin(), attrib.end()));
+ (&(spirit::_val)(attrib,context,pass)->*mem_ptr_).push_back(
+ std::string(attrib.begin(), attrib.end()));
         }
         
         std::vector<std::string> Struct::*mem_ptr_;
@@ -109,8 +125,6 @@
     member_push_type<Struct, Member> member_push(Member Struct::*mem_ptr) {
         return member_push_type<Struct, Member>(mem_ptr);
     }
-
-
 }
 
 #endif

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-06-12 09:03:47 EDT (Sat, 12 Jun 2010)
@@ -13,38 +13,13 @@
 #include <boost/spirit/include/qi_eoi.hpp>
 #include <boost/spirit/include/qi_eps.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 "grammar_impl.hpp"
+#include "phrase.hpp"
 #include "code.hpp"
 #include "actions.hpp"
 #include "template.hpp"
 #include "misc_rules.hpp"
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::simple_markup,
- (char, symbol)
- (std::string, raw_content)
-)
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::unicode_char,
- (std::string, value)
-)
-
-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)
-)
+#include "parse_utils.hpp"
 
 namespace quickbook
 {
@@ -58,6 +33,7 @@
         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, std::string(char)>& simple_format_body = store_.create();
         qi::rule<iterator>& escape = store_.create();
         qi::rule<iterator, quickbook::call_template()>& call_template = store_.create();
         qi::rule<iterator, quickbook::break_()>& break_ = store_.create();
@@ -123,13 +99,13 @@
         qi::rule<iterator>& brackets_1_5 = store_.create();
 
         call_template =
- position
- >> qi::matches['`']
+ position [member_assign(&quickbook::call_template::position)]
+ >> qi::matches['`'] [member_assign(&quickbook::call_template::escape)]
>> ( // Lookup the template name
                     (&qi::punct >> actions.templates.scope)
                 | (actions.templates.scope >> hard_space)
- )
- >> template_args
+ ) [member_assign(&quickbook::call_template::symbol)]
+ >> template_args [member_assign(&quickbook::call_template::args)]
>> &qi::lit(']')
             ;
 
@@ -138,8 +114,9 @@
             qi::eps(qbk_since(105u)) >> -(template_arg_1_5 % "..");
 
         template_arg_1_4 =
- position >>
- qi::raw[+(brackets_1_4 | ~qi::char_(']') - "..")]
+ position [member_assign(&quickbook::template_value::position)]
+ >> qi::raw[+(brackets_1_4 | ~qi::char_(']') - "..")]
+ [member_assign(&quickbook::template_value::content)]
             ;
 
         brackets_1_4 =
@@ -147,8 +124,9 @@
             ;
 
         template_arg_1_5 =
- position >>
- qi::raw[+(brackets_1_5 | '\\' >> qi::char_ | ~qi::char_("[]") - "..")]
+ position [member_assign(&quickbook::template_value::position)]
+ >> qi::raw[+(brackets_1_5 | '\\' >> qi::char_ | ~qi::char_("[]") - "..")]
+ [member_assign(&quickbook::template_value::content)]
             ;
 
         brackets_1_5 =
@@ -156,69 +134,83 @@
             ;
 
         break_ =
- position
+ position [member_assign(&quickbook::break_::position)]
>> "br"
- >> qi::attr(nothing())
             ;
 
+ qi::rule<iterator, std::string()>& code_block1 = store_.create();
+ qi::rule<iterator, std::string()>& code_block2 = store_.create();
+ qi::rule<iterator, std::string()>& inline_code_block = store_.create();
+
         code_block =
                 (
                     "```"
- >> position
- >> qi::raw[*(qi::char_ - "```")]
+ >> position [member_assign(&quickbook::code::position)]
+ [member_assign(&quickbook::code::block, true)]
+ >> code_block1 [member_assign(&quickbook::code::code)]
>> "```"
- >> qi::attr(true)
                 )
             | (
                     "``"
- >> position
- >> qi::raw[*(qi::char_ - "``")]
+ >> position [member_assign(&quickbook::code::position)]
+ [member_assign(&quickbook::code::block, true)]
+ >> code_block2 [member_assign(&quickbook::code::code)]
>> "``"
- >> qi::attr(true)
                 )
             ;
 
+ code_block1 = qi::raw[*(qi::char_ - "```")];
+ code_block2 = qi::raw[*(qi::char_ - "``")];
+
         inline_code =
                 '`'
- >> position
- >> qi::raw
- [ *( qi::char_ -
- ( '`'
- | (eol >> eol) // Make sure that we don't go
- ) // past a single block
- )
- >> &qi::lit('`')
- ]
+ >> position [member_assign(&quickbook::code::position)]
+ [member_assign(&quickbook::code::block, false)]
+ >> inline_code_block [member_assign(&quickbook::code::code)]
>> '`'
- >> qi::attr(false)
+ ;
+
+ inline_code_block =
+ qi::raw
+ [ *( qi::char_ -
+ ( '`'
+ | (eol >> eol) // Make sure that we don't go
+ ) // past a single block
+ )
+ >> &qi::lit('`')
+ ]
             ;
 
         qi::rule<iterator>& simple_phrase_end = store_.create();
 
- simple_format %=
+ simple_format =
                 qi::char_("*/_=") [qi::_a = qi::_1]
- >> qi::raw
+ >> simple_format_body(qi::_a) [member_assign(&quickbook::simple_markup::raw_content)]
+ >> qi::char_(qi::_a) [member_assign(&quickbook::simple_markup::symbol)]
+ ;
+
+ simple_format_body =
+ qi::raw
                 [ ( ( qi::graph // A single char. e.g. *c*
- >> &( qi::char_(qi::_a)
+ >> &( qi::char_(qi::_r1)
>> (qi::space | qi::punct | qi::eoi)
                             )
                         )
                     |
                         ( qi::graph // qi::graph must follow qi::lit(qi::_r1)
>> *( qi::char_ -
- ( (qi::graph >> qi::lit(qi::_a))
+ ( (qi::graph >> qi::lit(qi::_r1))
                                 | simple_phrase_end // Make sure that we don't go
                                 ) // past a single block
                             )
>> qi::graph // qi::graph must precede qi::lit(qi::_r1)
- >> &( qi::char_(qi::_a)
+ >> &( qi::char_(qi::_r1)
>> (qi::space | qi::punct | qi::eoi)
                             )
                         )
                     )
                 ]
- >> qi::omit[qi::char_(qi::_a)]
- ;
+ ;
 
         simple_phrase_end = '[' | phrase_end;
 
@@ -239,34 +231,31 @@
             ;
         
         escape_break =
- position
+ position [member_assign(&quickbook::break_::position)]
>> "\\n"
- >> qi::attr(nothing())
             ;
 
         escape_punct =
- qi::attr(formatted_type(""))
- >> '\\'
- >> qi::repeat(1)[qi::punct]
+ '\\'
+ >> qi::repeat(1)[qi::punct] [member_assign(&quickbook::formatted::content)]
+ [member_assign(&quickbook::formatted::type, "")]
             ;
 
         escape_markup =
                 ("'''" >> -eol)
- >> qi::attr("escape")
- >> *(qi::char_ - "'''")
+ >> (*(qi::char_ - "'''")) [member_assign(&quickbook::formatted::content)]
+ [member_assign(&quickbook::formatted::type, "escape")]
>> "'''"
             ;
 
         escape_unicode16 =
                 "\\u"
- > qi::raw[qi::repeat(4)[qi::xdigit]]
- > qi::attr(nothing())
+ > qi::raw[qi::repeat(4)[qi::xdigit]] [member_assign(&quickbook::unicode_char::value)]
             ;
 
         escape_unicode32 =
                 "\\U"
- > qi::raw[qi::repeat(8)[qi::xdigit]]
- > qi::attr(nothing())
+ > qi::raw[qi::repeat(8)[qi::xdigit]] [member_assign(&quickbook::unicode_char::value)]
             ;
 
         phrase_end =

Deleted: branches/quickbook-1.5-spirit2/phrase_grammar.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_grammar.hpp 2010-06-12 09:03:47 EDT (Sat, 12 Jun 2010)
+++ (empty file)
@@ -1,18 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- http://spirit.sourceforge.net/
-
- Use, modification and distribution is subject to the Boost Software
- License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-
-#include <boost/fusion/include/adapt_struct.hpp>
-#include "grammar_impl.hpp"
-#include "phrase.hpp"
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::break_,
- (quickbook::file_position, position)
-)
\ No newline at end of file

Modified: branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp 2010-06-12 09:03:47 EDT (Sat, 12 Jun 2010)
@@ -12,42 +12,12 @@
 #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 "grammar_impl.hpp"
+#include "phrase.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::callout_link,
- (std::string, role)
- (std::string, identifier)
-)
+#include "parse_utils.hpp"
 
 namespace quickbook
 {
@@ -66,10 +36,9 @@
         phrase_symbol_rules.add("[callout]", callout_link [actions.process]);
 
         callout_link =
- *~qi::char_(' ')
+ (*~qi::char_(' ')) [member_assign(&quickbook::callout_link::role)]
>> ' '
- >> *~qi::char_(']')
- >> qi::attr(nothing())
+ >> (*~qi::char_(']')) [member_assign(&quickbook::callout_link::identifier)]
             ;
 
         // Conditional Phrase
@@ -80,8 +49,8 @@
 
         cond_phrase =
                 blank
- >> macro_identifier
- >> -phrase
+ >> macro_identifier [member_assign(&quickbook::cond_phrase::macro_id)]
+ >> -phrase [member_assign(&quickbook::cond_phrase::content)]
             ;
 
         // Images
@@ -102,18 +71,18 @@
             (qi::eps(qbk_before(105u)) >> image_1_4);
         
         image_1_4 =
- position
+ position [member_assign(&quickbook::image::position)]
>> blank
- >> *(qi::char_ - phrase_end)
+ >> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::image::image_filename)]
>> &qi::lit(']')
             ;
         
         image_1_5 =
- position
+ position [member_assign(&quickbook::image::position)]
>> blank
- >> image_filename
+ >> image_filename [member_assign(&quickbook::image::image_filename)]
>> hard_space
- >> image_attributes
+ >> image_attributes [member_assign(&quickbook::image::attributes)]
>> &qi::lit(']')
             ;
 
@@ -128,9 +97,9 @@
         
         image_attribute =
                 '['
- >> image_attribute_key
+ >> image_attribute_key [member_assign(&std::pair<std::string, std::string>::first)]
>> space
- >> image_attribute_value
+ >> image_attribute_value [member_assign(&std::pair<std::string, std::string>::second)]
>> ']'
             ;
             
@@ -143,10 +112,10 @@
         
         phrase_symbol_rules.add("@", url [actions.process]);
 
- url = qi::attr("url")
- >> *(qi::char_ - (']' | qi::space))
+ url = (*(qi::char_ - (']' | qi::space))) [member_assign(&quickbook::link::destination)]
+ [member_assign(&quickbook::link::type, "url")]
>> ( &qi::lit(']')
- | (hard_space >> phrase)
+ | (hard_space >> phrase) [member_assign(&quickbook::link::content)]
                 )
             ;
 
@@ -169,11 +138,11 @@
             ;
 
         link =
- qi::attr(qi::_r1)
+ qi::attr(qi::_r1) [member_assign(&quickbook::link::type)]
>> space
- >> *(qi::char_ - (']' | qi::space))
+ >> (*(qi::char_ - (']' | qi::space))) [member_assign(&quickbook::link::destination)]
>> ( &qi::lit(']')
- | (hard_space >> phrase)
+ | (hard_space >> phrase) [member_assign(&quickbook::link::content)]
                 )
             ;
 
@@ -185,8 +154,7 @@
 
         anchor =
                 blank
- >> *(qi::char_ - phrase_end)
- >> qi::attr(nothing())
+ >> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::anchor::id)]
             ;
 
         // Source Mode
@@ -215,7 +183,11 @@
             ("footnote", formatted(formatted_type("footnote")) [actions.process])
             ;
 
- formatted = qi::attr(qi::_r1) >> blank >> phrase;
+ formatted =
+ qi::attr(qi::_r1) [member_assign(&quickbook::formatted::type)]
+ >> blank
+ >> phrase [member_assign(&quickbook::formatted::content)]
+ ;
 
         // phrase_end
 

Modified: branches/quickbook-1.5-spirit2/syntax_highlight_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/syntax_highlight_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/syntax_highlight_grammar.cpp 2010-06-12 09:03:47 EDT (Sat, 12 Jun 2010)
@@ -12,18 +12,12 @@
 #include <boost/spirit/include/qi_auxiliary.hpp>
 #include <boost/spirit/include/qi_string.hpp>
 #include <boost/spirit/include/qi_directive.hpp>
-#include <boost/fusion/include/adapt_struct.hpp>
 #include "grammar.hpp"
 #include "actions.hpp"
 #include "phrase.hpp"
 #include "utils.hpp"
 #include "syntax_highlight.hpp"
-
-BOOST_FUSION_ADAPT_STRUCT(
- quickbook::code_token,
- (std::string, text)
- (char const*, type)
-)
+#include "parse_utils.hpp"
 
 namespace quickbook
 {
@@ -89,28 +83,31 @@
 
             space
                 = qi::raw[+qi::space]
- >> qi::attr("space");
+ [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "space")]
+ ;
 
             preprocessor
                 = qi::raw[
                         '#' >> *qi::space
>> ((qi::alpha | '_') >> *(qi::alnum | '_'))
- ]
- >> qi::attr("preprocessor")
+ ] [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "preprocessor")]
                 ;
 
             comment
                 = qi::raw[
                         qi::lit("//") >> *(qi::char_ - qi::eol) >> -qi::eol
                     | qi::lit("/*") >> *(qi::char_ - "*/") >> -qi::lit("*/")
- ]
- >> qi::attr("comment")
+ ] [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "comment")]
                 ;
 
             keyword
                 = qi::raw[keyword_ >> !(qi::alnum | '_')]
- >> qi::attr("keyword")
- ; // make sure we recognize whole words only
+ [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "keyword")]
+ ;
 
             keyword_
                 = "and_eq", "and", "asm", "auto", "bitand", "bitor",
@@ -130,8 +127,9 @@
                 ;
 
             special
- = +qi::char_("~!%^&*()+={[}]:;,<.>?/|\\-")
- >> qi::attr("special")
+ = (+qi::char_("~!%^&*()+={[}]:;,<.>?/|\\-"))
+ [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "special")]
                 ;
 
             string_char = ('\\' >> qi::char_) | (qi::char_ - '\\');
@@ -140,16 +138,16 @@
                 = qi::raw[
                         -qi::no_case['l']
>> '"' >> *(string_char - '"') >> -qi::lit('"')
- ]
- >> qi::attr("string")
+ ] [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "string")]
                 ;
 
             char_ =
                     qi::raw[
                         -qi::no_case['l']
>> '\'' >> *(string_char - '\'') >> -qi::lit('\'')
- ]
- >> qi::attr("char")
+ ] [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "char")]
                 ;
 
             number
@@ -161,19 +159,20 @@
                         | qi::long_double
                         )
>> *qi::no_case[qi::char_("ldfu")]
- ]
- >> qi::attr("number")
+ ] [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "number")]
                 ;
 
             identifier
                 = qi::raw[(qi::alpha | '_') >> *(qi::alnum | '_')]
- >> qi::attr("identifier")
+ [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "identifier")]
                 ;
             
             // TODO: warn user?
             unexpected
- = qi::raw[qi::char_]
- >> qi::attr("error")
+ = qi::raw[qi::char_] [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "error")]
                 ;
         }
 
@@ -229,19 +228,21 @@
                 ;
 
             space
- = qi::raw[+qi::space]
- >> qi::attr("space");
+ = qi::raw[+qi::space] [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "space")]
+ ;
 
             comment
                 = qi::raw[
                         '#' >> *(qi::char_ - qi::eol) >> -qi::eol
- ]
- >> qi::attr("comment")
+ ] [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "comment")]
                 ;
 
             keyword
                 = qi::raw[keyword_ >> !(qi::alnum | '_')]
- >> qi::attr("keyword")
+ [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "keyword")]
                 ; // make sure we recognize whole words only
 
             keyword_
@@ -261,8 +262,9 @@
                 ;
 
             special
- = +qi::char_("~!%^&*()+={[}]:;,<.>/|\\-")
- >> qi::attr("special")
+ = (+qi::char_("~!%^&*()+={[}]:;,<.>/|\\-"))
+ [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "special")]
                 ;
 
             string_prefix
@@ -273,8 +275,8 @@
                 = qi::raw[
                         -string_prefix
>> (long_string | short_string)
- ]
- >> qi::attr("string")
+ ] [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "string")]
                 ;
 
             string_char = ('\\' >> qi::char_) | (qi::char_ - '\\');
@@ -297,19 +299,20 @@
                         | qi::long_double
                         )
>> *qi::no_case[qi::char_("lj")]
- ]
- >> qi::attr("number")
+ ] [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "number")]
                 ;
 
             identifier
                 = qi::raw[(qi::alpha | '_') >> *(qi::alnum | '_')]
- >> qi::attr("identifier")
+ [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "identifier")]
                 ;
 
             // TODO: warn user?
             unexpected
- = qi::raw[qi::char_]
- >> qi::attr("error")
+ = qi::raw[qi::char_] [member_assign(&code_token::text)]
+ [member_assign(&code_token::type, "error")]
                 ;
         }
 


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