Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r67332 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2010-12-19 08:32:46


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

Log:
Split out the block and phrase markup.
Added:
   trunk/tools/quickbook/src/block_markup_grammar.cpp
      - copied, changed from r67331, /trunk/tools/quickbook/src/block_grammar.cpp
   trunk/tools/quickbook/src/phrase_markup_grammar.cpp (contents, props changed)
Text files modified:
   trunk/tools/quickbook/src/Jamfile.v2 | 2
   trunk/tools/quickbook/src/block_grammar.cpp | 356 ---------------------------------------
   trunk/tools/quickbook/src/block_markup_grammar.cpp | 126 -------------
   trunk/tools/quickbook/src/grammar.cpp | 2
   trunk/tools/quickbook/src/grammar_impl.hpp | 2
   trunk/tools/quickbook/src/phrase_grammar.cpp | 229 ------------------------
   6 files changed, 22 insertions(+), 695 deletions(-)

Modified: trunk/tools/quickbook/src/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/src/Jamfile.v2 (original)
+++ trunk/tools/quickbook/src/Jamfile.v2 2010-12-19 08:32:42 EST (Sun, 19 Dec 2010)
@@ -32,7 +32,9 @@
     syntax_highlight.cpp
     grammar.cpp
     block_grammar.cpp
+ block_markup_grammar.cpp
     phrase_grammar.cpp
+ phrase_markup_grammar.cpp
     doc_info_grammar.cpp
     /boost//program_options
     /boost//filesystem

Modified: trunk/tools/quickbook/src/block_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/block_grammar.cpp (original)
+++ trunk/tools/quickbook/src/block_grammar.cpp 2010-12-19 08:32:42 EST (Sun, 19 Dec 2010)
@@ -14,10 +14,6 @@
 #include "grammar_impl.hpp"
 #include <boost/spirit/include/classic_confix.hpp>
 #include <boost/spirit/include/classic_chset.hpp>
-#include <boost/spirit/include/classic_assign_actor.hpp>
-#include <boost/spirit/include/classic_if.hpp>
-#include <boost/spirit/include/classic_symbols.hpp>
-#include <boost/spirit/include/classic_clear_actor.hpp>
 
 namespace quickbook
 {
@@ -29,18 +25,8 @@
                         top_level, blocks, paragraph_separator,
                         block_markup, block_markup_start,
                         code, code_line, blank_line,
- space, blank, comment, h, h1, h2,
- h3, h4, h5, h6, hr, blurb, blockquote,
- warning, caution, important, note, tip,
- inner_phrase, phrase, list, phrase_end, ordered_list, def_macro,
- macro_identifier, table, table_row, variablelist,
- varlistentry, varlistterm, varlistitem, table_cell,
- preformatted, list_item, begin_section, end_section,
- xinclude, include, hard_space, eol,
- template_, template_id, template_formal_arg,
- template_body, identifier, dummy_block, import,
- inside_paragraph,
- element_id, element_id_1_5, element_id_1_6;
+ space, blank, comment, dummy_block, hr,
+ list, ordered_list, list_item, hard_space, eol;
 
         cl::rule<scanner> block_keyword_rule;
     };
@@ -99,15 +85,6 @@
         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.
-
         // Follows after an alphanumeric identifier - ensures that it doesn't
         // match an empty space in the middle of the identifier.
         local.hard_space =
@@ -146,321 +123,6 @@
                 )
             ;
 
