Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67335 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2010-12-19 08:34:53


Author: danieljames
Date: 2010-12-19 08:34:50 EST (Sun, 19 Dec 2010)
New Revision: 67335
URL: http://svn.boost.org/trac/boost/changeset/67335

Log:
More use of shared rules.
Text files modified:
   trunk/tools/quickbook/src/block_markup_grammar.cpp | 172 ++++++++++++++-------------------------
   trunk/tools/quickbook/src/doc_info_grammar.cpp | 88 +++++++------------
   trunk/tools/quickbook/src/grammar_impl.hpp | 21 +++-
   trunk/tools/quickbook/src/main_grammar.cpp | 124 +++++++++++++++-------------
   trunk/tools/quickbook/src/phrase_markup_grammar.cpp | 142 ++++++++++++--------------------
   5 files changed, 230 insertions(+), 317 deletions(-)

Modified: trunk/tools/quickbook/src/block_markup_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/block_markup_grammar.cpp (original)
+++ trunk/tools/quickbook/src/block_markup_grammar.cpp 2010-12-19 08:34:50 EST (Sun, 19 Dec 2010)
@@ -23,17 +23,15 @@
     struct block_markup_grammar_local
     {
         cl::rule<scanner>
- space, blank, comment, h, h1, h2,
- h3, h4, h5, h6, blurb, blockquote,
+ h, h1, h2, h3, h4, h5, h6, blurb, blockquote,
                         warning, caution, important, note, tip,
- inner_phrase, phrase, phrase_end, def_macro,
- macro_identifier, table, table_row, variablelist,
+ inner_phrase, def_macro,
+ table, table_row, variablelist,
                         varlistentry, varlistterm, varlistitem, table_cell,
                         preformatted, begin_section, end_section,
- xinclude, include, eol,
+ xinclude, include,
                         template_, template_id, template_formal_arg,
- template_body, identifier, dummy_block, import,
- inside_paragraph,
+ template_body, identifier, import,
                         element_id, element_id_1_5, element_id_1_6;
     };
 
@@ -43,40 +41,11 @@
 
         block_markup_grammar_local& local = store_.create();
 
- local.space =
- *(cl::space_p | local.comment)
- ;
-
- local.blank =
- *(cl::blank_p | local.comment)
- ;
-
- local.eol = local.blank >> cl::eol_p
- ;
-
- local.phrase_end =
- ']' |
- cl::if_p(var(no_eols))
- [
- local.eol >> *cl::blank_p >> cl::eol_p
- // Make sure that we don't go
- ] // past a single block, except
- ; // when preformatted.
-
- local.comment =
- "[/" >> *(local.dummy_block | (cl::anychar_p - ']')) >> ']'
- ;
-
- local.dummy_block =
- '[' >> *(local.dummy_block | (cl::anychar_p - ']')) >> ']'
- ;
-
         local.element_id =
                 ':'
