Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63715 - branches/quickbook-1.5-spirit2
From: daniel_james_at_[hidden]
Date: 2010-07-06 19:16:16


Author: danieljames
Date: 2010-07-06 19:16:15 EDT (Tue, 06 Jul 2010)
New Revision: 63715
URL: http://svn.boost.org/trac/boost/changeset/63715

Log:
Use confix parser in several places.

I think it makes the rules a little more readable.
Text files modified:
   branches/quickbook-1.5-spirit2/block_grammar.cpp | 2
   branches/quickbook-1.5-spirit2/code_grammar.cpp | 30 +++---
   branches/quickbook-1.5-spirit2/code_snippet_grammar.cpp | 184 ++++++++++++++++-----------------------
   branches/quickbook-1.5-spirit2/doc_info_grammar.cpp | 51 ++++------
   branches/quickbook-1.5-spirit2/phrase_grammar.cpp | 19 +--
   branches/quickbook-1.5-spirit2/phrase_image_grammar.cpp | 9 +
   branches/quickbook-1.5-spirit2/syntax_highlight_grammar.cpp | 19 ++-
   branches/quickbook-1.5-spirit2/template_grammar.cpp | 18 ++-
   8 files changed, 151 insertions(+), 181 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-07-06 19:16:15 EDT (Tue, 06 Jul 2010)