- local.element_id =
- ':'
- >>
- (
- cl::if_p(qbk_since(105u))
- [local.space]
- >> (+(cl::alnum_p | '_')) [cl::assign_a(actions.element_id)]
- | cl::eps_p [actions.element_id_warning]
- [cl::assign_a(actions.element_id)]
- )
- | cl::eps_p [cl::assign_a(actions.element_id)]
- ;
-
- local.element_id_1_5 =
- cl::if_p(qbk_since(105u)) [
- local.element_id
- ]
- .else_p [
- cl::eps_p [cl::assign_a(actions.element_id)]
- ]
- ;
-
- local.element_id_1_6 =
- cl::if_p(qbk_since(106u)) [
- local.element_id
- ]
- .else_p [
- cl::eps_p [cl::assign_a(actions.element_id)]
- ]
- ;
-
- block_keyword_rules.add
- ("section", &local.begin_section)
- ("endsect", &local.end_section)
- ;
-
- local.begin_section =
- local.space
- >> local.element_id
- >> local.space
- >> local.inner_phrase [actions.begin_section]
- ;
-
- local.end_section =
- cl::eps_p [actions.end_section]
- ;
-
- block_keyword_rules.add
- ("heading", &local.h)
- ("h1", &local.h1)
- ("h2", &local.h2)
- ("h3", &local.h3)
- ("h4", &local.h4)
- ("h5", &local.h5)
- ("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];
-
- 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]
- [actions.blurb]
- ;
-
- block_symbol_rules.add
- (":", &local.blockquote)
- ;
-
- local.blockquote =
- local.blank >> scoped_block(actions)[local.inside_paragraph]
- [actions.blockquote]
- ;
-
- block_keyword_rules.add
- ("warning", &local.warning)
- ("caution", &local.caution)
- ("important", &local.important)
- ("note", &local.note)
- ("tip", &local.tip)
- ;
-
- local.warning =
- scoped_block(actions)[local.inside_paragraph]
- [actions.warning]
- ;
-
- local.caution =
- scoped_block(actions)[local.inside_paragraph]
- [actions.caution]
- ;
-
- local.important =
- scoped_block(actions)[local.inside_paragraph]
- [actions.important]
- ;
-
- local.note =
- scoped_block(actions)[local.inside_paragraph]
- [actions.note]
- ;
-
- local.tip =
- scoped_block(actions)[local.inside_paragraph]
- [actions.tip]
- ;
-
- block_keyword_rules.add
- ("pre", &local.preformatted)
- ;
-
- local.preformatted =
- local.space [cl::assign_a(no_eols, false_)]
- >> !local.eol >> local.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]
- ;
-
- local.identifier =
- (cl::alpha_p | '_') >> *(cl::alnum_p | '_')
- ;
-
- local.template_id =
- local.identifier | (cl::punct_p - (cl::ch_p('[') | ']'))
- ;
-
- block_keyword_rules.add
- ("template", &local.template_)
- ;
-
- local.template_ =
- local.space
- >> local.template_id [cl::assign_a(actions.template_identifier)]
- [cl::clear_a(actions.template_info)]
- >>
- !(
- local.space >> '['
- >> *(
- local.space
- >> local.template_id [cl::push_back_a(actions.template_info)]
- )
- >> local.space >> ']'
- )
- >> ( cl::eps_p(*cl::blank_p >> cl::eol_p)
- [cl::assign_a(actions.template_block, true_)]
- | cl::eps_p [cl::assign_a(actions.template_block, false_)]
- )
- >> local.template_body [actions.template_body]
- ;
-
- local.template_body =
- *(('[' >> local.template_body >> ']') | (cl::anychar_p - ']'))
- >> cl::eps_p(local.space >> ']')
- >> local.space
- ;
-
- block_keyword_rules.add
- ("variablelist", &local.variablelist)
- ;
-
- 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]
- >> *local.varlistentry
- >> cl::eps_p [actions.variablelist]
- ;
-
- local.varlistentry =
- local.space
- >> cl::ch_p('[') [actions.start_varlistentry]
- >>
- (
- (
- local.varlistterm
- >> ( scoped_block(actions) [+local.varlistitem]
- [actions.varlistitem]
- | cl::eps_p [actions.error]
- )
- >> cl::ch_p(']') [actions.end_varlistentry]
- >> local.space
- )
- | cl::eps_p [actions.error]
- )
- ;
-
- local.varlistterm =
- local.space
- >> cl::ch_p('[') [actions.start_varlistterm]
- >>
- (
- (
- local.phrase
- >> cl::ch_p(']') [actions.end_varlistterm]
- >> local.space
- )
- | cl::eps_p [actions.error]
- )
- ;
-
- local.varlistitem =
- local.space
- >> cl::ch_p('[')
- >>
- (
- (
- local.inside_paragraph
- >> cl::ch_p(']')
- >> local.space
- )
- | cl::eps_p [actions.error]
- )
- ;
-
- block_keyword_rules.add
- ("table", &local.table)
- ;
-
- local.table =
- (cl::eps_p(*cl::blank_p >> cl::eol_p) | local.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]
- >> *local.table_row
- >> cl::eps_p [actions.table]
- ;
-
- local.table_row =
- local.space
- >> cl::ch_p('[') [actions.start_row]
- >>
- (
- (
- *local.table_cell
- >> cl::ch_p(']') [actions.end_row]
- >> local.space
- )
- | cl::eps_p [actions.error]
- )
- ;
-
- local.table_cell =
- local.space
- >> cl::ch_p('[')
- >> ( scoped_block(actions) [
- local.inside_paragraph
- >> cl::ch_p(']')
- >> local.space
- ] [actions.cell]
- | cl::eps_p [actions.error]
- )
- ;
-
- block_keyword_rules.add
- ("xinclude", &local.xinclude)
- ("import", &local.import)
- ("include", &local.include)
- ;
-
- local.xinclude =
- local.space
- >> (*(cl::anychar_p - local.phrase_end))
- [actions.xinclude]
- ;
-
- local.import =
- local.space
- >> (*(cl::anychar_p - local.phrase_end))
- [actions.import]
- ;
-
- local.include =
- local.space
- >>
- !(
- ':'
- >> (*((cl::alnum_p | '_') - cl::space_p))
- [cl::assign_a(actions.include_doc_id)]
- >> local.space
- )
- >> (*(cl::anychar_p - local.phrase_end))
- [actions.include]
- ;
-
         local.code =
             (
                 local.code_line
@@ -497,19 +159,5 @@
             )