>>
                 (
- cl::if_p(qbk_since(105u))
- [local.space]
+ cl::if_p(qbk_since(105u)) [space]
>> (+(cl::alnum_p | '_')) [cl::assign_a(actions.element_id)]
                 | cl::eps_p [actions.element_id_warning]
                                                 [cl::assign_a(actions.element_id)]
@@ -108,9 +77,9 @@
             ;
 
         local.begin_section =
- local.space
+ space
>> local.element_id
- >> local.space
+ >> space
>> local.inner_phrase [actions.begin_section]
             ;
 
@@ -128,28 +97,21 @@
             ("h6", &local.h6)
             ;
 
- local.h = local.space >> local.element_id_1_6 >> local.space >> local.inner_phrase [actions.h];
- local.h1 = local.space >> local.element_id_1_6 >> local.space >> local.inner_phrase [actions.h1];
- local.h2 = local.space >> local.element_id_1_6 >> local.space >> local.inner_phrase [actions.h2];
- local.h3 = local.space >> local.element_id_1_6 >> local.space >> local.inner_phrase [actions.h3];
- local.h4 = local.space >> local.element_id_1_6 >> local.space >> local.inner_phrase [actions.h4];
- local.h5 = local.space >> local.element_id_1_6 >> local.space >> local.inner_phrase [actions.h5];
- local.h6 = local.space >> local.element_id_1_6 >> local.space >> local.inner_phrase [actions.h6];
+ local.h = space >> local.element_id_1_6 >> space >> local.inner_phrase [actions.h];
+ local.h1 = space >> local.element_id_1_6 >> space >> local.inner_phrase [actions.h1];
+ local.h2 = space >> local.element_id_1_6 >> space >> local.inner_phrase [actions.h2];
+ local.h3 = space >> local.element_id_1_6 >> space >> local.inner_phrase [actions.h3];
+ local.h4 = space >> local.element_id_1_6 >> space >> local.inner_phrase [actions.h4];
+ local.h5 = space >> local.element_id_1_6 >> space >> local.inner_phrase [actions.h5];
+ local.h6 = space >> local.element_id_1_6 >> space >> local.inner_phrase [actions.h6];
         
         static const bool true_ = true;
         static const bool false_ = false;
 
- local.inside_paragraph =
- local.phrase [actions.inside_paragraph]
- >> *(
- +local.eol >> local.phrase [actions.inside_paragraph]
- )
- ;
-
         block_keyword_rules.add("blurb", &local.blurb);
 
         local.blurb =
- scoped_block(actions)[local.inside_paragraph]
+ scoped_block(actions)[inside_paragraph]
                                                 [actions.blurb]
             ;
 
@@ -158,7 +120,7 @@
             ;
 
         local.blockquote =
- local.blank >> scoped_block(actions)[local.inside_paragraph]
+ blank >> scoped_block(actions)[inside_paragraph]
                                                 [actions.blockquote]
             ;
 
@@ -171,27 +133,27 @@
             ;
 
         local.warning =
- scoped_block(actions)[local.inside_paragraph]
+ scoped_block(actions)[inside_paragraph]
                                                 [actions.warning]
             ;
 
         local.caution =
- scoped_block(actions)[local.inside_paragraph]
+ scoped_block(actions)[inside_paragraph]
                                                 [actions.caution]
             ;
 
         local.important =
- scoped_block(actions)[local.inside_paragraph]
+ scoped_block(actions)[inside_paragraph]
                                                 [actions.important]
             ;
 
         local.note =
- scoped_block(actions)[local.inside_paragraph]
+ scoped_block(actions)[inside_paragraph]
                                                 [actions.note]
             ;
 
         local.tip =
- scoped_block(actions)[local.inside_paragraph]
+ scoped_block(actions)[inside_paragraph]
                                                 [actions.tip]
             ;
 
@@ -200,23 +162,19 @@
             ;
 
         local.preformatted =
- local.space [cl::assign_a(no_eols, false_)]
- >> !local.eol >> local.phrase [actions.preformatted]
+ space [cl::assign_a(no_eols, false_)]
+ >> !eol >> phrase [actions.preformatted]
>> cl::eps_p [cl::assign_a(no_eols, true_)]
             ;
 
- local.macro_identifier =
- +(cl::anychar_p - (cl::space_p | ']'))
- ;
-
         block_keyword_rules.add
             ("def", &local.def_macro)
             ;
 
         local.def_macro =
- local.space
- >> local.macro_identifier [actions.macro_identifier]
- >> local.blank >> local.phrase [actions.macro_definition]
+ space
+ >> macro_identifier [actions.macro_identifier]
+ >> blank >> phrase [actions.macro_definition]
             ;
 
         local.identifier =
@@ -232,17 +190,17 @@
             ;
 
         local.template_ =
- local.space
+ space
>> local.template_id [cl::assign_a(actions.template_identifier)]
                                                 [cl::clear_a(actions.template_info)]
>>
             !(
- local.space >> '['
+ space >> '['
>> *(
- local.space
+ space
>> local.template_id [cl::push_back_a(actions.template_info)]
                     )
- >> local.space >> ']'
+ >> space >> ']'
             )
>> ( cl::eps_p(*cl::blank_p >> cl::eol_p)
                                                 [cl::assign_a(actions.template_block, true_)]
@@ -253,8 +211,8 @@
 
         local.template_body =
            *(('[' >> local.template_body >> ']') | (cl::anychar_p - ']'))
- >> cl::eps_p(local.space >> ']')
- >> local.space
+ >> cl::eps_p(space >> ']')
+ >> space
             ;
 
         block_keyword_rules.add
@@ -262,15 +220,15 @@
             ;
 
         local.variablelist =
- (cl::eps_p(*cl::blank_p >> cl::eol_p) | local.space)
- >> (*(cl::anychar_p - local.eol)) [cl::assign_a(actions.table_title)]
- >> (+local.eol) [actions.output_pre]
+ (cl::eps_p(*cl::blank_p >> cl::eol_p) | space)
+ >> (*(cl::anychar_p - eol)) [cl::assign_a(actions.table_title)]
+ >> (+eol) [actions.output_pre]
>> *local.varlistentry
>> cl::eps_p [actions.variablelist]
             ;
 
         local.varlistentry =
- local.space
+ space
>> cl::ch_p('[') [actions.start_varlistentry]
>>
             (
@@ -281,35 +239,35 @@
                         | cl::eps_p [actions.error]
                         )
>> cl::ch_p(']') [actions.end_varlistentry]
- >> local.space
+ >> space
                 )
                 | cl::eps_p [actions.error]
             )
             ;
 
         local.varlistterm =