@@ -95,7 +95,7 @@
             qi::eps[actions.phrase_push] >>
            *( common
             | (qi::char_ -
- ( qi::eol >> *qi::blank >> &(qi::char_('*') | '#')
+ ( qi::eol >> *qi::blank >> &qi::char_("*#")
                     | (eol >> *qi::blank >> qi::eol)
                     )
                 ) [actions.process]

Modified: branches/quickbook-1.5-spirit2/code_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/code_grammar.cpp 2010-07-06 19:16:15 EDT (Tue, 06 Jul 2010)
@@ -10,6 +10,7 @@
 
 #include <boost/spirit/include/qi_core.hpp>
 #include <boost/spirit/include/qi_eol.hpp>
+#include <boost/spirit/repository/include/qi_confix.hpp>
 #include "grammar_impl.hpp"
 #include "actions.hpp"
 #include "code.hpp"
@@ -19,6 +20,7 @@
 namespace quickbook
 {
     namespace qi = boost::spirit::qi;
+ namespace repo = boost::spirit::repository;
     namespace ph = boost::phoenix;
 
     struct code_grammar_local
@@ -56,29 +58,29 @@
         code_block = (local.code_block1 | local.code_block2) [actions.process];
 
         local.code_block1
- = "```"
- >> position [member_assign(&quickbook::code::position)]
+ = repo::confix("```", "```")
+ [ position [member_assign(&quickbook::code::position)]
                                                     [member_assign(&quickbook::code::flow, quickbook::code::inline_block)]
- >> qi::raw[*(qi::char_ - "```")] [member_assign(&quickbook::code::content)]
- >> "```"
- ;
+ >> qi::raw[*(qi::char_ - "```")] [member_assign(&quickbook::code::content)]
+ ]
+ ;
 
         local.code_block2
- = "``"
- >> position [member_assign(&quickbook::code::position)]
+ = repo::confix("``", "``")
+ [ position [member_assign(&quickbook::code::position)]
                                                     [member_assign(&quickbook::code::flow, quickbook::code::inline_block)]
- >> qi::raw[*(qi::char_ - "``")] [member_assign(&quickbook::code::content)]
- >> "``"
+ >> qi::raw[*(qi::char_ - "``")] [member_assign(&quickbook::code::content)]
+ ]
             ;
 
         inline_code = local.inline_code [actions.process];
 
- local.inline_code =
- '`'
- >> position [member_assign(&quickbook::code::position)]
+ local.inline_code
+ = repo::confix('`', '`')
+ [ position [member_assign(&quickbook::code::position)]
                                                     [member_assign(&quickbook::code::flow, quickbook::code::inline_)]
- >> local.inline_code_block [member_assign(&quickbook::code::content)]
- >> '`'
+ >> local.inline_code_block [member_assign(&quickbook::code::content)]
+ ]
             ;
 
         local.inline_code_block =

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-07-06 19:16:15 EDT (Tue, 06 Jul 2010)
@@ -11,6 +11,7 @@
 #include <boost/spirit/include/qi_eol.hpp>
 #include <boost/spirit/include/qi_eps.hpp>
 #include <boost/spirit/include/qi_attr.hpp>
+#include <boost/spirit/repository/include/qi_confix.hpp>
 #include "fwd.hpp"
 #include "code_snippet_types.hpp"
 #include "code_snippet_grammar.hpp"
@@ -19,7 +20,10 @@
 
 namespace quickbook
 {
+ // TODO: End of file as well as end of line?
+
     namespace qi = boost::spirit::qi;
+ namespace repo = boost::spirit::repository;
 
     struct python_code_snippet_grammar::rules
     {
@@ -39,8 +43,6 @@
             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)
@@ -54,9 +56,8 @@
         : actions(actions)
     {
         start_ =
- +(
- snippet [actions.output]
- | qi::char_
+ +( snippet [actions.output]
+ | qi::char_
             )
             ;
 
@@ -66,44 +67,36 @@
 
         snippet =
                 position [member_assign(&quickbook::code_snippet::position)]
- >> "#["
- >> qi::omit[*qi::space]
- >> identifier [member_assign(&quickbook::code_snippet::identifier)]
- >> qi::omit[*(code_elements - "#]")]
- >> "#]"
+ >> repo::confix("#[", "#]")
+ [ *qi::space
+ >> identifier [member_assign(&quickbook::code_snippet::identifier)]
+ >> *(!qi::lit("#]") >> code_elements)
+ ]
             ;
 
         code_elements =
                 escaped_comment [actions.process]
             | ignore
- | (qi::char_ - "#]") [actions.process]
+ | +qi::blank [actions.process]
+ | qi::char_ [actions.process]
+ ;
+
+ ignore
+ = ( repo::confix(*qi::blank >> "#<-", "#->" >> *qi::blank >> qi::eol)
+ [*(qi::char_ - "#->")]
+ | repo::confix("\"\"\"<-\"\"\"", "\"\"\"->\"\"\"")
+ [*(qi::char_ - "\"\"\"->\"\"\"")]
+ | repo::confix("\"\"\"<-", "->\"\"\"")
+ [*(qi::char_ - "->\"\"\"")]
+ )
             ;
 
- ignore =
- *qi::blank >> "#<-"
- >> (*(qi::char_ - "#->"))
- >> "#->" >> *qi::blank >> qi::eol
- | "\"\"\"<-\"\"\""
- >> (*(qi::char_ - "\"\"\"->\"\"\""))
- >> "\"\"\"->\"\"\""
- | "\"\"\"<-"
- >> (*(qi::char_ - "->\"\"\""))
- >> "->\"\"\""
- ;
-
- 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::omit[*qi::space >> "\"\"\"`"]
- >> (
- *(qi::char_ - "\"\"\"")
- )
- >> "\"\"\""
+ escaped_comment
+ = ( repo::confix(*qi::space >> "#`", qi::eol)
+ [*(qi::char_ - qi::eol)]
+ | repo::confix(*qi::space >> "\"\"\"`", "\"\"\"")
+ [*(qi::char_ - "\"\"\"")]
+ ) [member_assign(&quickbook::escaped_comment::content)]
             ;
     }
 
@@ -123,12 +116,8 @@
             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)
@@ -142,9 +131,8 @@
         : actions(actions)
     {
         start_ =
- +(
- snippet [actions.output]
- | qi::char_
+ +( snippet [actions.output]
+ | qi::char_
             )
             ;
 
@@ -152,21 +140,21 @@
             (qi::alpha | '_') >> *(qi::alnum | '_')
             ;
 
- snippet =
- position [member_assign(&quickbook::code_snippet::position)]
- >> "//["
- >> qi::omit[*qi::space]
- >> identifier [member_assign(&quickbook::code_snippet::identifier)]
- >> qi::omit[*(code_elements - "//]")]
- >> "//]"
- |
- position [member_assign(&quickbook::code_snippet::position)]
- >> "/*["
- >> qi::omit[*qi::space]
- >> identifier [member_assign(&quickbook::code_snippet::identifier)]
- >> qi::omit[*qi::space >> "*/"]
- >> qi::omit[*(code_elements - "/*]*")]
- >> "/*]*/"
+ snippet
+ = position [member_assign(&quickbook::code_snippet::position)]
+ >> ( repo::confix("//[", "//]")
+ [ *qi::space
+ >> identifier [member_assign(&quickbook::code_snippet::identifier)]
+ >> *(!qi::lit("//]") >> code_elements)
+ ]
+ | repo::confix("/*[", "/*]*/")
+ [ *qi::space
+ >> identifier [member_assign(&quickbook::code_snippet::identifier)]
+ >> *qi::space
+ >> "*/"
+ >> *(!qi::lit("/*]*/") >> code_elements)
+ ]
+ )
             ;
 
         code_elements =
@@ -174,60 +162,42 @@
             | ignore
             | line_callout [actions.process]
             | inline_callout [actions.process]
- | (qi::char_ - "//]" - "/*]*/") [actions.process]
+ | +qi::blank [actions.process]
+ | qi::char_ [actions.process]
             ;
 
- inline_callout =
- "/*<"
- >> position [member_assign(&quickbook::callout::position)]
+ inline_callout
+ = repo::confix("/*<", ">*/")
+ [ position [member_assign(&quickbook::callout::position)]
                                                 [member_assign(&quickbook::callout::role, "callout_bug")]
- >> inline_callout_body [member_assign(&quickbook::callout::content)]
- >> ">*/"
+ >> (*(qi::char_ - ">*/")) [member_assign(&quickbook::callout::content)]
+ ]
             ;
 
- inline_callout_body =
- *(qi::char_ - ">*/")
- ;
-
- line_callout =
- "/*<<"
- >> position [member_assign(&quickbook::callout::position)]
- >> line_callout_body [member_assign(&quickbook::callout::content)]
- >> ">>*/"
- >> qi::omit[*qi::space] [member_assign(&quickbook::callout::role, "line_callout_bug")]
- ;
-
- line_callout_body =
- *(qi::char_ - ">>*/")
- ;
-
- ignore =
- *qi::blank >> "//<-"
- >> (*(qi::char_ - "//->"))
- >> "//->" >> *qi::blank >> qi::eol
- | "/*<-*/"
- >> (*(qi::char_ - "/*->*/"))
- >> "/*->*/"
- | "/*<-"
- >> (*(qi::char_ - "->*/"))
- >> "->*/"
- ;
-
- 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::omit[*qi::space]
- >> "/*`"
- >> (
- *(qi::char_ - "*/")
- )
- >> "*/"
+ line_callout
+ = repo::confix("/*<<", ">>*/" >> *qi::space)
+ [ position [member_assign(&quickbook::callout::position)]
+ [member_assign(&quickbook::callout::role, "line_callout_bug")]
+ >> (*(qi::char_ - ">>*/")) [member_assign(&quickbook::callout::content)]
+ ]
+ ;
+
+ ignore
+ = repo::confix(*qi::blank >> "//<-", "//->" >> *qi::blank >> qi::eol)
+ [*(qi::char_ - "//->")]
+ | repo::confix("/*<-*/", "/*->*/")
+ [*(qi::char_ - "/*->*/")]
+ | repo::confix("/*<-", "->*/")
+ [*(qi::char_ - "->*/")]
+ ;
+
+ escaped_comment =
+ *qi::space
+ >> ( repo::confix("//`", qi::eol)
+ [*(qi::char_ - qi::eol)]
+ | repo::confix("/*`", "*/")
+ [*(qi::char_ - "*/")]
+ ) [member_assign(&quickbook::escaped_comment::content)]
             ;
     }
 }

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-07-06 19:16:15 EDT (Tue, 06 Jul 2010)
@@ -13,11 +13,11 @@
 #include <boost/spirit/include/qi_eol.hpp>
 #include <boost/spirit/include/qi_eps.hpp>
 #include <boost/spirit/include/qi_attr_cast.hpp>
+#include <boost/spirit/repository/include/qi_confix.hpp>
 #include <boost/spirit/include/phoenix_core.hpp>
 #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 "doc_info.hpp"
 #include "grammar_impl.hpp"
 #include "actions.hpp"
@@ -29,6 +29,7 @@
 namespace quickbook
 {
     namespace qi = boost::spirit::qi;
+ namespace repo = boost::spirit::repository;
     namespace ph = boost::phoenix;
     
     void set_quickbook_version(boost::fusion::vector<unsigned, unsigned> version)
@@ -81,47 +82,39 @@
         ;
         
         doc_info_details =
- space
- >> '[' >> space
- >> qi::raw[local.doc_types] [member_assign(&doc_info::doc_type)]
+ repo::confix(space >> '[' >> space, space >> ']' >> +qi::eol)
+ [ qi::raw[local.doc_types] [member_assign(&doc_info::doc_type)]
>> hard_space
>> qi::raw[
                     *(~qi::char_("[]") - qi::eol)
                 ] [member_assign(&doc_info::doc_title)]
>> local.quickbook_version
- >>
- *(
- space >> '[' >>
- (
- local.doc_version [member_assign(&doc_info::doc_version)]
- | local.doc_id [member_assign(&doc_info::doc_id)]
- | local.doc_dirname [member_assign(&doc_info::doc_dirname)]
- | local.doc_copyright [member_push(&doc_info::doc_copyrights)]
- | local.doc_purpose [member_assign(&doc_info::doc_purpose)]
- | local.doc_category [member_push(&doc_info::doc_categories)]
- | local.doc_authors [member_assign(&doc_info::doc_authors)]
- | local.doc_license [member_assign(&doc_info::doc_license)]
- | local.doc_last_revision
+ >> *repo::confix(space >> '[', space >> ']' >> +qi::eol)
+ [ local.doc_version [member_assign(&doc_info::doc_version)]
+ | local.doc_id [member_assign(&doc_info::doc_id)]
+ | local.doc_dirname [member_assign(&doc_info::doc_dirname)]
+ | local.doc_copyright [member_push(&doc_info::doc_copyrights)]
+ | local.doc_purpose [member_assign(&doc_info::doc_purpose)]
+ | local.doc_category [member_push(&doc_info::doc_categories)]
+ | local.doc_authors [member_assign(&doc_info::doc_authors)]
+ | local.doc_license [member_assign(&doc_info::doc_license)]
+ | local.doc_last_revision
                                             [member_assign(&doc_info::doc_last_revision)]
- // This has to be set in actions so that source code in phrases use the
- // correct encoding.
- | local.doc_source_mode [ph::ref(actions.state_.source_mode) = qi::_1]
- )
- >> space >> ']' >> +qi::eol
- )
- >> space >> ']' >> +qi::eol
+ // This has to be set in actions so that source code in phrases use the
+ // correct encoding.
+ | local.doc_source_mode [ph::ref(actions.state_.source_mode) = qi::_1]
+ ]
+ ]
             ;
 
         local.quickbook_version =
- ( space
- >> '['
- >> "quickbook"
+ repo::confix(space >> '[', space >> ']')
+ [ "quickbook"
>> hard_space
>> qi::uint_
>> '.'
>> uint2_t()
- >> space >> ']'
- ) [set_quickbook_version]
+ ] [set_quickbook_version]
             | position [default_quickbook_version]
             ;
 

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-07-06 19:16:15 EDT (Tue, 06 Jul 2010)
@@ -13,6 +13,7 @@
 #include <boost/spirit/include/qi_eoi.hpp>
 #include <boost/spirit/include/qi_eol.hpp>
 #include <boost/spirit/include/qi_eps.hpp>
+#include <boost/spirit/repository/include/qi_confix.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
 #include "grammar_impl.hpp"
 #include "phrase.hpp"
@@ -24,6 +25,7 @@
 namespace quickbook
 {
     namespace qi = boost::spirit::qi;
+ namespace repo = boost::spirit::repository;
     namespace ph = boost::phoenix;
 
     struct phrase_grammar_local
@@ -80,13 +82,11 @@
             ;
 
         local.phrase_markup =
- ( '['
- >> ( local.phrase_markup_impl
- | call_template
- | local.break_ [actions.process]
- )
- >> ']'
- )
+ repo::confix('[', ']')
+ [ local.phrase_markup_impl
+ | call_template
+ | local.break_ [actions.process]
+ ]
             ;
 
         local.phrase_markup_impl
@@ -155,10 +155,9 @@
             ;
 
         local.escape_markup =
- ("'''" >> -eol)
- >> (*(qi::char_ - "'''")) [member_assign(&quickbook::formatted::content)]
+ repo::confix("'''" >> -eol, "'''") [*(qi::char_ - "'''")]
+ [member_assign(&quickbook::formatted::content)]
                                                     [member_assign(&quickbook::formatted::type, "escape")]
- >> "'''"
             ;
 
         local.escape_unicode16 =

Modified: branches/quickbook-1.5-spirit2/phrase_image_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_image_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_image_grammar.cpp 2010-07-06 19:16:15 EDT (Tue, 06 Jul 2010)
@@ -10,6 +10,7 @@
 
 #include <boost/spirit/include/qi_core.hpp>
 #include <boost/spirit/include/qi_eps.hpp>
+#include <boost/spirit/repository/include/qi_confix.hpp>
 #include "grammar_impl.hpp"
 #include "phrase.hpp"
 #include "actions.hpp"
@@ -19,7 +20,7 @@
 namespace quickbook
 {
     namespace qi = boost::spirit::qi;
- namespace ph = boost::phoenix;
+ namespace repo = boost::spirit::repository;
 
     struct image_grammar_local
     {
@@ -69,11 +70,11 @@
         local.image_attributes = *(local.image_attribute >> space);
         
         local.image_attribute =
- '['
- >> local.image_attribute_key [member_assign(&std::pair<std::string, std::string>::first)]
+ repo::confix('[', ']')
+ [ local.image_attribute_key [member_assign(&std::pair<std::string, std::string>::first)]
>> space
>> local.image_attribute_value [member_assign(&std::pair<std::string, std::string>::second)]
- >> ']'
+ ]
             ;
             
         local.image_attribute_key = *(qi::alnum | '_');

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-07-06 19:16:15 EDT (Tue, 06 Jul 2010)
@@ -12,6 +12,7 @@
 #include <boost/spirit/include/qi_auxiliary.hpp>
 #include <boost/spirit/include/qi_string.hpp>
 #include <boost/spirit/include/qi_directive.hpp>
+#include <boost/spirit/repository/include/qi_confix.hpp>
 #include "grammar.hpp"
 #include "actions.hpp"
 #include "phrase.hpp"
@@ -23,6 +24,8 @@
 namespace quickbook
 {
     namespace qi = boost::spirit::qi;
+ namespace repo = boost::spirit::repository;
+
     using boost::spirit::unused_type;
 
     struct parse_escaped_impl
@@ -99,8 +102,8 @@
 
             comment
                 = qi::raw[
- qi::lit("//") >> *(qi::char_ - qi::eol) >> -qi::eol
- | qi::lit("/*") >> *(qi::char_ - "*/") >> -qi::lit("*/")
+ repo::confix("//", -qi::eol) [*(qi::char_ - qi::eol)]
+ | repo::confix("/*", -qi::lit("*/")) [*(qi::char_ - "*/")]
                     ] [member_assign(&code_token::text)]
                                                         [member_assign(&code_token::type, "comment")]
                 ;
@@ -139,7 +142,7 @@
             string_
                 = qi::raw[
                         -qi::no_case['l']
- >> '"' >> *(string_char - '"') >> -qi::lit('"')
+ >> repo::confix('"', -qi::lit('"')) [*(string_char - '"')]
                     ] [member_assign(&code_token::text)]
                                                         [member_assign(&code_token::type, "string")]
                 ;
@@ -147,7 +150,7 @@
             char_ =
                     qi::raw[
                         -qi::no_case['l']
- >> '\'' >> *(string_char - '\'') >> -qi::lit('\'')
+ >> repo::confix('\'', -qi::lit('\'')) [*(string_char - '\'')]
                     ] [member_assign(&code_token::text)]
                                                         [member_assign(&code_token::type, "char")]
                 ;
@@ -285,13 +288,13 @@
             string_char = ('\\' >> qi::char_) | (qi::char_ - '\\');
         
             short_string
- = qi::lit('\'') >> *(string_char - '\'') >> -qi::lit('\'') |
- qi::lit('"') >> *(string_char - '"') >> -qi::lit('"')
+ = repo::confix('\'', -qi::lit('\'')) [*(string_char - '\'')]
+ | repo::confix('"', -qi::lit('"')) [*(string_char - '"')]
                 ;
         
             long_string
- = qi::lit("'''") >> *(string_char - "'''") >> -qi::lit("'''") |
- qi::lit("\"\"\"") >> *(string_char - "\"\"\"") >> -qi::lit("\"\"\"")
+ = repo::confix("'''", -qi::lit("'''")) [*(string_char - "'''")]
+ | repo::confix("\"\"\"", -qi::lit("\"\"\"")) [*(string_char - "\"\"\"")]
                 ;
             
             number

Modified: branches/quickbook-1.5-spirit2/template_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/template_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/template_grammar.cpp 2010-07-06 19:16:15 EDT (Tue, 06 Jul 2010)
@@ -10,6 +10,7 @@
 
 #include <boost/spirit/include/qi_core.hpp>
 #include <boost/spirit/include/qi_eps.hpp>
+#include <boost/spirit/repository/include/qi_confix.hpp>
 #include "grammar_impl.hpp"
 #include "template.hpp"
 #include "actions.hpp"
@@ -19,6 +20,7 @@
 namespace quickbook
 {
     namespace qi = boost::spirit::qi;
+ namespace repo = boost::spirit::repository;
     
     struct template_grammar_local
     {
@@ -50,10 +52,8 @@
 
         local.define_template_params =
                 space
- >> '['
- >> *(space >> local.template_id)
- >> space
- >> ']'
+ >> repo::confix('[', ']')
+ [space >> *(local.template_id >> space)]
             ;
 
         local.template_body =
@@ -63,7 +63,7 @@
             ;
 
         local.template_body_recurse =
- *( ('[' >> local.template_body_recurse >> ']')
+ *( repo::confix('[', ']')[local.template_body_recurse]
                 | (qi::char_ - ']')
                 )
>> space
@@ -75,7 +75,7 @@
             | qi::repeat(1)[qi::punct - qi::char_("[]")]
             ;
 
- call_template = local.call_template [actions.process];
+ call_template = local.call_template [actions.process];
 
         local.call_template =
                 position [member_assign(&quickbook::call_template::position)]
@@ -99,7 +99,8 @@
             ;
 
         local.brackets_1_4 =
- '[' >> +(local.brackets_1_4 | ~qi::char_(']') - "..") >> ']'
+ repo::confix('[', ']')
+ [+(local.brackets_1_4 | ~qi::char_(']') - "..")]
             ;
 
         local.template_arg_1_5 =
@@ -109,7 +110,8 @@
             ;
 
         local.brackets_1_5 =
- '[' >> +(local.brackets_1_5 | '\\' >> qi::char_ | ~qi::char_("[]")) >> ']'
+ repo::confix('[', ']')
+ [+(local.brackets_1_5 | '\\' >> qi::char_ | ~qi::char_("[]"))]
             ;
     }
 }


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