Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65283 - branches/quickbook-1.5-spirit2/src
From: dnljms_at_[hidden]
Date: 2010-09-05 05:32:25


Author: danieljames
Date: 2010-09-05 05:32:22 EDT (Sun, 05 Sep 2010)
New Revision: 65283
URL: http://svn.boost.org/trac/boost/changeset/65283

Log:
Store rules by pointer in the Nablieck trick.
Text files modified:
   branches/quickbook-1.5-spirit2/src/block_grammar.cpp | 10 +++---
   branches/quickbook-1.5-spirit2/src/block_markup_grammar.cpp | 57 ++++++++++++++++++++++++++-------------
   branches/quickbook-1.5-spirit2/src/block_section_grammar.cpp | 36 +++++++++++++++++-------
   branches/quickbook-1.5-spirit2/src/block_table_grammar.cpp | 10 +++++-
   branches/quickbook-1.5-spirit2/src/grammar_impl.hpp | 4 +-
   branches/quickbook-1.5-spirit2/src/template_grammar.cpp | 5 ++
   6 files changed, 82 insertions(+), 40 deletions(-)

Modified: branches/quickbook-1.5-spirit2/src/block_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/src/block_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/src/block_grammar.cpp 2010-09-05 05:32:22 EDT (Sun, 05 Sep 2010)
@@ -28,8 +28,8 @@
     struct block_grammar_local
     {
         qi::rule<iterator> blocks;
- qi::rule<iterator, qi::locals<qi::rule<iterator> > > block_markup;
- qi::rule<iterator, qi::rule<iterator>()> block_markup_start;
+ qi::rule<iterator, qi::locals<qi::rule<iterator>*> > block_markup;
+ qi::rule<iterator, qi::rule<iterator>*()> block_markup_start;
         qi::rule<iterator, quickbook::list()> list;
         qi::rule<iterator, quickbook::list_item()> list_item;
         qi::rule<iterator, std::string()> list_item_content;
@@ -72,7 +72,7 @@
 
         local.block_markup
             = local.block_markup_start [qi::_a = qi::_1]
- >> lazy(qi::_a)
+ >> lazy(*qi::_a)
>> ( (space >> ']' >> +eol)
                 | error
                 )
@@ -81,8 +81,8 @@
         local.block_markup_start
             = '['
>> space
- >> ( block_keyword_rules >> !(qi::alnum | '_')
- | block_symbol_rules
+ >> ( block_keyword_rules [qi::_val = qi::_1] >> !(qi::alnum | '_')
+ | block_symbol_rules [qi::_val = qi::_1]
                 )
             ;
 

Modified: branches/quickbook-1.5-spirit2/src/block_markup_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/src/block_markup_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/src/block_markup_grammar.cpp 2010-09-05 05:32:22 EDT (Sun, 05 Sep 2010)
@@ -35,12 +35,16 @@
     struct block_markup_grammar_local
     {
         qi::rule<iterator, quickbook::block_formatted(formatted_type)> paragraph_block;
- qi::rule<iterator, quickbook::block_formatted()> preformatted;
+ qi::rule<iterator, quickbook::block_formatted()> preformatted_impl;
         qi::rule<iterator, quickbook::def_macro()> def_macro;
         qi::rule<iterator, quickbook::xinclude()> xinclude;
         qi::rule<iterator, quickbook::include()> include;
         qi::rule<iterator, raw_string()> include_id;
         qi::rule<iterator, quickbook::import()> import;
+
+ qi::rule<iterator> blurb, warning, caution, important, note, tip;
+ qi::rule<iterator> blockquote;
+ qi::rule<iterator> preformatted, def, xinclude_block, include_block, import_block;
     };
 
     void quickbook_grammar::impl::init_block_markup()
@@ -50,18 +54,23 @@
         // Paragraph Blocks
 
         block_keyword_rules.add
- ("blurb", local.paragraph_block(formatted_type("blurb")) [actions.process])
- ("warning", local.paragraph_block(formatted_type("warning")) [actions.process])
- ("caution", local.paragraph_block(formatted_type("caution")) [actions.process])
- ("important", local.paragraph_block(formatted_type("important")) [actions.process])
- ("note", local.paragraph_block(formatted_type("note")) [actions.process])
- ("tip", local.paragraph_block(formatted_type("tip")) [actions.process])
- ;
-
- block_symbol_rules.add
- (":", local.paragraph_block(formatted_type("blockquote")) [actions.process])
- ;
+ ("blurb", &local.blurb)
+ ("warning", &local.warning)
+ ("caution", &local.caution)
+ ("important", &local.important)
+ ("note", &local.note)
+ ("tip", &local.tip)
+ ;
+
+ local.blurb = local.paragraph_block(formatted_type("blurb")) [actions.process];
+ local.warning = local.paragraph_block(formatted_type("warning")) [actions.process];
+ local.caution = local.paragraph_block(formatted_type("caution")) [actions.process];
+ local.important = local.paragraph_block(formatted_type("important")) [actions.process];
+ local.note = local.paragraph_block(formatted_type("note")) [actions.process];
+ local.tip = local.paragraph_block(formatted_type("tip")) [actions.process];
 
+ block_symbol_rules.add(":", &local.blockquote);
+ local.blockquote = local.paragraph_block(formatted_type("blockquote")) [actions.process];
         local.paragraph_block =
                 qi::attr(qi::_r1) [member_assign(&quickbook::block_formatted::type)]
>> space
@@ -70,9 +79,11 @@
 
         // Preformatted
 
- block_keyword_rules.add("pre", local.preformatted [actions.process]);
+ block_keyword_rules.add("pre", &local.preformatted);
+
+ local.preformatted = local.preformatted_impl [actions.process];
         
- local.preformatted =
+ local.preformatted_impl =
                 space [ph::ref(no_eols) = false]
                                                 [member_assign(&quickbook::block_formatted::type, "preformatted")]
>> -eol
@@ -82,7 +93,9 @@
 
         // Define Macro
 
- block_keyword_rules.add("def", local.def_macro[actions.process]);
+ block_keyword_rules.add("def", &local.def);
+
+ local.def = local.def_macro[actions.process];
         
         local.def_macro =
                 space
@@ -93,7 +106,9 @@
 
         // xinclude
 
- block_keyword_rules.add("xinclude", local.xinclude[actions.process]);
+ block_keyword_rules.add("xinclude", &local.xinclude_block);
+
+ local.xinclude_block = local.xinclude[actions.process];
 
         // TODO: Why do these use phrase_end? It doesn't make any sense.
         local.xinclude =
@@ -101,10 +116,12 @@
>> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::xinclude::path)]
             ;
         
