|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63169 - branches/quickbook-1.5-spirit2
From: daniel_james_at_[hidden]
Date: 2010-06-20 16:33:26
Author: danieljames
Date: 2010-06-20 16:33:24 EDT (Sun, 20 Jun 2010)
New Revision: 63169
URL: http://svn.boost.org/trac/boost/changeset/63169
Log:
Store local rules in a struct.
It turns out my hack for storing rules on the heap and referring to them
by reference wasn't very portable as a lot of compilers weren't
instantiating the rules properly or were having trouble with ADL. So I'm
just creating structures to store the local rules.
Text files modified:
branches/quickbook-1.5-spirit2/block_grammar.cpp | 78 ++++++++++++++---------------
branches/quickbook-1.5-spirit2/block_markup_grammar.cpp | 66 ++++++++++++------------
branches/quickbook-1.5-spirit2/block_section_grammar.cpp | 49 +++++++++----------
branches/quickbook-1.5-spirit2/block_table_grammar.cpp | 73 +++++++++++++--------------
branches/quickbook-1.5-spirit2/code_grammar.cpp | 43 +++++++++-------
branches/quickbook-1.5-spirit2/doc_info_grammar.cpp | 102 +++++++++++++++++++++------------------
branches/quickbook-1.5-spirit2/phrase_grammar.cpp | 100 ++++++++++++++++++++-------------------
branches/quickbook-1.5-spirit2/phrase_image_grammar.cpp | 55 +++++++++++----------
branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp | 84 ++++++++++++++++----------------
branches/quickbook-1.5-spirit2/template_grammar.cpp | 85 ++++++++++++++++----------------
10 files changed, 371 insertions(+), 364 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-20 16:33:24 EDT (Sun, 20 Jun 2010)
@@ -25,46 +25,50 @@
namespace qi = boost::spirit::qi;
namespace ph = boost::phoenix;
+ 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, quickbook::list()> list;
+ qi::rule<iterator, quickbook::list_item()> list_item;
+ qi::rule<iterator, std::string()> list_item_content;
+ qi::rule<iterator, quickbook::hr()> hr;
+ qi::rule<iterator> paragraph;
+ qi::rule<iterator, quickbook::block_separator()> block_separator;
+ qi::rule<iterator, quickbook::def_macro> command_line_macro_parse;
+ };
+
void quickbook_grammar::impl::init_block()
{
- qi::rule<iterator>& block_markup = store_.create();
- qi::rule<iterator, qi::rule<iterator>()>& block_markup_start = store_.create();
- qi::rule<iterator>& blocks = store_.create();
- qi::rule<iterator, quickbook::list()>& list = store_.create();
- qi::rule<iterator, quickbook::hr()>& hr = store_.create();
- qi::rule<iterator>& paragraph = store_.create();
- qi::rule<iterator, quickbook::block_separator()>& block_separator = store_.create();
+ block_grammar_local& local = store_.create();
block_start =
- blocks >> blank
+ local.blocks >> blank
;
- blocks =
- +( block_markup
+ local.blocks =
+ +( local.block_markup
| indented_code [actions.process]
- | list [actions.process]
- | hr [actions.process]
- | block_separator [actions.process]
+ | local.list [actions.process]
+ | local.hr [actions.process]
+ | local.block_separator [actions.process]
| eol
- | paragraph
+ | local.paragraph
)
;
// Block markup
- qi::rule<iterator, qi::locals<qi::rule<iterator> > >& block_markup_impl = store_.create();
-
- block_markup = block_markup_impl;
-
- block_markup_impl
- = block_markup_start [qi::_a = qi::_1]
+ local.block_markup
+ = local.block_markup_start [qi::_a = qi::_1]
>> lazy(qi::_a)
>> ( (space >> ']' >> +eol)
| error
)
;
- block_markup_start
+ local.block_markup_start
= '['
>> space
>> ( block_keyword_rules >> !(qi::alnum | '_')
@@ -74,23 +78,20 @@
// List
- qi::rule<iterator, quickbook::list_item()>& list_item = store_.create();
- qi::rule<iterator, std::string()>& list_item_content = store_.create();
-
- list =
+ local.list =
&qi::char_("*#")
- >> +list_item
+ >> +local.list_item
;
- list_item =
+ local.list_item =
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
- >> list_item_content [member_assign(&quickbook::list_item::content)]
+ >> local.list_item_content [member_assign(&quickbook::list_item::content)]
;
- list_item_content =
+ local.list_item_content =
qi::eps[actions.phrase_push] >>
*( common
| (qi::char_ -
@@ -105,7 +106,7 @@
// Horizontol rule
- hr =
+ local.hr =
qi::omit[
"----"
>> *(qi::char_ - eol)
@@ -115,9 +116,9 @@
// Paragraph
- paragraph =
+ local.paragraph =
+( common
- | (qi::char_ - (block_separator | block_markup_start))
+ | (qi::char_ - (local.block_separator | local.block_markup_start))
[actions.process]
)
;
@@ -125,7 +126,7 @@
// Define block_separator using qi::eol/qi::blank rather than 'eol'
// because we don't want any comments in the blank line.
- block_separator =
+ local.block_separator =
qi::attr(quickbook::block_separator())
>> qi::omit
[ qi::eol >> *qi::blank >> qi::eol
@@ -135,11 +136,9 @@
// Parse command line macro definition. This is more here out of
// convenience than anything.
- qi::rule<iterator, quickbook::def_macro>& command_line_macro_parse = store_.create();
-
- command_line_macro = command_line_macro_parse [actions.process];
+ command_line_macro = local.command_line_macro_parse [actions.process];
- command_line_macro_parse =
+ local.command_line_macro_parse =
space
>> macro_identifier
>> space
@@ -153,8 +152,7 @@
// Error
- error =
- position [actions.error];
+ error = position [actions.error];
// Block contents
@@ -162,7 +160,7 @@
qi::eps [actions.block_push][actions.phrase_push]
>> *( common
| (qi::char_ - phrase_end) [actions.process]
- | block_separator [actions.process]
+ | local.block_separator [actions.process]
)
>> qi::attr(quickbook::block_separator())
[actions.process]
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-20 16:33:24 EDT (Sun, 20 Jun 2010)
@@ -32,26 +32,37 @@
};
}
+ 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::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;
+ };
+
void quickbook_grammar::impl::init_block_markup()
{
- // Paragraph Blocks
+ block_markup_grammar_local& local = store_.create();
- qi::rule<iterator, quickbook::block_formatted(formatted_type)>& paragraph_block = store_.create();
+ // Paragraph Blocks
block_keyword_rules.add
- ("blurb", paragraph_block(formatted_type("blurb")) [actions.process])
- ("warning", paragraph_block(formatted_type("warning")) [actions.process])
- ("caution", paragraph_block(formatted_type("caution")) [actions.process])
- ("important", paragraph_block(formatted_type("important")) [actions.process])
- ("note", paragraph_block(formatted_type("note")) [actions.process])
- ("tip", paragraph_block(formatted_type("tip")) [actions.process])
+ ("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
- (":", paragraph_block(formatted_type("blockquote")) [actions.process])
+ (":", local.paragraph_block(formatted_type("blockquote")) [actions.process])
;
- paragraph_block =
+ local.paragraph_block =
qi::attr(qi::_r1) [member_assign(&quickbook::block_formatted::type)]
>> space
>> inside_paragraph [member_assign(&quickbook::block_formatted::content)]
@@ -59,11 +70,9 @@
// Preformatted
- qi::rule<iterator, quickbook::block_formatted()>& preformatted = store_.create();
-
- block_keyword_rules.add("pre", preformatted [actions.process]);
+ block_keyword_rules.add("pre", local.preformatted [actions.process]);
- preformatted =
+ local.preformatted =
space [ph::ref(no_eols) = false]
[member_assign(&quickbook::block_formatted::type, "preformatted")]
>> -eol
@@ -73,11 +82,9 @@
// Define Macro
- qi::rule<iterator, quickbook::def_macro()>& def_macro = store_.create();
-
- block_keyword_rules.add("def", def_macro[actions.process]);
+ block_keyword_rules.add("def", local.def_macro[actions.process]);
- def_macro =
+ local.def_macro =
space
>> macro_identifier [member_assign(&quickbook::def_macro::macro_identifier)]
>> blank
@@ -86,42 +93,35 @@
// xinclude
- qi::rule<iterator, quickbook::xinclude()>& xinclude = store_.create();
-
- block_keyword_rules.add("xinclude", xinclude[actions.process]);
+ block_keyword_rules.add("xinclude", local.xinclude[actions.process]);
// TODO: Why do these use phrase_end? It doesn't make any sense.
- xinclude =
+ local.xinclude =
space
>> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::xinclude::path)]
;
-
- qi::rule<iterator, quickbook::include()>& include = store_.create();
- qi::rule<iterator, raw_string()>& include_id = store_.create();
- block_keyword_rules.add("include", include[actions.process]);
+ block_keyword_rules.add("include", local.include[actions.process]);
// Include
- include =
+ local.include =
space
>> -(
':'
- >> include_id
+ >> local.include_id
>> space
) [member_assign(&quickbook::include::id)]
>> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::include::path)]
;
- include_id = qi::raw[*(qi::alnum | '_')] [qi::_val = qi::_1];
+ local.include_id = qi::raw[*(qi::alnum | '_')] [qi::_val = qi::_1];
// Import
- qi::rule<iterator, quickbook::import()>& import = store_.create();
-
- block_keyword_rules.add("import", import[actions.process]);
+ block_keyword_rules.add("import", local.import[actions.process]);
- import =
+ local.import =
space
>> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::import::path)]
;
Modified: branches/quickbook-1.5-spirit2/block_section_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_section_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_section_grammar.cpp 2010-06-20 16:33:24 EDT (Sun, 20 Jun 2010)
@@ -24,55 +24,52 @@
namespace qi = boost::spirit::qi;
namespace ph = boost::phoenix;
- // Workaround for clang:
- namespace {
- struct dummmy {
- qi::rule<iterator, raw_string()> a1;
- };
- }
+ struct block_section_grammar_local
+ {
+ 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;
+ };
void quickbook_grammar::impl::init_block_section()
{
- qi::rule<iterator, quickbook::title()>& title_phrase = store_.create();
+ block_section_grammar_local& local = store_.create();
// Sections
- qi::rule<iterator, quickbook::begin_section()>& begin_section = store_.create();
- qi::rule<iterator, quickbook::end_section()>& end_section = store_.create();
- block_keyword_rules.add("section", begin_section[actions.process]);
- block_keyword_rules.add("endsect", end_section[actions.process]);
+ block_keyword_rules.add("section", local.begin_section[actions.process]);
+ block_keyword_rules.add("endsect", local.end_section[actions.process]);
- begin_section =
+ local.begin_section =
space
>> element_id [member_assign(&quickbook::begin_section::id)]
- >> title_phrase [member_assign(&quickbook::begin_section::content)]
+ >> local.title_phrase [member_assign(&quickbook::begin_section::content)]
;
- end_section =
+ local.end_section =
space
>> position [member_assign(&quickbook::end_section::position)]
;
// Headings
- qi::rule<iterator, quickbook::heading(int)>& heading = store_.create();
-
block_keyword_rules.add
- ("h1", heading(1) [actions.process])
- ("h2", heading(2) [actions.process])
- ("h3", heading(3) [actions.process])
- ("h4", heading(4) [actions.process])
- ("h5", heading(5) [actions.process])
- ("h6", heading(6) [actions.process])
- ("heading", heading(-1) [actions.process]);
+ ("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]);
- heading =
+ local.heading =
qi::attr(qi::_r1) [member_assign(&quickbook::heading::level)]
>> space
- >> title_phrase [member_assign(&quickbook::heading::content)]
+ >> local.title_phrase [member_assign(&quickbook::heading::content)]
;
- title_phrase =
+ local.title_phrase =
qi::raw[
phrase [member_assign(&quickbook::title::content)]
] [member_assign(&quickbook::title::raw)]
Modified: branches/quickbook-1.5-spirit2/block_table_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_table_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_table_grammar.cpp 2010-06-20 16:33:24 EDT (Sun, 20 Jun 2010)
@@ -25,25 +25,29 @@
namespace qi = boost::spirit::qi;
namespace ph = boost::phoenix;
- // Workaround for clang:
- namespace {
- struct dummmy {
- qi::rule<iterator, raw_string()> a1;
- };
- }
+ struct block_table_grammar_local
+ {
+ 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, quickbook::block_formatted()> table_cell_body;
+ qi::rule<iterator, quickbook::variablelist()> variablelist;
+ qi::rule<iterator, quickbook::varlistentry()> varlistentry;
+ qi::rule<iterator, quickbook::block_formatted()> varlistterm;
+ qi::rule<iterator, quickbook::block_formatted()> varlistterm_body;
+ qi::rule<iterator, quickbook::block_formatted()> varlistitem;
+ qi::rule<iterator, quickbook::block_formatted()> varlistitem_body;
+ };
void quickbook_grammar::impl::init_block_table()
{
- // Table
+ block_table_grammar_local& local = store_.create();
- qi::rule<iterator, quickbook::table()>& table = store_.create();
- qi::rule<iterator, quickbook::table_row()>& table_row = store_.create();
- qi::rule<iterator, quickbook::table_cell()>& table_cell = store_.create();
- qi::rule<iterator, quickbook::block_formatted()>& table_cell_body = store_.create();
+ // Table
- block_keyword_rules.add("table", table[actions.process]);
+ block_keyword_rules.add("table", local.table[actions.process]);
- table =
+ local.table =
(&(*qi::blank >> qi::eol) | space)
>> ((
qi::eps(qbk_since(105u))
@@ -52,79 +56,72 @@
>> (&(*qi::blank >> qi::eol) | space)
>> qi::raw[*(qi::char_ - eol)] [member_assign(&quickbook::table::title)]
>> +eol
- >> (*table_row) [member_assign(&quickbook::table::rows)]
+ >> (*local.table_row) [member_assign(&quickbook::table::rows)]
;
- table_row =
+ local.table_row =
space
>> '['
- >> ( *table_cell >> ']' >> space
+ >> ( *local.table_cell >> ']' >> space
| error >> qi::attr(quickbook::table_row())
)
;
- table_cell =
+ local.table_cell =
space
>> '['
- >> ( table_cell_body >> ']' >> space
+ >> ( local.table_cell_body >> ']' >> space
| error >> qi::attr(quickbook::table_cell())
)
;
- table_cell_body =
+ local.table_cell_body =
inside_paragraph [member_assign(&quickbook::block_formatted::content)]
[member_assign(&quickbook::block_formatted::type, "cell")]
;
- qi::rule<iterator, quickbook::variablelist()>& variablelist = store_.create();
- qi::rule<iterator, quickbook::varlistentry()>& varlistentry = store_.create();
- qi::rule<iterator, quickbook::block_formatted()>& varlistterm = store_.create();
- qi::rule<iterator, quickbook::block_formatted()>& varlistterm_body = store_.create();
- qi::rule<iterator, quickbook::block_formatted()>& varlistitem = store_.create();
- qi::rule<iterator, quickbook::block_formatted()>& varlistitem_body = store_.create();
-
- block_keyword_rules.add("variablelist", variablelist[actions.process]);
+ block_keyword_rules.add("variablelist", local.variablelist[actions.process]);
- variablelist =
+ local.variablelist =
(&(*qi::blank >> qi::eol) | space)
>> qi::raw[*(qi::char_ - eol)] [member_assign(&quickbook::variablelist::title)]
>> +eol
- >> (*varlistentry) [member_assign(&quickbook::variablelist::entries)]
+ >> (*local.varlistentry) [member_assign(&quickbook::variablelist::entries)]
;
- varlistentry =
+ local.varlistentry =
space
>> '['
- >> ( varlistterm
- >> +varlistitem
+ >> ( local.varlistterm
+ >> +local.varlistitem
>> ']'
>> space
| error >> qi::attr(quickbook::varlistentry())
)
;
- varlistterm =
+ local.varlistterm =
space
>> '['
- >> ( varlistterm_body >> ']' >> space
+ >> ( local.varlistterm_body >> ']' >> space
| error >> qi::attr(quickbook::block_formatted())
)
;
- varlistterm_body =
+ local.varlistterm_body =
phrase [member_assign(&quickbook::block_formatted::content)]
[member_assign(&quickbook::block_formatted::type, "varlistterm")]
;
- varlistitem =
+ local.varlistitem =
space
>> '['
- >> ( varlistitem_body >> ']' >> space
+ >> ( local.varlistitem_body >> ']' >> space
| error >> qi::attr(quickbook::block_formatted())
)
;
- varlistitem_body =
+ local.varlistitem_body =
inside_paragraph [member_assign(&quickbook::block_formatted::content)]
[member_assign(&quickbook::block_formatted::type, "varlistitem")]
;
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-06-20 16:33:24 EDT (Sun, 20 Jun 2010)
@@ -21,35 +21,41 @@
namespace qi = boost::spirit::qi;
namespace ph = boost::phoenix;
+ struct code_grammar_local
+ {
+ qi::rule<iterator, quickbook::code()> indented_code;
+ qi::rule<iterator> code_line;
+ qi::rule<iterator, quickbook::code()> code_block1;
+ qi::rule<iterator, quickbook::code()> code_block2;
+ qi::rule<iterator, quickbook::code()> inline_code;
+ qi::rule<iterator, std::string()> inline_code_block;
+ };
+
void quickbook_grammar::impl::init_code()
{
+ code_grammar_local& local = store_.create();
+
// Indented code
- qi::rule<iterator, quickbook::code()>& indented_code_impl = store_.create();
- qi::rule<iterator>& code_line = store_.create();
+ indented_code = local.indented_code [actions.process];
- indented_code = indented_code_impl [actions.process];
-
- indented_code_impl =
+ local.indented_code =
position [member_assign(&quickbook::code::position)]
[member_assign(&quickbook::code::flow, quickbook::code::block)]
- >> qi::raw[code_line >> *(*eol >> code_line)]
+ >> qi::raw[local.code_line >> *(*eol >> local.code_line)]
[member_assign(&quickbook::code::content)]
>> +eol
;
- code_line =
+ local.code_line =
qi::char_(" \t")
>> *(qi::char_ - eol)
>> eol
;
- qi::rule<iterator, quickbook::code()>& code_block1 = store_.create();
- qi::rule<iterator, quickbook::code()>& code_block2 = store_.create();
-
- code_block = (code_block1 | code_block2) [actions.process];
+ code_block = (local.code_block1 | local.code_block2) [actions.process];
- code_block1
+ local.code_block1
= "```"
>> position [member_assign(&quickbook::code::position)]
[member_assign(&quickbook::code::flow, quickbook::code::inline_block)]
@@ -57,7 +63,7 @@
>> "```"
;
- code_block2
+ local.code_block2
= "``"
>> position [member_assign(&quickbook::code::position)]
[member_assign(&quickbook::code::flow, quickbook::code::inline_block)]
@@ -65,20 +71,17 @@
>> "``"
;
- qi::rule<iterator, quickbook::code()>& inline_code_impl = store_.create();
- qi::rule<iterator, std::string()>& inline_code_block = store_.create();
-
- inline_code = inline_code_impl [actions.process];
+ inline_code = local.inline_code [actions.process];
- inline_code_impl =
+ local.inline_code =
'`'
>> position [member_assign(&quickbook::code::position)]
[member_assign(&quickbook::code::flow, quickbook::code::inline_)]
- >> inline_code_block [member_assign(&quickbook::code::content)]
+ >> local.inline_code_block [member_assign(&quickbook::code::content)]
>> '`'
;
- inline_code_block =
+ local.inline_code_block =
qi::raw
[ *( ~qi::char_('`') -
(qi::eol >> *qi::blank >> qi::eol) // Make sure that we don't go
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-20 16:33:24 EDT (Sun, 20 Jun 2010)
@@ -48,29 +48,33 @@
<< "Warning: Quickbook version undefined. "
"Version 1.1 is assumed" << std::endl;
}
+
+ struct doc_info_grammar_local
+ {
+ qi::symbols<char> doc_types;
+ qi::rule<iterator> quickbook_version;
+ qi::rule<iterator, raw_source()> doc_version;
+ qi::rule<iterator, raw_source()> doc_id;
+ qi::rule<iterator, raw_source()> doc_dirname;
+ qi::rule<iterator, raw_source()> doc_category;
+ qi::rule<iterator, raw_source()> doc_last_revision;
+ qi::rule<iterator, std::string()> doc_source_mode; // TODO: raw_source
+ qi::rule<iterator, doc_info::variant_string()> doc_purpose;
+ qi::rule<iterator, doc_info::variant_string()> doc_license;
+ qi::rule<iterator, doc_info::copyright_entry()> doc_copyright;
+ qi::rule<iterator, doc_info::author_list()> doc_authors;
+ qi::rule<iterator, doc_info::author()> doc_author;
+ qi::rule<iterator, quickbook::raw_string()> raw_phrase;
+ qi::rule<iterator, std::string()> doc_info_phrase;
+ };
void quickbook_grammar::impl::init_doc_info()
{
- qi::symbols<char>& doc_types = store_.create();
- qi::rule<iterator>& quickbook_version = store_.create();
- qi::rule<iterator, raw_source()>& doc_version = store_.create();
- qi::rule<iterator, raw_source()>& doc_id = store_.create();
- qi::rule<iterator, raw_source()>& doc_dirname = store_.create();
- qi::rule<iterator, raw_source()>& doc_category = store_.create();
- qi::rule<iterator, raw_source()>& doc_last_revision = store_.create();
- qi::rule<iterator, std::string()>& doc_source_mode = store_.create(); // TODO: raw_source
- qi::rule<iterator, doc_info::variant_string()>& doc_purpose = store_.create();
- qi::rule<iterator, doc_info::variant_string()>& doc_license = store_.create();
- qi::rule<iterator, doc_info::copyright_entry()>& doc_copyright = store_.create();
- qi::rule<iterator, doc_info::author_list()>& doc_authors = store_.create();
- qi::rule<iterator, doc_info::author()>& doc_author = store_.create();
-
- qi::rule<iterator, quickbook::raw_string()>& raw_phrase = store_.create();
- qi::rule<iterator, std::string()>& doc_info_phrase = store_.create();
+ doc_info_grammar_local& local = store_.create();
typedef qi::uint_parser<int, 10, 1, 2> uint2_t;
- doc_types =
+ local.doc_types =
"book", "article", "library", "chapter", "part"
, "appendix", "preface", "qandadiv", "qandaset"
, "reference", "set"
@@ -79,35 +83,36 @@
doc_info_details =
space
>> '[' >> space
- >> qi::raw[doc_types] [member_assign(&doc_info::doc_type)]
+ >> 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)]
- >> quickbook_version
+ >> local.quickbook_version
>>
*(
space >> '[' >>
(
- doc_version [member_assign(&doc_info::doc_version)]
- | doc_id [member_assign(&doc_info::doc_id)]
- | doc_dirname [member_assign(&doc_info::doc_dirname)]
- | doc_copyright [member_push(&doc_info::doc_copyrights)]
- | doc_purpose [member_assign(&doc_info::doc_purpose)]
- | doc_category [member_push(&doc_info::doc_categories)]
- | doc_authors [member_assign(&doc_info::doc_authors)]
- | doc_license [member_assign(&doc_info::doc_license)]
- | doc_last_revision [member_assign(&doc_info::doc_last_revision)]
+ 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.
- | doc_source_mode [ph::ref(actions.state_.source_mode) = qi::_1]
+ | local.doc_source_mode [ph::ref(actions.state_.source_mode) = qi::_1]
)
>> space >> ']' >> +qi::eol
)
>> space >> ']' >> +qi::eol
;
- quickbook_version =
+ local.quickbook_version =
( space
>> '['
>> "quickbook"
@@ -120,13 +125,13 @@
| position [default_quickbook_version]
;
- doc_version = "version" >> hard_space >> qi::raw[*~qi::char_(']')];
- doc_id = "id" >> hard_space >> qi::raw[*~qi::char_(']')];
- doc_dirname = "dirname" >> hard_space >> qi::raw[*~qi::char_(']')];
- doc_category="category" >> hard_space >> qi::raw[*~qi::char_(']')];
- doc_last_revision = "last-revision" >> hard_space >> qi::raw[*~qi::char_(']')];
+ local.doc_version = "version" >> hard_space >> qi::raw[*~qi::char_(']')];
+ local.doc_id = "id" >> hard_space >> qi::raw[*~qi::char_(']')];
+ local.doc_dirname = "dirname" >> hard_space >> qi::raw[*~qi::char_(']')];
+ local.doc_category="category" >> hard_space >> qi::raw[*~qi::char_(']')];
+ local.doc_last_revision = "last-revision" >> hard_space >> qi::raw[*~qi::char_(']')];
- doc_copyright =
+ local.doc_copyright =
"copyright"
>> hard_space
>> (+(qi::uint_ >> space)) [member_assign(&doc_info::copyright_entry::years)]
@@ -134,15 +139,15 @@
[member_assign(&doc_info::copyright_entry::holder)]
;
- doc_purpose =
+ local.doc_purpose =
"purpose" >> hard_space
>> (
- qi::eps(qbk_before(103)) >> raw_phrase |
- qi::eps(qbk_since(103)) >> doc_info_phrase
+ qi::eps(qbk_before(103)) >> local.raw_phrase |
+ qi::eps(qbk_since(103)) >> local.doc_info_phrase
)
;
- doc_author =
+ local.doc_author =
space
>> '['
>> space
@@ -152,17 +157,17 @@
>> ']'
;
- doc_authors = "authors" >> hard_space >> (doc_author % ',') ;
+ local.doc_authors = "authors" >> hard_space >> (local.doc_author % ',') ;
- doc_license =
+ local.doc_license =
"license" >> hard_space
>> (
- qi::eps(qbk_before(103)) >> raw_phrase |
- qi::eps(qbk_since(103)) >> doc_info_phrase
+ qi::eps(qbk_before(103)) >> local.raw_phrase |
+ qi::eps(qbk_since(103)) >> local.doc_info_phrase
)
;
- doc_source_mode =
+ local.doc_source_mode =
"source-mode" >> hard_space
>> (
qi::string("c++")
@@ -171,11 +176,12 @@
)
;
- raw_phrase =
- qi::raw[doc_info_phrase] [qi::_val = qi::_1]
+ local.raw_phrase =
+ qi::raw[local.doc_info_phrase]
+ [qi::_val = qi::_1]
;
- doc_info_phrase =
+ local.doc_info_phrase =
qi::eps [actions.phrase_push]
>> *( common
| comment
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-20 16:33:24 EDT (Sun, 20 Jun 2010)
@@ -26,13 +26,28 @@
namespace qi = boost::spirit::qi;
namespace ph = boost::phoenix;
+ struct phrase_grammar_local
+ {
+ qi::rule<iterator> macro;
+ qi::rule<iterator> phrase_markup;
+ qi::rule<iterator, qi::locals<qi::rule<iterator> > > phrase_markup_impl;
+ qi::rule<iterator, quickbook::break_()> break_;
+ qi::rule<iterator, quickbook::simple_markup(), qi::locals<char> > simple_format;
+ qi::rule<iterator, std::string(char)> simple_format_body;
+ qi::rule<iterator, void(char)> simple_format_chars;
+ qi::rule<iterator, void(char)> simple_format_end;
+ qi::rule<iterator> simple_phrase_end;
+ qi::rule<iterator> escape;
+ qi::rule<iterator, quickbook::break_()> escape_break;
+ qi::rule<iterator, quickbook::formatted()> escape_punct;
+ qi::rule<iterator, quickbook::formatted()> escape_markup;
+ qi::rule<iterator, quickbook::unicode_char()> escape_unicode16;
+ qi::rule<iterator, quickbook::unicode_char()> escape_unicode32;
+ };
+
void quickbook_grammar::impl::init_phrase()
{
- qi::rule<iterator>& macro = store_.create();
- qi::rule<iterator>& phrase_markup = 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::break_()>& break_ = store_.create();
+ phrase_grammar_local& local = store_.create();
simple_phrase =
*( common
@@ -49,122 +64,109 @@
;
common =
- macro
- | phrase_markup
+ local.macro
+ | local.phrase_markup
| code_block [actions.process]
| inline_code [actions.process]
- | simple_format [actions.process]
- | escape
+ | local.simple_format [actions.process]
+ | local.escape
| comment
;
- macro =
+ local.macro =
( actions.macro // must not be followed by
>> !(qi::alpha | '_') // alpha or underscore
) [actions.process]
;
- qi::rule<iterator, qi::locals<qi::rule<iterator> > >& phrase_markup_impl = store_.create();
-
- phrase_markup =
+ local.phrase_markup =
( '['
- >> ( phrase_markup_impl
+ >> ( local.phrase_markup_impl
| call_template
- | break_ [actions.process]
+ | local.break_ [actions.process]
)
>> ']'
)
;
- phrase_markup_impl
+ local.phrase_markup_impl
= ( phrase_keyword_rules >> !(qi::alnum | '_')
| phrase_symbol_rules
) [qi::_a = qi::_1]
>> lazy(qi::_a)
;
- break_ =
+ local.break_ =
position [member_assign(&quickbook::break_::position)]
>> "br"
;
- qi::rule<iterator>& simple_phrase_end = store_.create();
- qi::rule<iterator, std::string(char)>& simple_format_body = store_.create();
- qi::rule<iterator, void(char)>& simple_format_chars = store_.create();
- qi::rule<iterator, void(char)>& simple_format_end = store_.create();
-
- simple_format
+ local.simple_format
= qi::char_("*/_=") [qi::_a = qi::_1]
- >> simple_format_body(qi::_a) [member_assign(&quickbook::simple_markup::raw_content)]
+ >> local.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
+ local.simple_format_body
= qi::raw
[ qi::graph
- >> ( &simple_format_end(qi::_r1)
- | simple_format_chars(qi::_r1)
+ >> ( &local.simple_format_end(qi::_r1)
+ | local.simple_format_chars(qi::_r1)
)
]
;
- simple_format_chars
+ local.simple_format_chars
= *( qi::char_ -
( (qi::graph >> qi::lit(qi::_r1))
- | simple_phrase_end // Make sure that we don't go
+ | local.simple_phrase_end // Make sure that we don't go
) // past a single block
)
>> qi::graph // qi::graph must precede qi::lit(qi::_r1)
- >> &simple_format_end(qi::_r1)
+ >> &local.simple_format_end(qi::_r1)
;
- simple_format_end
+ local.simple_format_end
= qi::lit(qi::_r1)
>> (qi::space | qi::punct | qi::eoi)
;
- simple_phrase_end = '[' | phrase_end;
-
- qi::rule<iterator, quickbook::break_()>& escape_break = store_.create();
- qi::rule<iterator, quickbook::formatted()>& escape_punct = store_.create();
- qi::rule<iterator, quickbook::formatted()>& escape_markup = store_.create();
- qi::rule<iterator, quickbook::unicode_char()>& escape_unicode16 = store_.create();
- qi::rule<iterator, quickbook::unicode_char()>& escape_unicode32 = store_.create();
+ local.simple_phrase_end = '[' | phrase_end;
- escape =
- ( escape_break
+ local.escape =
+ ( local.escape_break
| "\\ " // ignore an escaped char
- | escape_punct
- | escape_unicode16
- | escape_unicode32
- | escape_markup
+ | local.escape_punct
+ | local.escape_unicode16
+ | local.escape_unicode32
+ | local.escape_markup
) [actions.process]
;
- escape_break =
+ local.escape_break =
position [member_assign(&quickbook::break_::position)]
>> "\\n"
;
- escape_punct =
+ local.escape_punct =
'\\'
>> qi::repeat(1)[qi::punct] [member_assign(&quickbook::formatted::content)]
[member_assign(&quickbook::formatted::type, "")]
;
- escape_markup =
+ local.escape_markup =
("'''" >> -eol)
>> (*(qi::char_ - "'''")) [member_assign(&quickbook::formatted::content)]
[member_assign(&quickbook::formatted::type, "escape")]
>> "'''"
;
- escape_unicode16 =
+ local.escape_unicode16 =
"\\u"
> qi::raw[qi::repeat(4)[qi::xdigit]] [member_assign(&quickbook::unicode_char::value)]
;
- escape_unicode32 =
+ local.escape_unicode32 =
"\\U"
> qi::raw[qi::repeat(8)[qi::xdigit]] [member_assign(&quickbook::unicode_char::value)]
;
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-06-20 16:33:24 EDT (Sun, 20 Jun 2010)
@@ -21,59 +21,62 @@
namespace qi = boost::spirit::qi;
namespace ph = boost::phoenix;
- void quickbook_grammar::impl::init_phrase_image()
+ struct image_grammar_local
{
- // Images
+ qi::rule<iterator, quickbook::image()> image;
+ qi::rule<iterator, quickbook::image()> image_1_4;
+ qi::rule<iterator, quickbook::image()> image_1_5;
+ qi::rule<iterator, std::string()> image_filename;
+ qi::rule<iterator, quickbook::image::attribute_map()> image_attributes;
+ qi::rule<iterator, std::pair<std::string, std::string>()> image_attribute;
+ qi::rule<iterator, std::string()> image_attribute_key;
+ qi::rule<iterator, std::string()> image_attribute_value;
+ };
- qi::rule<iterator, quickbook::image()>& image = store_.create();
- 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();
-
- phrase_symbol_rules.add("$", image [actions.process]);
+ void quickbook_grammar::impl::init_phrase_image()
+ {
+ image_grammar_local& local = store_.create();
+
+ phrase_symbol_rules.add("$", local.image [actions.process]);
- image =
- (qi::eps(qbk_since(105u)) >> image_1_5) |
- (qi::eps(qbk_before(105u)) >> image_1_4);
+ local.image =
+ (qi::eps(qbk_since(105u)) >> local.image_1_5) |
+ (qi::eps(qbk_before(105u)) >> local.image_1_4);
- image_1_4 =
+ local.image_1_4 =
position [member_assign(&quickbook::image::position)]
>> blank
>> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::image::image_filename)]
>> &qi::lit(']')
;
- image_1_5 =
+ local.image_1_5 =
position [member_assign(&quickbook::image::position)]
>> blank
- >> image_filename [member_assign(&quickbook::image::image_filename)]
+ >> local.image_filename [member_assign(&quickbook::image::image_filename)]
>> hard_space
- >> image_attributes [member_assign(&quickbook::image::attributes)]
+ >> local.image_attributes [member_assign(&quickbook::image::attributes)]
>> &qi::lit(']')
;
- image_filename = qi::raw[
+ local.image_filename = qi::raw[
+(qi::char_ - (qi::space | phrase_end | '['))
>> *(
+qi::space
>> +(qi::char_ - (qi::space | phrase_end | '['))
)];
- image_attributes = *(image_attribute >> space);
+ local.image_attributes = *(local.image_attribute >> space);
- image_attribute =
+ local.image_attribute =
'['
- >> image_attribute_key [member_assign(&std::pair<std::string, std::string>::first)]
+ >> local.image_attribute_key [member_assign(&std::pair<std::string, std::string>::first)]
>> space
- >> image_attribute_value [member_assign(&std::pair<std::string, std::string>::second)]
+ >> local.image_attribute_value [member_assign(&std::pair<std::string, std::string>::second)]
>> ']'
;
- image_attribute_key = *(qi::alnum | '_');
- image_attribute_value = *(qi::char_ - (phrase_end | '['));
+ local.image_attribute_key = *(qi::alnum | '_');
+ local.image_attribute_value = *(qi::char_ - (phrase_end | '['));
}
}
\ 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-20 16:33:24 EDT (Sun, 20 Jun 2010)
@@ -24,16 +24,27 @@
namespace qi = boost::spirit::qi;
namespace ph = boost::phoenix;
+ struct phrase_markup_grammar_local
+ {
+ qi::rule<iterator, quickbook::callout_link()> callout_link;
+ qi::rule<iterator, quickbook::cond_phrase()> cond_phrase;
+ qi::rule<iterator, quickbook::link()> url;
+ qi::symbols<char, formatted_type> link_symbol;
+ qi::rule<iterator, quickbook::link(formatted_type)> link;
+ qi::rule<iterator, quickbook::anchor()> anchor;
+ qi::rule<iterator, quickbook::formatted(formatted_type)> formatted;
+ };
+
void quickbook_grammar::impl::init_phrase_markup()
{
+ phrase_markup_grammar_local& local = store_.create();
+
// Callouts
- // Don't use this, it's meant to be private.
- qi::rule<iterator, quickbook::callout_link()>& callout_link = store_.create();
-
- phrase_symbol_rules.add("[callout]", callout_link [actions.process]);
+ // Don't use this, it's meant to be private.
+ phrase_symbol_rules.add("[callout]", local.callout_link [actions.process]);
- callout_link =
+ local.callout_link =
(*~qi::char_(' ')) [member_assign(&quickbook::callout_link::role)]
>> ' '
>> (*~qi::char_(']')) [member_assign(&quickbook::callout_link::identifier)]
@@ -41,11 +52,9 @@
// Conditional Phrase
- qi::rule<iterator, quickbook::cond_phrase()>& cond_phrase = store_.create();
-
- phrase_symbol_rules.add("?", cond_phrase [actions.process]);
+ phrase_symbol_rules.add("?", local.cond_phrase [actions.process]);
- cond_phrase =
+ local.cond_phrase =
blank
>> macro_identifier [member_assign(&quickbook::cond_phrase::macro_id)]
>> -phrase [member_assign(&quickbook::cond_phrase::content)]
@@ -53,36 +62,31 @@
// URL
- qi::rule<iterator, quickbook::link()>& url = store_.create();
-
- phrase_symbol_rules.add("@", url [actions.process]);
+ phrase_symbol_rules.add("@", local.url [actions.process]);
- url = (*(qi::char_ - (']' | qi::space))) [member_assign(&quickbook::link::destination)]
+ local.url
+ = (*(qi::char_ - (']' | qi::space))) [member_assign(&quickbook::link::destination)]
[member_assign(&quickbook::link::type, "url")]
>> ( &qi::lit(']')
| (hard_space >> phrase) [member_assign(&quickbook::link::content)]
)
;
- qi::symbols<char, formatted_type>& link_symbol = store_.create();
-
// Link
-
- qi::rule<iterator, quickbook::link(formatted_type)>& link = store_.create();
phrase_keyword_rules.add
- ("link", link(formatted_type("link")) [actions.process])
- ("funcref", link(formatted_type("funcref")) [actions.process])
- ("classref", link(formatted_type("classref")) [actions.process])
- ("memberref", link(formatted_type("memberref")) [actions.process])
- ("enumref", link(formatted_type("enumref")) [actions.process])
- ("macroref", link(formatted_type("macroref")) [actions.process])
- ("headerref", link(formatted_type("headerref")) [actions.process])
- ("conceptref", link(formatted_type("conceptref")) [actions.process])
- ("globalref", link(formatted_type("globalref")) [actions.process])
+ ("link", local.link(formatted_type("link")) [actions.process])
+ ("funcref", local.link(formatted_type("funcref")) [actions.process])
+ ("classref", local.link(formatted_type("classref")) [actions.process])
+ ("memberref", local.link(formatted_type("memberref")) [actions.process])
+ ("enumref", local.link(formatted_type("enumref")) [actions.process])
+ ("macroref", local.link(formatted_type("macroref")) [actions.process])
+ ("headerref", local.link(formatted_type("headerref")) [actions.process])
+ ("conceptref", local.link(formatted_type("conceptref")) [actions.process])
+ ("globalref", local.link(formatted_type("globalref")) [actions.process])
;
- link =
+ local.link =
qi::attr(qi::_r1) [member_assign(&quickbook::link::type)]
>> space
>> (*(qi::char_ - (']' | qi::space))) [member_assign(&quickbook::link::destination)]
@@ -93,11 +97,9 @@
// Anchor
- qi::rule<iterator, quickbook::anchor()>& anchor = store_.create();
-
- phrase_symbol_rules.add("#", anchor [actions.process]);
+ phrase_symbol_rules.add("#", local.anchor [actions.process]);
- anchor =
+ local.anchor =
blank
>> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::anchor::id)]
;
@@ -112,23 +114,21 @@
// Formatted
- qi::rule<iterator, quickbook::formatted(formatted_type)>& formatted = store_.create();
-
phrase_symbol_rules.add
- ("*", formatted(formatted_type("bold")) [actions.process])
- ("'", formatted(formatted_type("italic")) [actions.process])
- ("_", formatted(formatted_type("underline")) [actions.process])
- ("^", formatted(formatted_type("teletype")) [actions.process])
- ("-", formatted(formatted_type("strikethrough")) [actions.process])
- ("\"", formatted(formatted_type("quote")) [actions.process])
- ("~", formatted(formatted_type("replaceable")) [actions.process])
+ ("*", local.formatted(formatted_type("bold")) [actions.process])
+ ("'", local.formatted(formatted_type("italic")) [actions.process])
+ ("_", local.formatted(formatted_type("underline")) [actions.process])
+ ("^", local.formatted(formatted_type("teletype")) [actions.process])
+ ("-", local.formatted(formatted_type("strikethrough")) [actions.process])
+ ("\"", local.formatted(formatted_type("quote")) [actions.process])
+ ("~", local.formatted(formatted_type("replaceable")) [actions.process])
;
phrase_keyword_rules.add
- ("footnote", formatted(formatted_type("footnote")) [actions.process])
+ ("footnote", local.formatted(formatted_type("footnote")) [actions.process])
;
- formatted =
+ local.formatted =
qi::attr(qi::_r1) [member_assign(&quickbook::formatted::type)]
>> blank
>> phrase [member_assign(&quickbook::formatted::content)]
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-06-20 16:33:24 EDT (Sun, 20 Jun 2010)
@@ -20,95 +20,96 @@
{
namespace qi = boost::spirit::qi;
- void quickbook_grammar::impl::init_template()
+ struct template_grammar_local
{
- // Define Template
+ qi::rule<iterator, quickbook::define_template()> define_template;
+ qi::rule<iterator, std::vector<std::string>()> define_template_params;
+ qi::rule<iterator, quickbook::template_value()> template_body;
+ qi::rule<iterator> template_body_recurse;
+ qi::rule<iterator, std::string()> template_id;
+ qi::rule<iterator, quickbook::call_template()> call_template;
+ qi::rule<iterator, std::vector<quickbook::template_value>()> template_args;
+ qi::rule<iterator, quickbook::template_value()> template_arg_1_4;
+ qi::rule<iterator> brackets_1_4;
+ qi::rule<iterator, quickbook::template_value()> template_arg_1_5;
+ qi::rule<iterator> brackets_1_5;
+ };
- 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();
+ void quickbook_grammar::impl::init_template()
+ {
+ template_grammar_local& local = store_.create();
- block_keyword_rules.add("template", define_template[actions.process]);
+ block_keyword_rules.add("template", local.define_template[actions.process]);
- define_template =
+ local.define_template =
space
- >> 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)]
+ >> local.template_id [member_assign(&quickbook::define_template::id)]
+ >> -local.define_template_params [member_assign(&quickbook::define_template::params)]
+ >> local.template_body [member_assign(&quickbook::define_template::body)]
;
- define_template_params =
+ local.define_template_params =
space
>> '['
- >> *(space >> template_id)
+ >> *(space >> local.template_id)
>> space
>> ']'
;
- template_body =
+ local.template_body =
position [member_assign(&quickbook::template_value::position)]
- >> qi::raw[template_body_recurse] [member_assign(&quickbook::template_value::content)]
+ >> qi::raw[local.template_body_recurse]
+ [member_assign(&quickbook::template_value::content)]
;
- template_body_recurse =
- *( ('[' >> template_body_recurse >> ']')
+ local.template_body_recurse =
+ *( ('[' >> local.template_body_recurse >> ']')
| (qi::char_ - ']')
)
>> space
>> &qi::lit(']')
;
- template_id
+ local.template_id
= (qi::alpha | '_') >> *(qi::alnum | '_')
| qi::repeat(1)[qi::punct - qi::char_("[]")]
;
- // Call Template
-
- qi::rule<iterator, quickbook::call_template()>& call_template_impl = store_.create();
- 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 = call_template_impl[actions.process];
+ call_template = local.call_template [actions.process];
- call_template_impl =
+ local.call_template =
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)
) [member_assign(&quickbook::call_template::symbol)]
- >> template_args [member_assign(&quickbook::call_template::args)]
+ >> local.template_args [member_assign(&quickbook::call_template::args)]
>> &qi::lit(']')
;
- template_args =
- qi::eps(qbk_before(105u)) >> -(template_arg_1_4 % "..") |
- qi::eps(qbk_since(105u)) >> -(template_arg_1_5 % "..");
+ local.template_args =
+ qi::eps(qbk_before(105u)) >> -(local.template_arg_1_4 % "..") |
+ qi::eps(qbk_since(105u)) >> -(local.template_arg_1_5 % "..");
- template_arg_1_4 =
+ local.template_arg_1_4 =
position [member_assign(&quickbook::template_value::position)]
- >> qi::raw[+(brackets_1_4 | ~qi::char_(']') - "..")]
+ >> qi::raw[+(local.brackets_1_4 | ~qi::char_(']') - "..")]
[member_assign(&quickbook::template_value::content)]
;
- brackets_1_4 =
- '[' >> +(brackets_1_4 | ~qi::char_(']') - "..") >> ']'
+ local.brackets_1_4 =
+ '[' >> +(local.brackets_1_4 | ~qi::char_(']') - "..") >> ']'
;
- template_arg_1_5 =
+ local.template_arg_1_5 =
position [member_assign(&quickbook::template_value::position)]
- >> qi::raw[+(brackets_1_5 | '\\' >> qi::char_ | ~qi::char_("[]") - "..")]
+ >> qi::raw[+(local.brackets_1_5 | '\\' >> qi::char_ | ~qi::char_("[]") - "..")]
[member_assign(&quickbook::template_value::content)]
;
- brackets_1_5 =
- '[' >> +(brackets_1_5 | '\\' >> qi::char_ | ~qi::char_("[]")) >> ']'
+ local.brackets_1_5 =
+ '[' >> +(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