>> +local.eol
             ;
-
- local.inner_phrase =
- cl::eps_p [actions.inner_phrase_pre]
- >> local.phrase
- >> cl::eps_p [actions.inner_phrase_post]
- ;
-
- local.phrase =
- *( common
- | local.comment
- | (cl::anychar_p - local.phrase_end)
- [actions.plain_char]
- )
- ;
     }
 }

Copied: trunk/tools/quickbook/src/block_markup_grammar.cpp (from r67331, /trunk/tools/quickbook/src/block_grammar.cpp)
==============================================================================
--- /trunk/tools/quickbook/src/block_grammar.cpp (original)
+++ trunk/tools/quickbook/src/block_markup_grammar.cpp 2010-12-19 08:32:42 EST (Sun, 19 Dec 2010)
@@ -12,81 +12,36 @@
 #include "utils.hpp"
 #include "actions_class.hpp"
 #include "grammar_impl.hpp"
-#include <boost/spirit/include/classic_confix.hpp>
-#include <boost/spirit/include/classic_chset.hpp>
 #include <boost/spirit/include/classic_assign_actor.hpp>
 #include <boost/spirit/include/classic_if.hpp>
-#include <boost/spirit/include/classic_symbols.hpp>
 #include <boost/spirit/include/classic_clear_actor.hpp>
 
 namespace quickbook
 {
     namespace cl = boost::spirit::classic;
 
- struct block_grammar_local
+ struct block_markup_grammar_local
     {
         cl::rule<scanner>
- top_level, blocks, paragraph_separator,
- block_markup, block_markup_start,
- code, code_line, blank_line,
                         space, blank, comment, h, h1, h2,
- h3, h4, h5, h6, hr, blurb, blockquote,
+ h3, h4, h5, h6, blurb, blockquote,
                         warning, caution, important, note, tip,
- inner_phrase, phrase, list, phrase_end, ordered_list, def_macro,
+ inner_phrase, phrase, phrase_end, def_macro,
                         macro_identifier, table, table_row, variablelist,
                         varlistentry, varlistterm, varlistitem, table_cell,
- preformatted, list_item, begin_section, end_section,
- xinclude, include, hard_space, eol,
+ preformatted, begin_section, end_section,
+ xinclude, include, eol,
                         template_, template_id, template_formal_arg,
                         template_body, identifier, dummy_block, import,
                         inside_paragraph,
                         element_id, element_id_1_5, element_id_1_6;
-
- cl::rule<scanner> block_keyword_rule;
     };
 
- void quickbook_grammar::impl::init_block(bool skip_initial_spaces)
+ void quickbook_grammar::impl::init_block_markup()
     {
         using detail::var;
 
- block_grammar_local& local = store_.create();
-
- if (skip_initial_spaces)
- {
- block_start =
- *(cl::blank_p | local.comment) >> local.top_level >> local.blank
- ;
- }
- else
- {
- block_start =
- local.top_level >> local.blank
- ;
- }
-
- local.top_level
- = local.blocks
- >> *(
- local.block_markup >> local.blocks
- | local.paragraph_separator >> local.blocks
- | common
- | cl::space_p [actions.space_char]
- | cl::anychar_p [actions.plain_char]
- );
-
- local.blocks =
- *( local.code
- | local.list [actions.list]
- | local.hr [actions.hr]
- | +local.eol
- )
- ;
-
- local.paragraph_separator
- = cl::eol_p
- >> *cl::blank_p
- >> cl::eol_p [actions.inside_paragraph]
- ;
+ block_markup_grammar_local& local = store_.create();
 
         local.space =
             *(cl::space_p | local.comment)
@@ -108,12 +63,6 @@
             ] // past a single block, except
             ; // when preformatted.
 
- // 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 - ']')) >> ']'
             ;
@@ -122,30 +71,6 @@
             '[' >> *(local.dummy_block | (cl::anychar_p - ']')) >> ']'
             ;
 
- local.hr =
- cl::str_p("----")
- >> *(cl::anychar_p - local.eol)
- >> +local.eol
- ;
-
- local.block_markup
- = local.block_markup_start [actions.inside_paragraph]
- >> ( local.block_keyword_rule
- >> ( (local.space >> ']' >> +local.eol)
- | cl::eps_p [actions.error]
- )
- | cl::eps_p [actions.error]
- )
- ;
-
- local.block_markup_start
- = '[' >> local.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)]
- )
- ;
-
         local.element_id =
                 ':'