- local.space
+ space
>> cl::ch_p('[') [actions.start_varlistterm]
>>
             (
                 (
- local.phrase
+ phrase
>> cl::ch_p(']') [actions.end_varlistterm]
- >> local.space
+ >> space
                 )
                 | cl::eps_p [actions.error]
             )
             ;
 
         local.varlistitem =
- local.space
+ space
>> cl::ch_p('[')
>>
             (
                 (
- local.inside_paragraph
+ inside_paragraph
>> cl::ch_p(']')
- >> local.space
+ >> space
                 )
                 | cl::eps_p [actions.error]
             )
@@ -320,36 +278,36 @@
             ;
 
         local.table =
- (cl::eps_p(*cl::blank_p >> cl::eol_p) | local.space)
+ (cl::eps_p(*cl::blank_p >> cl::eol_p) | space)
>> local.element_id_1_5
- >> (cl::eps_p(*cl::blank_p >> cl::eol_p) | local.space)
- >> (*(cl::anychar_p - local.eol)) [cl::assign_a(actions.table_title)]
- >> (+local.eol) [actions.output_pre]
+ >> (cl::eps_p(*cl::blank_p >> cl::eol_p) | space)
+ >> (*(cl::anychar_p - eol)) [cl::assign_a(actions.table_title)]
+ >> (+eol) [actions.output_pre]
>> *local.table_row
>> cl::eps_p [actions.table]
             ;
 
         local.table_row =
- local.space
+ space
>> cl::ch_p('[') [actions.start_row]
>>
             (
                 (
                     *local.table_cell
>> cl::ch_p(']') [actions.end_row]
- >> local.space
+ >> space
                 )
                 | cl::eps_p [actions.error]
             )
             ;
 
         local.table_cell =
- local.space
+ space
>> cl::ch_p('[')
>> ( scoped_block(actions) [
- local.inside_paragraph
+ inside_paragraph
>> cl::ch_p(']')
- >> local.space
+ >> space
                     ] [actions.cell]
                 | cl::eps_p [actions.error]
                 )
@@ -362,42 +320,34 @@
             ;
 
         local.xinclude =
- local.space
- >> (*(cl::anychar_p - local.phrase_end))
+ space
+ >> (*(cl::anychar_p - phrase_end))
                                                 [actions.xinclude]
             ;
 
         local.import =
- local.space
- >> (*(cl::anychar_p - local.phrase_end))
+ space
+ >> (*(cl::anychar_p - phrase_end))
                                                 [actions.import]
             ;
 
         local.include =
- local.space
+ space
>>
            !(
                 ':'
>> (*((cl::alnum_p | '_') - cl::space_p))
                                                 [cl::assign_a(actions.include_doc_id)]
- >> local.space
+ >> space
             )
- >> (*(cl::anychar_p - local.phrase_end))
+ >> (*(cl::anychar_p - phrase_end))
                                                 [actions.include]
             ;
 
         local.inner_phrase =
                 cl::eps_p [actions.inner_phrase_pre]
- >> local.phrase
+ >> phrase
>> cl::eps_p [actions.inner_phrase_post]
             ;
-
- local.phrase =
- *( common
- | local.comment
- | (cl::anychar_p - local.phrase_end)
- [actions.plain_char]
- )
- ;
     }
 }

Modified: trunk/tools/quickbook/src/doc_info_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/doc_info_grammar.cpp (original)
+++ trunk/tools/quickbook/src/doc_info_grammar.cpp 2010-12-19 08:34:50 EST (Sun, 19 Dec 2010)
@@ -25,9 +25,9 @@
         cl::rule<scanner>
                         doc_title, doc_version, doc_id, doc_dirname,
                         doc_copyright, doc_purpose, doc_category, doc_authors,
- doc_author, space, hard_space, doc_license,
+ doc_author, doc_license,
                         doc_last_revision, doc_source_mode, doc_biblioid, doc_lang,
- phrase, quickbook_version, char_, comment, dummy_block;
+ quickbook_version, char_;
         cl::symbols<> doc_types;
     };
 
@@ -44,21 +44,21 @@
         ;
         
         doc_info_details =