- block_keyword_rules.add("include", local.include[actions.process]);
-
         // Include
 
+ block_keyword_rules.add("include", &local.include_block);
+
+ local.include_block = local.include[actions.process];
+
         local.include =
                 space
>> -(
@@ -119,7 +136,9 @@
 
         // Import
 
- block_keyword_rules.add("import", local.import[actions.process]);
+ block_keyword_rules.add("import", &local.import_block);
+
+ local.import_block = local.import[actions.process];
         
         local.import =
                 space

Modified: branches/quickbook-1.5-spirit2/src/block_section_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/src/block_section_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/src/block_section_grammar.cpp 2010-09-05 05:32:22 EDT (Sun, 05 Sep 2010)
@@ -29,7 +29,10 @@
         qi::rule<iterator, quickbook::title()> title_phrase;
         qi::rule<iterator, quickbook::begin_section()> begin_section;
         qi::rule<iterator, quickbook::end_section()> end_section;
- qi::rule<iterator, quickbook::heading(int)> heading;
+ qi::rule<iterator, quickbook::heading(int)> heading_impl;
+
+ qi::rule<iterator> section_block, endsect_block,
+ h1, h2, h3, h4, h5, h6, heading;
     };
 
     void quickbook_grammar::impl::init_block_section()
@@ -38,8 +41,11 @@
 
         // Sections
 
- block_keyword_rules.add("section", local.begin_section[actions.process]);
- block_keyword_rules.add("endsect", local.end_section[actions.process]);
+ block_keyword_rules.add("section", &local.section_block);
+ block_keyword_rules.add("endsect", &local.endsect_block);
+
+ local.section_block = local.begin_section[actions.process];
+ local.endsect_block = local.end_section[actions.process];
 
         local.begin_section =
                 space
@@ -56,15 +62,23 @@
         // Headings
 
         block_keyword_rules.add