>>
@@ -461,43 +386,6 @@
                                                 [actions.include]
             ;
 
- local.code =
- (
- local.code_line
- >> *(*local.blank_line >> local.code_line)
- ) [actions.code]
- >> *local.eol
- ;
-
- local.code_line =
- cl::blank_p >> *(cl::anychar_p - cl::eol_p) >> cl::eol_p
- ;
-
- local.blank_line =
- *cl::blank_p >> cl::eol_p
- ;
-
- local.list =
- cl::eps_p(cl::ch_p('*') | '#') >>
- +(
- (*cl::blank_p
- >> (cl::ch_p('*') | '#')) [actions.list_format]
- >> *cl::blank_p
- >> local.list_item
- ) [actions.list_item]
- ;
-
- local.list_item =
- *( common
- | (cl::anychar_p -
- ( cl::eol_p >> *cl::blank_p
- >> (cl::ch_p('*') | '#' | cl::eol_p)
- )
- ) [actions.plain_char]
- )
- >> +local.eol
- ;
-
         local.inner_phrase =
                 cl::eps_p [actions.inner_phrase_pre]
>> local.phrase

Modified: trunk/tools/quickbook/src/grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/grammar.cpp (original)
+++ trunk/tools/quickbook/src/grammar.cpp 2010-12-19 08:32:42 EST (Sun, 19 Dec 2010)
@@ -34,6 +34,8 @@
     {
         init_block(skip_initial_spaces);
         init_phrase();
+ init_block_markup();
+ init_phrase_markup();
         init_doc_info();
     }
 }

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:32:42 EST (Sun, 19 Dec 2010)
@@ -47,6 +47,8 @@
 
         void init_block(bool);
         void init_phrase();
+ void init_block_markup();
+ void init_phrase_markup();
         void init_doc_info();
     };
 }

Modified: trunk/tools/quickbook/src/phrase_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/phrase_grammar.cpp (original)
+++ trunk/tools/quickbook/src/phrase_grammar.cpp 2010-12-19 08:32:42 EST (Sun, 19 Dec 2010)
@@ -14,7 +14,6 @@
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_confix.hpp>
 #include <boost/spirit/include/classic_chset.hpp>
-#include <boost/spirit/include/classic_assign_actor.hpp>
 #include <boost/spirit/include/classic_clear_actor.hpp>
 #include <boost/spirit/include/classic_if.hpp>
 #include <boost/spirit/include/classic_loops.hpp>