- local.space
- >> '[' >> local.space
+ space
+ >> '[' >> space
>> (local.doc_types >> cl::eps_p)
                                             [cl::assign_a(actions.doc_type)]
- >> local.hard_space
+ >> hard_space
>> ( *(~cl::eps_p(cl::ch_p('[') | ']' | cl::eol_p) >> local.char_)
                 ) [actions.extract_doc_title]
>> !(
- local.space >> '[' >>
+ space >> '[' >>
                         local.quickbook_version
- >> local.space >> ']'
+ >> space >> ']'
                 )
>>
                 *(
- local.space >> '[' >>
+ space >> '[' >>
                     (
                       local.doc_version
                     | local.doc_id
@@ -73,13 +73,13 @@
                     | local.doc_biblioid
                     | local.doc_lang
                     )
- >> local.space >> ']' >> +cl::eol_p
+ >> space >> ']' >> +cl::eol_p
                 )
- >> local.space >> ']' >> +cl::eol_p
+ >> space >> ']' >> +cl::eol_p
             ;
 
         local.quickbook_version =
- "quickbook" >> local.hard_space
+ "quickbook" >> hard_space
>> ( cl::uint_p [cl::assign_a(qbk_major_version)]
>> '.'
>> uint2_t() [cl::assign_a(qbk_minor_version)]
@@ -87,54 +87,54 @@
             ;
 
         local.doc_version =
- "version" >> local.hard_space
+ "version" >> hard_space
>> (*(~cl::eps_p(']') >> local.char_))
                                             [actions.extract_doc_version]
             ;
 
         // TODO: Restrictions on doc_id?
         local.doc_id =
- "id" >> local.hard_space
+ "id" >> hard_space
>> (*(~cl::eps_p(']') >> local.char_))
                                             [actions.extract_doc_id]
             ;
 
         // TODO: Restrictions on doc_dirname?
         local.doc_dirname =
- "dirname" >> local.hard_space
+ "dirname" >> hard_space
>> (*(~cl::eps_p(']') >> local.char_))
                                             [actions.extract_doc_dirname]
             ;
 
         local.doc_copyright =
                 "copyright"
- >> local.hard_space [cl::clear_a(actions.copyright.first)]
+ >> hard_space [cl::clear_a(actions.copyright.first)]
>> +( cl::repeat_p(4)[cl::digit_p]
                                             [cl::push_back_a(actions.copyright.first)]
- >> local.space
+ >> space
                 )
- >> local.space
+ >> space
>> (*(~cl::eps_p(']') >> local.char_))
                                             [actions.extract_copyright_second]
             ;
 
         local.doc_purpose =
- "purpose" >> local.hard_space
- >> local.phrase [actions.extract_doc_purpose]
+ "purpose" >> hard_space
+ >> simple_phrase [actions.extract_doc_purpose]
             ;
 
         local.doc_category =
- "category" >> local.hard_space
+ "category" >> hard_space
>> (*(~cl::eps_p(']') >> local.char_))
                                             [actions.extract_doc_category]
                                             [cl::push_back_a(actions.doc_categories, actions.doc_category)]
             ;
 
         local.doc_author =
- '[' >> local.space
+ '[' >> space
>> (*(~cl::eps_p(',') >> local.char_))
                                             [actions.extract_name_second]
- >> ',' >> local.space
+ >> ',' >> space
>> (*(~cl::eps_p(']') >> local.char_))
                                             [actions.extract_name_first]
>> ']'
@@ -142,28 +142,28 @@
 
         local.doc_authors =
                 "authors"
- >> local.hard_space
+ >> hard_space
>> local.doc_author [cl::push_back_a(actions.doc_authors, actions.name)]
- >> local.space
- >> *( !(cl::ch_p(',') >> local.space)
+ >> space
+ >> *( !(cl::ch_p(',') >> space)
>> local.doc_author [cl::push_back_a(actions.doc_authors, actions.name)]
- >> local.space
+ >> space
                 )
             ;
 
         local.doc_license =
- "license" >> local.hard_space
- >> local.phrase [actions.extract_doc_license]
+ "license" >> hard_space
+ >> simple_phrase [actions.extract_doc_license]
             ;
 
         local.doc_last_revision =
- "last-revision" >> local.hard_space
+ "last-revision" >> hard_space
>> (*(~cl::eps_p(']') >> local.char_))
                                             [actions.extract_doc_last_revision]
             ;
 
         local.doc_source_mode =
- "source-mode" >> local.hard_space
+ "source-mode" >> hard_space
>> (
                    cl::str_p("c++")
                 | "python"
@@ -173,42 +173,20 @@
 
         local.doc_biblioid =
                 "biblioid"
- >> local.hard_space
+ >> hard_space
>> (+cl::alnum_p) [cl::assign_a(actions.doc_biblioid.first)]
- >> local.hard_space
+ >> hard_space
>> (+(~cl::eps_p(']') >> local.char_))
                                             [actions.extract_doc_biblioid]
                                             [cl::push_back_a(actions.doc_biblioid_items, actions.doc_biblioid)]
             ;
 
         local.doc_lang =
- "lang" >> local.hard_space
+ "lang" >> hard_space
>> (*(~cl::eps_p(']') >> local.char_))
                                             [actions.extract_doc_lang]
             ;
 
- local.space =
- *(cl::space_p | local.comment)
- ;
-
- local.hard_space =
- (cl::eps_p - (cl::alnum_p | '_')) >> local.space // must not be preceded by
- ; // alpha-numeric or underscore
-
- local.comment =
- "[/" >> *(local.dummy_block | (cl::anychar_p - ']')) >> ']'
- ;
-
- local.dummy_block =
- '[' >> *(local.dummy_block | (cl::anychar_p - ']')) >> ']'
- ;
-
- local.phrase =
- *( common
- | (cl::anychar_p - ']') [actions.plain_char]
- )
- ;
-
         local.char_ =
                 cl::str_p("\\n") [actions.break_]
             | "\\ " // ignore an escaped space

Modified: trunk/tools/quickbook/src/grammar_impl.hpp
==============================================================================
--- trunk/tools/quickbook/src/grammar_impl.hpp (original)
+++ trunk/tools/quickbook/src/grammar_impl.hpp 2010-12-19 08:34:50 EST (Sun, 19 Dec 2010)
@@ -25,21 +25,32 @@
         bool no_eols;
         rule_store store_;
 
- // phrase
+ // Main Grammar
+ cl::rule<scanner> block_start;
+ cl::rule<scanner> block_skip_initial_spaces;
         cl::rule<scanner> common;
         cl::rule<scanner> simple_phrase;
         cl::rule<scanner> phrase;
+ cl::rule<scanner> inside_paragraph;
         cl::rule<scanner> command_line;
+
+ // Miscellaneous stuff
+ cl::rule<scanner> hard_space;
+ cl::rule<scanner> space;
+ cl::rule<scanner> blank;
+ cl::rule<scanner> eol;
+ cl::rule<scanner> phrase_end;
+ cl::rule<scanner> comment;
+ cl::rule<scanner> macro_identifier;
+
+ // Markup Symbols
         cl::symbols<cl::rule<scanner>*> phrase_keyword_rules;
         cl::symbols<cl::rule<scanner>*> phrase_symbol_rules;
 
- // block
- cl::rule<scanner> block_start;
- cl::rule<scanner> block_skip_initial_spaces;
         cl::symbols<cl::rule<scanner>*> block_keyword_rules;
         cl::symbols<cl::rule<scanner>*> block_symbol_rules;
         
- // doc_info
+ // Doc Info
         cl::rule<scanner> doc_info_details;
         
         impl(quickbook::actions&);

Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp (original)
+++ trunk/tools/quickbook/src/main_grammar.cpp 2010-12-19 08:34:50 EST (Sun, 19 Dec 2010)
@@ -62,11 +62,10 @@
         cl::rule<scanner>
                         top_level, blocks, paragraph_separator,
                         block_markup, block_markup_start,
- code, code_line, blank_line,
- space, blank, comment, dummy_block, hr,
- list, ordered_list, list_item, hard_space, eol,
+ code, code_line, blank_line, hr,
+ list, ordered_list, list_item,
                         phrase_markup,
- simple_phrase_end, phrase_end,
+ simple_phrase_end,
                         escape,
                         inline_code, simple_format,
                         simple_bold, simple_italic, simple_underline,
@@ -77,7 +76,8 @@
                         template_inner_arg_1_4, brackets_1_4,
                         template_args_1_5, template_arg_1_5,
                         template_inner_arg_1_5, brackets_1_5,
- command_line_macro_identifier, command_line_phrase
+ command_line_macro_identifier, command_line_phrase,
+ dummy_block
                         ;
 
         cl::rule<scanner> block_keyword_rule;
@@ -91,11 +91,11 @@
         main_grammar_local& local = store_.create();
 
         block_skip_initial_spaces =
- *(cl::blank_p | local.comment) >> block_start
+ *(cl::blank_p | comment) >> block_start
             ;
 
         block_start =
- local.top_level >> local.blank
+ local.top_level >> blank
             ;
 
         local.top_level
@@ -112,7 +112,7 @@
            *( local.code
             | local.list [actions.list]
             | local.hr [actions.hr]
- | +local.eol
+ | +eol
             )
             ;
 
@@ -122,41 +122,16 @@
>> cl::eol_p [actions.inside_paragraph]
             ;
 
- local.space =
- *(cl::space_p | local.comment)
- ;
-
- local.blank =
- *(cl::blank_p | local.comment)
- ;
-
- local.eol = local.blank >> cl::eol_p
- ;
-
- // Follows after an alphanumeric identifier - ensures that it doesn't
- // match an empty space in the middle of the identifier.
- local.hard_space =
- (cl::eps_p - (cl::alnum_p | '_')) >> local.space
- ;
-
- local.comment =
- "[/" >> *(local.dummy_block | (cl::anychar_p - ']')) >> ']'
- ;
-
- local.dummy_block =
- '[' >> *(local.dummy_block | (cl::anychar_p - ']')) >> ']'
- ;
-
         local.hr =
             cl::str_p("----")
- >> *(cl::anychar_p - local.eol)
- >> +local.eol
+ >> *(cl::anychar_p - eol)
+ >> +eol
             ;
 
         local.block_markup
             = local.block_markup_start [actions.inside_paragraph]
>> ( local.block_keyword_rule
- >> ( (local.space >> ']' >> +local.eol)
+ >> ( (space >> ']' >> +eol)
                     | cl::eps_p [actions.error]
                     )
                 | cl::eps_p [actions.error]
@@ -164,7 +139,7 @@
             ;
 
         local.block_markup_start
- = '[' >> local.space
+ = '[' >> space
>> ( block_keyword_rules [detail::assign_rule(local.block_keyword_rule)]
>> (cl::eps_p - (cl::alnum_p | '_'))
                 | block_symbol_rules [detail::assign_rule(local.block_keyword_rule)]
@@ -176,7 +151,7 @@
                 local.code_line
>> *(*local.blank_line >> local.code_line)
             ) [actions.code]
- >> *local.eol
+ >> *eol
             ;
 
         local.code_line =
@@ -205,18 +180,9 @@
                     )
                 ) [actions.plain_char]
             )
- >> +local.eol
+ >> +eol
             ;
 
- local.phrase_end =
- ']' |
- cl::if_p(var(no_eols))
- [
- cl::eol_p >> *cl::blank_p >> cl::eol_p
- // Make sure that we don't go
- ] // past a single block, except
- ; // when preformatted.
-
         common =
                 local.macro
             | local.phrase_markup
@@ -224,7 +190,7 @@
             | local.inline_code
             | local.simple_format
             | local.escape
- | local.comment
+ | comment
             ;
 
         local.macro =
@@ -252,10 +218,10 @@
>> !local.template_args
             ) | (
                 (actions.templates.scope
- >> cl::eps_p(local.hard_space)
+ >> cl::eps_p(hard_space)
                 ) [cl::assign_a(actions.template_identifier)]
                                                 [cl::clear_a(actions.template_args)]
- >> local.space
+ >> space
>> !local.template_args
             ) )