- ("h1", local.heading(1) [actions.process])
- ("h2", local.heading(2) [actions.process])
- ("h3", local.heading(3) [actions.process])
- ("h4", local.heading(4) [actions.process])
- ("h5", local.heading(5) [actions.process])
- ("h6", local.heading(6) [actions.process])
- ("heading", local.heading(-1) [actions.process]);
+ ("h1", &local.h1)
+ ("h2", &local.h2)
+ ("h3", &local.h3)
+ ("h4", &local.h4)
+ ("h5", &local.h5)
+ ("h6", &local.h6)
+ ("heading", &local.heading);
+
+ local.h1 = local.heading_impl(1) [actions.process];
+ local.h2 = local.heading_impl(2) [actions.process];
+ local.h3 = local.heading_impl(3) [actions.process];
+ local.h4 = local.heading_impl(4) [actions.process];
+ local.h5 = local.heading_impl(5) [actions.process];
+ local.h6 = local.heading_impl(6) [actions.process];
+ local.heading = local.heading_impl(-1) [actions.process];
 
- local.heading =
+ local.heading_impl =
                 qi::attr(qi::_r1) [member_assign(&quickbook::heading::level)]
>> space
>> -( qi::eps(qbk_since(106u))

Modified: branches/quickbook-1.5-spirit2/src/block_table_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/src/block_table_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/src/block_table_grammar.cpp 2010-09-05 05:32:22 EDT (Sun, 05 Sep 2010)
@@ -24,9 +24,11 @@
     
     struct block_table_grammar_local
     {
+ qi::rule<iterator> table_block;
         qi::rule<iterator, quickbook::table()> table;
         qi::rule<iterator, quickbook::table_row()> table_row;
         qi::rule<iterator, quickbook::table_cell()> table_cell;
+ qi::rule<iterator> variablelist_block;
         qi::rule<iterator, quickbook::variablelist()> variablelist;
         qi::rule<iterator, quickbook::varlistentry()> varlistentry;
         qi::rule<iterator, quickbook::block_formatted()> varlistterm;
@@ -46,7 +48,9 @@
 
         // Table
         
- block_keyword_rules.add("table", local.table[actions.process]);
+ block_keyword_rules.add("table", &local.table_block);
+
+ local.table_block = local.table[actions.process];
 
         local.table =
                 (&(*qi::blank >> qi::eol) | space)
@@ -81,7 +85,9 @@
         local.table_row.name("table_row");
         local.table_cell.name("table_cell");
 
- block_keyword_rules.add("variablelist", local.variablelist[actions.process]);
+ block_keyword_rules.add("variablelist", &local.variablelist_block);
+
+ local.variablelist_block = local.variablelist[actions.process];
 
         local.variablelist =
                 (&(*qi::blank >> qi::eol) | space)

Modified: branches/quickbook-1.5-spirit2/src/grammar_impl.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/src/grammar_impl.hpp (original)
+++ branches/quickbook-1.5-spirit2/src/grammar_impl.hpp 2010-09-05 05:32:22 EDT (Sun, 05 Sep 2010)
@@ -40,8 +40,8 @@
         // block
         qi::rule<iterator> block_start;
         qi::rule<iterator> command_line_macro;
- qi::symbols<char, qi::rule<iterator> > block_keyword_rules;
- qi::symbols<char, qi::rule<iterator> > block_symbol_rules;
+ qi::symbols<char, qi::rule<iterator>* > block_keyword_rules;
+ qi::symbols<char, qi::rule<iterator>* > block_symbol_rules;
         qi::rule<iterator> error;
         qi::rule<iterator, std::string()> inside_paragraph;
         qi::rule<iterator, boost::optional<raw_string>()> element_id;

Modified: branches/quickbook-1.5-spirit2/src/template_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/src/template_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/src/template_grammar.cpp 2010-09-05 05:32:22 EDT (Sun, 05 Sep 2010)
@@ -45,6 +45,7 @@
 
     struct template_grammar_local
     {
+ qi::rule<iterator> define_template_block;
         qi::rule<iterator, quickbook::define_template()> define_template;
         qi::rule<iterator, std::vector<std::string>()> define_template_params;
         qi::rule<iterator, quickbook::template_body()> template_body;
@@ -62,7 +63,9 @@
     {
         template_grammar_local& local = store_.create();
         
- block_keyword_rules.add("template", local.define_template[actions.process]);
+ block_keyword_rules.add("template", &local.define_template_block);
+
+ local.define_template_block = local.define_template[actions.process];
 
         local.define_template =
                 space


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