@@ -60,16 +59,15 @@
     struct phrase_grammar_local
     {
         cl::rule<scanner>
- space, blank, comment, phrase_markup, image,
- simple_phrase_end, phrase_end, bold, italic, underline, teletype,
- strikethrough, escape, url, funcref, classref,
- memberref, enumref, macroref, headerref, conceptref, globalref,
- anchor, link, hard_space, eol, inline_code, simple_format,
+ space, blank, comment, phrase_markup,
+ simple_phrase_end, phrase_end,
+ escape,
+ hard_space, eol, inline_code, simple_format,
                         simple_bold, simple_italic, simple_underline,
                         simple_teletype, template_,
- source_mode_cpp, source_mode_python, source_mode_teletype,
- quote, code_block, footnote, replaceable, macro,
- dummy_block, cond_phrase, macro_identifier, template_args,
+ dummy_block,
+ code_block, macro,
+ template_args,
                         template_args_1_4, template_arg_1_4,
                         template_inner_arg_1_4, brackets_1_4,
                         template_args_1_5, template_arg_1_5,
@@ -294,219 +292,6 @@
                 )
             ;
 
- 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]
- >> (!phrase) [actions.cond_phrase_post]
- ;
-
- phrase_symbol_rules.add
- ("$", &local.image)
- ;
-
- local.image =
- local.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::assign_a(actions.image_fileref)]
- >> local.hard_space
- >> *(
- '['
- >> (*(cl::alnum_p | '_')) [cl::assign_a(actions.attribute_name)]
- >> local.space
- >> (*(cl::anychar_p - (local.phrase_end | '[')))
- [actions.attribute]
- >> ']'
- >> local.space
- )
- ].else_p [
- (*(cl::anychar_p - local.phrase_end))
- [cl::assign_a(actions.image_fileref)]
- ]
- >> cl::eps_p(']') [actions.image]
- ;
-
- phrase_symbol_rules.add
- ("@", &local.url)
- ;
-
- local.url =
- (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.url_pre]
- >> local.hard_space
- >> phrase [actions.url_post]
- ;
-
- phrase_keyword_rules.add
- ("link", &local.link)
- ;
-
- local.link =
- local.space
- >> (*(cl::anychar_p - (']' | local.hard_space)))
- [actions.link_pre]
- >> local.hard_space
- >> phrase [actions.link_post]
- ;
-
- phrase_symbol_rules.add
- ("#", &local.anchor)
- ;
-
- local.anchor =
- local.blank
- >> (*(cl::anychar_p - local.phrase_end)) [actions.anchor]
- ;
-
- phrase_keyword_rules.add
- ("funcref", &local.funcref)
- ("classref", &local.classref)
- ("memberref", &local.memberref)
- ("enumref", &local.enumref)
- ("macroref", &local.macroref)
- ("headerref", &local.headerref)
- ("conceptref", &local.conceptref)
- ("globalref", &local.globalref)
- ;
-
- local.funcref =
- local.space
- >> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.funcref_pre]
- >> local.hard_space
- >> phrase [actions.funcref_post]
- ;
-
- local.classref =
- local.space
- >> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.classref_pre]
- >> local.hard_space
- >> phrase [actions.classref_post]
- ;
-
- local.memberref =
- local.space
- >> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.memberref_pre]
- >> local.hard_space
- >> phrase [actions.memberref_post]
- ;
-
- local.enumref =
- local.space
- >> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.enumref_pre]
- >> local.hard_space
- >> phrase [actions.enumref_post]
- ;
-
- local.macroref =
- local.space
- >> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.macroref_pre]
- >> local.hard_space
- >> phrase [actions.macroref_post]
- ;
-
- local.headerref =
- local.space
- >> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.headerref_pre]
- >> local.hard_space
- >> phrase [actions.headerref_post]
- ;
-
- local.conceptref =
- local.space
- >> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.conceptref_pre]
- >> local.hard_space
- >> phrase [actions.conceptref_post]
- ;
-
- local.globalref =
- local.space
- >> (*(cl::anychar_p -
- (']' | local.hard_space))) [actions.globalref_pre]
- >> local.hard_space
- >> phrase [actions.globalref_post]
- ;
-
- phrase_symbol_rules.add
- ("*", &local.bold)
- ("'", &local.italic)
- ("_", &local.underline)
- ("^", &local.teletype)
- ("-", &local.strikethrough)
- ("\"", &local.quote)
- ("~", &local.replaceable)
- ;
-
- local.bold =
- local.blank [actions.bold_pre]
- >> phrase [actions.bold_post]
- ;
-
- local.italic =
- local.blank [actions.italic_pre]
- >> phrase [actions.italic_post]
- ;
-
- local.underline =
- local.blank [actions.underline_pre]
- >> phrase [actions.underline_post]
- ;
-
- local.teletype =
- local.blank [actions.teletype_pre]
- >> phrase [actions.teletype_post]
- ;
-
- local.strikethrough =
- local.blank [actions.strikethrough_pre]
- >> phrase [actions.strikethrough_post]
- ;
-
- local.quote =
- local.blank [actions.quote_pre]
- >> phrase [actions.quote_post]
- ;
-
- local.replaceable =
- local.blank [actions.replaceable_pre]
- >> phrase [actions.replaceable_post]
- ;
-
- phrase_keyword_rules.add
- ("c++", &local.source_mode_cpp)
- ("python", &local.source_mode_python)
- ("teletype", &local.source_mode_teletype)
- ;
-
- local.source_mode_cpp = cl::eps_p [cl::assign_a(actions.source_mode, "c++")];
- local.source_mode_python = cl::eps_p [cl::assign_a(actions.source_mode, "python")];
- local.source_mode_teletype = cl::eps_p [cl::assign_a(actions.source_mode, "teletype")];
-
- phrase_keyword_rules.add
- ("footnote", &local.footnote)
- ;
-
- local.footnote =
- local.blank [actions.footnote_pre]
- >> phrase [actions.footnote_post]
- ;
-
         //
         // Simple phrase grammar
         //