>> cl::eps_p(']')
@@ -345,7 +311,7 @@
             | local.simple_teletype
             ;
 
- local.simple_phrase_end = '[' | local.phrase_end;
+ local.simple_phrase_end = '[' | phrase_end;
 
         simple_markup(local.simple_bold,
             '*', actions.simple_bold, local.simple_phrase_end);
@@ -358,11 +324,17 @@
 
         phrase =
            *( common
- | local.comment
- | (cl::anychar_p - local.phrase_end) [actions.plain_char]
+ | (cl::anychar_p - phrase_end) [actions.plain_char]
             )
             ;
 
+ inside_paragraph =
+ (*( common
+ | (cl::anychar_p - phrase_end) [actions.plain_char]
+ | (+eol) [actions.inside_paragraph]
+ )) [actions.inside_paragraph]
+ ;
+
         local.phrase_markup
             = '['
>> ( phrase_keyword_rules [detail::assign_rule(local.phrase_keyword_rule)]
@@ -385,7 +357,7 @@
             | "\\U" >> cl::repeat_p(8) [cl::chset<>("0-9a-fA-F")]
                                                 [actions.escape_unicode]
             | (
- ("'''" >> !local.eol) [actions.escape_pre]
+ ("'''" >> !eol) [actions.escape_pre]
>> *(cl::anychar_p - "'''") [actions.raw_char]
>> cl::str_p("'''") [actions.escape_post]
                 )
@@ -397,7 +369,6 @@
 
         simple_phrase =
            *( common
- | local.comment
             | (cl::anychar_p - ']') [actions.plain_char]
             )
             ;
@@ -430,5 +401,46 @@
             | (cl::anychar_p - ']') [actions.plain_char]
             )
             ;
+
+ // Miscellaneous stuff
+
+ // Follows an alphanumeric identifier - ensures that it doesn't
+ // match an empty space in the middle of the identifier.
+ hard_space =
+ (cl::eps_p - (cl::alnum_p | '_')) >> space
+ ;
+
+ space =
+ *(cl::space_p | comment)
+ ;
+
+ blank =
+ *(cl::blank_p | comment)
+ ;
+
+ eol = blank >> cl::eol_p
+ ;
+
+ phrase_end =
+ ']' |
+ cl::if_p(var(no_eols))
+ [
+ cl::eol_p >> *cl::blank_p >> cl::eol_p
+ // Make sure that we don't go
+ ] // past a single block, except
+ ; // when preformatted.
+
+ comment =
+ "[/" >> *(local.dummy_block | (cl::anychar_p - ']')) >> ']'
+ ;
+
+ local.dummy_block =
+ '[' >> *(local.dummy_block | (cl::anychar_p - ']')) >> ']'
+ ;
+
+ macro_identifier =
+ +(cl::anychar_p - (cl::space_p | ']'))
+ ;
+
     }
 }

Modified: trunk/tools/quickbook/src/phrase_markup_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/phrase_markup_grammar.cpp (original)
+++ trunk/tools/quickbook/src/phrase_markup_grammar.cpp 2010-12-19 08:34:50 EST (Sun, 19 Dec 2010)
@@ -23,14 +23,14 @@
     struct phrase_markup_grammar_local
     {
         cl::rule<scanner>
- space, blank, comment, image,
- phrase_end, bold, italic, underline, teletype,
+ image,
+ bold, italic, underline, teletype,
                         strikethrough, url, funcref, classref,
                         memberref, enumref, macroref, headerref, conceptref, globalref,
- anchor, link, hard_space, eol,
+ anchor, link,
                         source_mode_cpp, source_mode_python, source_mode_teletype,
                         quote, footnote, replaceable,
- dummy_block, cond_phrase, macro_identifier
+ cond_phrase
                         ;
     };
 