Added: trunk/tools/quickbook/src/phrase_markup_grammar.cpp
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/src/phrase_markup_grammar.cpp 2010-12-19 08:32:42 EST (Sun, 19 Dec 2010)
@@ -0,0 +1,290 @@
+/*=============================================================================
+ Copyright (c) 2002 2004 2006 Joel de Guzman
+ Copyright (c) 2004 Eric Niebler
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#include "grammar_impl.hpp"
+#include "actions_class.hpp"
+#include "utils.hpp"
+#include <boost/spirit/include/classic_core.hpp>
+#include <boost/spirit/include/classic_assign_actor.hpp>
+#include <boost/spirit/include/classic_clear_actor.hpp>
+#include <boost/spirit/include/classic_if.hpp>
+
+namespace quickbook
+{
+ namespace cl = boost::spirit::classic;
+
+ struct phrase_markup_grammar_local
+ {
+ cl::rule<scanner>
+ space, blank, comment, image,
+ phrase_end, bold, italic, underline, teletype,
+ strikethrough, url, funcref, classref,
+ memberref, enumref, macroref, headerref, conceptref, globalref,
+ anchor, link, hard_space, eol,
+ source_mode_cpp, source_mode_python, source_mode_teletype,
+ quote, footnote, replaceable,
+ dummy_block, cond_phrase, macro_identifier
+ ;
+ };
+
+ void quickbook_grammar::impl::init_phrase_markup()
+ {
+ using detail::var;
+
+ 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]
+ >> (!phrase) [actions.cond_phrase_post]
+ ;
+
+ phrase_symbol_rules.add
+ ("$", &local.image)
+ ;
+
+ local.image =
+ local.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::assign_a(actions.image_fileref)]
+ >> local.hard_space
+ >> *(
+ '['
+ >> (*(cl::alnum_p | '_')) [cl::assign_a(actions.attribute_name)]
+ >> local.space
+ >> (*(cl::anychar_p - (local.phrase_end | '[')))
+ [actions.attribute]
+ >> ']'
+ >> local.space
+ )
+ ].else_p [
+ (*(cl::anychar_p - local.phrase_end))
+ [cl::assign_a(actions.image_fileref)]
+ ]
+ >> cl::eps_p(']') [actions.image]
+ ;
+
+ phrase_symbol_rules.add
+ ("@", &local.url)
+ ;
+
+ local.url =
+ (*(cl::anychar_p -
+ (']' | local.hard_space))) [actions.url_pre]
+ >> local.hard_space
+ >> phrase [actions.url_post]
+ ;
+
+ phrase_keyword_rules.add
+ ("link", &local.link)
+ ;
+
+ local.link =
+ local.space
+ >> (*(cl::anychar_p - (']' | local.hard_space)))
+ [actions.link_pre]
+ >> local.hard_space
+ >> phrase [actions.link_post]
+ ;
+
+ phrase_symbol_rules.add
+ ("#", &local.anchor)
+ ;
+
+ local.anchor =
+ local.blank
+ >> (*(cl::anychar_p - local.phrase_end)) [actions.anchor]
+ ;
+
+ phrase_keyword_rules.add
+ ("funcref", &local.funcref)
+ ("classref", &local.classref)
+ ("memberref", &local.memberref)
+ ("enumref", &local.enumref)
+ ("macroref", &local.macroref)
+ ("headerref", &local.headerref)
+ ("conceptref", &local.conceptref)
+ ("globalref", &local.globalref)
+ ;
+
+ local.funcref =
+ local.space
+ >> (*(cl::anychar_p -
+ (']' | local.hard_space))) [actions.funcref_pre]
+ >> local.hard_space
+ >> phrase [actions.funcref_post]
+ ;
+
+ local.classref =
+ local.space
+ >> (*(cl::anychar_p -
+ (']' | local.hard_space))) [actions.classref_pre]
+ >> local.hard_space
+ >> phrase [actions.classref_post]
+ ;
+
+ local.memberref =
+ local.space
+ >> (*(cl::anychar_p -
+ (']' | local.hard_space))) [actions.memberref_pre]
+ >> local.hard_space
+ >> phrase [actions.memberref_post]
+ ;
+
+ local.enumref =
+ local.space
+ >> (*(cl::anychar_p -
+ (']' | local.hard_space))) [actions.enumref_pre]
+ >> local.hard_space
+ >> phrase [actions.enumref_post]
+ ;
+
+ local.macroref =
+ local.space
+ >> (*(cl::anychar_p -
+ (']' | local.hard_space))) [actions.macroref_pre]
+ >> local.hard_space
+ >> phrase [actions.macroref_post]
+ ;
+
+ local.headerref =
+ local.space
+ >> (*(cl::anychar_p -
+ (']' | local.hard_space))) [actions.headerref_pre]
+ >> local.hard_space
+ >> phrase [actions.headerref_post]
+ ;
+
+ local.conceptref =
+ local.space
+ >> (*(cl::anychar_p -
+ (']' | local.hard_space))) [actions.conceptref_pre]
+ >> local.hard_space
+ >> phrase [actions.conceptref_post]
+ ;
+
+ local.globalref =
+ local.space
+ >> (*(cl::anychar_p -
+ (']' | local.hard_space))) [actions.globalref_pre]
+ >> local.hard_space
+ >> phrase [actions.globalref_post]
+ ;
+
+ phrase_symbol_rules.add
+ ("*", &local.bold)
+ ("'", &local.italic)
+ ("_", &local.underline)
+ ("^", &local.teletype)
+ ("-", &local.strikethrough)
+ ("\"", &local.quote)
+ ("~", &local.replaceable)
+ ;
+
+ local.bold =
+ local.blank [actions.bold_pre]
+ >> phrase [actions.bold_post]
+ ;
+
+ local.italic =
+ local.blank [actions.italic_pre]
+ >> phrase [actions.italic_post]
+ ;
+
+ local.underline =
+ local.blank [actions.underline_pre]
+ >> phrase [actions.underline_post]
+ ;
+
+ local.teletype =
+ local.blank [actions.teletype_pre]
+ >> phrase [actions.teletype_post]
+ ;
+
+ local.strikethrough =
+ local.blank [actions.strikethrough_pre]
+ >> phrase [actions.strikethrough_post]
+ ;
+
+ local.quote =
+ local.blank [actions.quote_pre]
+ >> phrase [actions.quote_post]
+ ;
+
+ local.replaceable =
+ local.blank [actions.replaceable_pre]
+ >> phrase [actions.replaceable_post]
+ ;
+
+ phrase_keyword_rules.add
+ ("c++", &local.source_mode_cpp)
+ ("python", &local.source_mode_python)
+ ("teletype", &local.source_mode_teletype)
+ ;
+
+ local.source_mode_cpp = cl::eps_p [cl::assign_a(actions.source_mode, "c++")];
+ local.source_mode_python = cl::eps_p [cl::assign_a(actions.source_mode, "python")];
+ local.source_mode_teletype = cl::eps_p [cl::assign_a(actions.source_mode, "teletype")];
+
+ phrase_keyword_rules.add
+ ("footnote", &local.footnote)
+ ;
+
+ local.footnote =
+ local.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