@@ -40,51 +40,13 @@
 
         phrase_markup_grammar_local& local = store_.create();
 
- local.space =
- *(cl::space_p | local.comment)
- ;
-
- local.blank =
- *(cl::blank_p | local.comment)
- ;
-
- local.eol = local.blank >> cl::eol_p
- ;
-
- local.phrase_end =
- ']' |
- cl::if_p(var(no_eols))
- [
- cl::eol_p >> *cl::blank_p >> cl::eol_p
- // Make sure that we don't go
- ] // past a single block, except
- ; // when preformatted.
-
- // Follows an alphanumeric identifier - ensures that it doesn't
- // match an empty space in the middle of the identifier.
- local.hard_space =
- (cl::eps_p - (cl::alnum_p | '_')) >> local.space
- ;
-
- local.comment =
- "[/" >> *(local.dummy_block | (cl::anychar_p - ']')) >> ']'
- ;
-
- local.dummy_block =
- '[' >> *(local.dummy_block | (cl::anychar_p - ']')) >> ']'
- ;
-
- local.macro_identifier =
- +(cl::anychar_p - (cl::space_p | ']'))
- ;
-
         phrase_symbol_rules.add
             ("?", &local.cond_phrase)
             ;
 
         local.cond_phrase =
- local.blank
- >> local.macro_identifier [actions.cond_phrase_pre]
+ blank
+ >> macro_identifier [actions.cond_phrase_pre]
>> (!phrase) [actions.cond_phrase_post]
             ;
 
@@ -93,24 +55,24 @@
             ;
 
         local.image =
- local.blank [cl::clear_a(actions.attributes)]
+ blank [cl::clear_a(actions.attributes)]
>> cl::if_p(qbk_since(105u)) [
                         (+(
                             *cl::space_p
- >> +(cl::anychar_p - (cl::space_p | local.phrase_end | '['))
+ >> +(cl::anychar_p - (cl::space_p | phrase_end | '['))
                         )) [cl::assign_a(actions.image_fileref)]
- >> local.hard_space
+ >> hard_space
>> *(
                             '['
>> (*(cl::alnum_p | '_')) [cl::assign_a(actions.attribute_name)]
- >> local.space
- >> (*(cl::anychar_p - (local.phrase_end | '[')))
+ >> space
+ >> (*(cl::anychar_p - (phrase_end | '[')))
                                                 [actions.attribute]
>> ']'
- >> local.space
+ >> space
                         )
                 ].else_p [
- (*(cl::anychar_p - local.phrase_end))
+ (*(cl::anychar_p - phrase_end))
                                                 [cl::assign_a(actions.image_fileref)]
                 ]
>> cl::eps_p(']') [actions.image]
@@ -122,8 +84,8 @@
 
         local.url =
                 (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.url_pre]
- >> local.hard_space
+ (']' | hard_space))) [actions.url_pre]
+ >> hard_space
>> phrase [actions.url_post]
             ;
 
@@ -132,10 +94,10 @@
             ;
 
         local.link =
- local.space
- >> (*(cl::anychar_p - (']' | local.hard_space)))
+ space
+ >> (*(cl::anychar_p - (']' | hard_space)))
                                                 [actions.link_pre]
- >> local.hard_space
+ >> hard_space
>> phrase [actions.link_post]
             ;
 
@@ -144,8 +106,8 @@
             ;
 
         local.anchor =
- local.blank
- >> (*(cl::anychar_p - local.phrase_end)) [actions.anchor]
+ blank
+ >> (*(cl::anychar_p - phrase_end)) [actions.anchor]
             ;
 
         phrase_keyword_rules.add
@@ -160,66 +122,66 @@
             ;
 
         local.funcref =
- local.space
+ space
>> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.funcref_pre]
- >> local.hard_space
+ (']' | hard_space))) [actions.funcref_pre]
+ >> hard_space
>> phrase [actions.funcref_post]
             ;
 
         local.classref =
- local.space
+ space
>> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.classref_pre]
- >> local.hard_space
+ (']' | hard_space))) [actions.classref_pre]
+ >> hard_space
>> phrase [actions.classref_post]
             ;
 
         local.memberref =
- local.space
+ space
>> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.memberref_pre]
- >> local.hard_space
+ (']' | hard_space))) [actions.memberref_pre]
+ >> hard_space
>> phrase [actions.memberref_post]
             ;
 
         local.enumref =
- local.space
+ space
>> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.enumref_pre]
- >> local.hard_space
+ (']' | hard_space))) [actions.enumref_pre]
+ >> hard_space
>> phrase [actions.enumref_post]
             ;
 
         local.macroref =
- local.space
+ space
>> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.macroref_pre]
- >> local.hard_space
+ (']' | hard_space))) [actions.macroref_pre]
+ >> hard_space
>> phrase [actions.macroref_post]
             ;
 
         local.headerref =
- local.space
+ space
>> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.headerref_pre]
- >> local.hard_space
+ (']' | hard_space))) [actions.headerref_pre]
+ >> hard_space
>> phrase [actions.headerref_post]
             ;
 
         local.conceptref =
- local.space
+ space
>> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.conceptref_pre]
- >> local.hard_space
+ (']' | hard_space))) [actions.conceptref_pre]
+ >> hard_space
>> phrase [actions.conceptref_post]
             ;
 
         local.globalref =
- local.space
+ space
>> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.globalref_pre]
- >> local.hard_space
+ (']' | hard_space))) [actions.globalref_pre]
+ >> hard_space
>> phrase [actions.globalref_post]
             ;
 
@@ -234,37 +196,37 @@
             ;
 
         local.bold =
- local.blank [actions.bold_pre]
+ blank [actions.bold_pre]
>> phrase [actions.bold_post]
             ;
 
         local.italic =
- local.blank [actions.italic_pre]
+ blank [actions.italic_pre]
>> phrase [actions.italic_post]
             ;
 
         local.underline =
- local.blank [actions.underline_pre]
+ blank [actions.underline_pre]
>> phrase [actions.underline_post]
             ;
 
         local.teletype =
- local.blank [actions.teletype_pre]
+ blank [actions.teletype_pre]
>> phrase [actions.teletype_post]
             ;
 
         local.strikethrough =
- local.blank [actions.strikethrough_pre]
+ blank [actions.strikethrough_pre]
>> phrase [actions.strikethrough_post]
             ;
 
         local.quote =
- local.blank [actions.quote_pre]
+ blank [actions.quote_pre]
>> phrase [actions.quote_post]
             ;
 
         local.replaceable =
- local.blank [actions.replaceable_pre]
+ blank [actions.replaceable_pre]
>> phrase [actions.replaceable_post]
             ;
 
@@ -283,7 +245,7 @@
             ;
 
         local.footnote =
- local.blank [actions.footnote_pre]
+ blank [actions.footnote_pre]
>> phrase [actions.footnote_post]
             ;
     }


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