diff --git a/src/block_grammar.cpp b/src/block_grammar.cpp index 394a8ec..52d6e5c 100644 --- a/src/block_grammar.cpp +++ b/src/block_grammar.cpp @@ -21,7 +21,7 @@ namespace quickbook { - using namespace boost::spirit::classic; + namespace cl = boost::spirit::classic; template struct block_grammar::definition @@ -30,7 +30,8 @@ namespace quickbook bool no_eols; - rule start_, blocks, block_markup, code, code_line, blank_line, + cl::rule + start_, blocks, block_markup, code, code_line, blank_line, paragraph, space, blank, comment, headings, h, h1, h2, h3, h4, h5, h6, hr, blurb, blockquote, admonition, phrase, list, phrase_end, ordered_list, def_macro, @@ -43,11 +44,11 @@ namespace quickbook inside_paragraph, element_id, element_id_1_5, element_id_1_6; - symbols<> paragraph_end_markups; + cl::symbols<> paragraph_end_markups; phrase_grammar common; - rule const& + cl::rule const& start() const { return start_; } }; @@ -62,7 +63,7 @@ namespace quickbook if (self.skip_initial_spaces) { start_ = - *(blank_p | comment) >> blocks >> blank + *(cl::blank_p | comment) >> blocks >> blank ; } else @@ -84,40 +85,42 @@ namespace quickbook ; space = - *(space_p | comment) + *(cl::space_p | comment) ; blank = - *(blank_p | comment) + *(cl::blank_p | comment) ; - eol = blank >> eol_p + eol = blank >> cl::eol_p ; phrase_end = ']' | - if_p(var(no_eols)) + cl::if_p(var(no_eols)) [ - eol >> *blank_p >> eol_p + 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. hard_space = - (eps_p - (alnum_p | '_')) >> space // must not be preceded by + (cl::eps_p - (cl::alnum_p | '_')) >> space // must not be preceded by ; // alpha-numeric or underscore comment = - "[/" >> *(dummy_block | (anychar_p - ']')) >> ']' + "[/" >> *(dummy_block | (cl::anychar_p - ']')) >> ']' ; dummy_block = - '[' >> *(dummy_block | (anychar_p - ']')) >> ']' + '[' >> *(dummy_block | (cl::anychar_p - ']')) >> ']' ; hr = - str_p("----") - >> *(anychar_p - eol) + cl::str_p("----") + >> *(cl::anychar_p - eol) >> +eol ; @@ -139,7 +142,7 @@ namespace quickbook | template_ ) >> ( (space >> ']' >> +eol) - | eps_p [actions.error] + | cl::eps_p [actions.error] ) ; @@ -147,29 +150,29 @@ namespace quickbook ':' >> ( - if_p(qbk_since(105u)) [space] - >> (+(alnum_p | '_')) [assign_a(actions.element_id)] - | eps_p [actions.element_id_warning] - [assign_a(actions.element_id)] + 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)] ) - | eps_p [assign_a(actions.element_id)] + | cl::eps_p [cl::assign_a(actions.element_id)] ; element_id_1_5 = - if_p(qbk_since(105u)) [ + cl::if_p(qbk_since(105u)) [ element_id ] .else_p [ - eps_p [assign_a(actions.element_id)] + cl::eps_p [cl::assign_a(actions.element_id)] ] ; element_id_1_6 = - if_p(qbk_since(106u)) [ + cl::if_p(qbk_since(106u)) [ element_id ] .else_p [ - eps_p [assign_a(actions.element_id)] + cl::eps_p [cl::assign_a(actions.element_id)] ] ; @@ -182,7 +185,7 @@ namespace quickbook ; end_section = - str_p("endsect") [actions.end_section] + cl::str_p("endsect") [actions.end_section] ; headings = @@ -210,7 +213,7 @@ namespace quickbook blurb = "blurb" >> hard_space >> inside_paragraph [actions.blurb] - >> eps_p + >> cl::eps_p ; blockquote = @@ -236,13 +239,13 @@ namespace quickbook ; preformatted = - "pre" >> hard_space [assign_a(no_eols, false_)] + "pre" >> hard_space [cl::assign_a(no_eols, false_)] >> !eol >> phrase [actions.preformatted] - >> eps_p [assign_a(no_eols, true_)] + >> cl::eps_p [cl::assign_a(no_eols, true_)] ; macro_identifier = - +(anychar_p - (space_p | ']')) + +(cl::anychar_p - (cl::space_p | ']')) ; def_macro = @@ -252,142 +255,143 @@ namespace quickbook ; identifier = - (alpha_p | '_') >> *(alnum_p | '_') + (cl::alpha_p | '_') >> *(cl::alnum_p | '_') ; template_id = - identifier | (punct_p - (ch_p('[') | ']')) + identifier | (cl::punct_p - (cl::ch_p('[') | ']')) ; template_ = "template" >> hard_space - >> template_id [assign_a(actions.template_identifier)] - [clear_a(actions.template_info)] + >> template_id [cl::assign_a(actions.template_identifier)] + [cl::clear_a(actions.template_info)] >> !( space >> '[' >> *( - space >> template_id [push_back_a(actions.template_info)] + space >> template_id [cl::push_back_a(actions.template_info)] ) >> space >> ']' ) - >> ( eps_p(*blank_p >> eol_p) [assign_a(actions.template_block, true_)] - | eps_p [assign_a(actions.template_block, false_)] + >> ( 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_)] ) >> template_body [actions.template_body] ; template_body = - *(('[' >> template_body >> ']') | (anychar_p - ']')) - >> eps_p(space >> ']') + *(('[' >> template_body >> ']') | (cl::anychar_p - ']')) + >> cl::eps_p(space >> ']') >> space ; variablelist = "variablelist" - >> (eps_p(*blank_p >> eol_p) | hard_space) - >> (*(anychar_p - eol)) [assign_a(actions.table_title)] + >> (cl::eps_p(*cl::blank_p >> cl::eol_p) | hard_space) + >> (*(cl::anychar_p - eol)) [cl::assign_a(actions.table_title)] >> +eol >> *varlistentry - >> eps_p [actions.variablelist] + >> cl::eps_p [actions.variablelist] ; varlistentry = space - >> ch_p('[') [actions.start_varlistentry] + >> cl::ch_p('[') [actions.start_varlistentry] >> ( ( varlistterm [actions.start_varlistitem] >> ( +varlistitem - | eps_p [actions.error] + | cl::eps_p [actions.error] ) [actions.end_varlistitem] - >> ch_p(']') [actions.end_varlistentry] + >> cl::ch_p(']') [actions.end_varlistentry] >> space ) - | eps_p [actions.error] + | cl::eps_p [actions.error] ) ; varlistterm = space - >> ch_p('[') [actions.start_varlistterm] + >> cl::ch_p('[') [actions.start_varlistterm] >> ( ( phrase - >> ch_p(']') [actions.end_varlistterm] + >> cl::ch_p(']') [actions.end_varlistterm] >> space ) - | eps_p [actions.error] + | cl::eps_p [actions.error] ) ; varlistitem = space - >> ch_p('[') + >> cl::ch_p('[') >> ( ( inside_paragraph - >> ch_p(']') + >> cl::ch_p(']') >> space ) - | eps_p [actions.error] + | cl::eps_p [actions.error] ) ; table = "table" - >> (eps_p(*blank_p >> eol_p) | hard_space) + >> (cl::eps_p(*cl::blank_p >> cl::eol_p) | hard_space) >> element_id_1_5 - >> (eps_p(*blank_p >> eol_p) | space) - >> (*(anychar_p - eol)) [assign_a(actions.table_title)] + >> (cl::eps_p(*cl::blank_p >> cl::eol_p) | space) + >> (*(cl::anychar_p - eol)) [cl::assign_a(actions.table_title)] >> +eol >> *table_row - >> eps_p [actions.table] + >> cl::eps_p [actions.table] ; table_row = space - >> ch_p('[') [actions.start_row] + >> cl::ch_p('[') [actions.start_row] >> ( ( *table_cell - >> ch_p(']') [actions.end_row] + >> cl::ch_p(']') [actions.end_row] >> space ) - | eps_p [actions.error] + | cl::eps_p [actions.error] ) ; table_cell = space - >> ch_p('[') [actions.start_cell] + >> cl::ch_p('[') [actions.start_cell] >> ( ( inside_paragraph - >> ch_p(']') [actions.end_cell] + >> cl::ch_p(']') [actions.end_cell] >> space ) - | eps_p [actions.error] + | cl::eps_p [actions.error] ) ; xinclude = "xinclude" >> hard_space - >> (*(anychar_p - + >> (*(cl::anychar_p - phrase_end)) [actions.xinclude] ; import = "import" >> hard_space - >> (*(anychar_p - + >> (*(cl::anychar_p - phrase_end)) [actions.import] ; @@ -397,10 +401,11 @@ namespace quickbook >> !( ':' - >> (*((alnum_p | '_') - space_p))[assign_a(actions.include_doc_id)] + >> (*((cl::alnum_p | '_') - cl::space_p)) + [cl::assign_a(actions.include_doc_id)] >> space ) - >> (*(anychar_p - + >> (*(cl::anychar_p - phrase_end)) [actions.include] ; @@ -413,27 +418,27 @@ namespace quickbook ; code_line = - blank_p >> *(anychar_p - eol_p) >> eol_p + cl::blank_p >> *(cl::anychar_p - cl::eol_p) >> cl::eol_p ; blank_line = - *blank_p >> eol_p + *cl::blank_p >> cl::eol_p ; list = - eps_p(ch_p('*') | '#') >> + cl::eps_p(cl::ch_p('*') | '#') >> +( - (*blank_p - >> (ch_p('*') | '#')) [actions.list_format] - >> *blank_p + (*cl::blank_p + >> (cl::ch_p('*') | '#')) [actions.list_format] + >> *cl::blank_p >> list_item ) [actions.list_item] ; list_item = *( common - | (anychar_p - - ( eol_p >> *blank_p >> eps_p(ch_p('*') | '#') + | (cl::anychar_p - + ( cl::eol_p >> *cl::blank_p >> cl::eps_p(cl::ch_p('*') | '#') | (eol >> eol) ) ) [actions.plain_char] @@ -449,28 +454,28 @@ namespace quickbook ; paragraph_end = - '[' >> space >> paragraph_end_markups >> hard_space | eol >> *blank_p >> eol_p + '[' >> space >> paragraph_end_markups >> hard_space | eol >> *cl::blank_p >> cl::eol_p ; paragraph = +( common - | (anychar_p - // Make sure we don't go past + | (cl::anychar_p - // Make sure we don't go past paragraph_end // a single block. ) [actions.plain_char] ) - >> (eps_p('[') | +eol) + >> (cl::eps_p('[') | +eol) ; phrase = *( common | comment - | (anychar_p - + | (cl::anychar_p - phrase_end) [actions.plain_char] ) ; } - parse_info call_parse( + cl::parse_info call_parse( iterator& first, iterator last, block_grammar& g) { return boost::spirit::classic::parse(first, last, g); diff --git a/src/code_snippet.cpp b/src/code_snippet.cpp index 62218ff..92eed67 100644 --- a/src/code_snippet.cpp +++ b/src/code_snippet.cpp @@ -16,7 +16,7 @@ namespace quickbook { - using namespace boost::spirit::classic; + namespace cl = boost::spirit::classic; struct code_snippet_actions { @@ -67,7 +67,7 @@ namespace quickbook }; struct python_code_snippet_grammar - : grammar + : cl::grammar { typedef code_snippet_actions actions_type; @@ -88,7 +88,7 @@ namespace quickbook start_ = *code_elements; identifier = - (alpha_p | '_') >> *(alnum_p | '_') + (cl::alpha_p | '_') >> *(cl::alnum_p | '_') ; code_elements = @@ -96,45 +96,46 @@ namespace quickbook | end_snippet [boost::bind(&actions_type::end_snippet, &actions, _1, _2)] | escaped_comment | ignore - | anychar_p [boost::bind(&actions_type::pass_thru_char, &actions, _1)] + | cl::anychar_p [boost::bind(&actions_type::pass_thru_char, &actions, _1)] ; start_snippet = - "#[" >> *space_p - >> identifier [assign_a(actions.id)] + "#[" >> *cl::space_p + >> identifier [cl::assign_a(actions.id)] ; end_snippet = - str_p("#]") + cl::str_p("#]") ; ignore = - *blank_p >> "#<-" - >> (*(anychar_p - "#->")) - >> "#->" >> *blank_p >> eol_p + *cl::blank_p >> "#<-" + >> (*(cl::anychar_p - "#->")) + >> "#->" >> *cl::blank_p >> cl::eol_p | "\"\"\"<-\"\"\"" - >> (*(anychar_p - "\"\"\"->\"\"\"")) + >> (*(cl::anychar_p - "\"\"\"->\"\"\"")) >> "\"\"\"->\"\"\"" | "\"\"\"<-" - >> (*(anychar_p - "->\"\"\"")) + >> (*(cl::anychar_p - "->\"\"\"")) >> "->\"\"\"" ; escaped_comment = - *space_p >> "#`" - >> ((*(anychar_p - eol_p)) - >> eol_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)] - | *space_p >> "\"\"\"`" - >> (*(anychar_p - "\"\"\"")) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)] + *cl::space_p >> "#`" + >> ((*(cl::anychar_p - cl::eol_p)) + >> cl::eol_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)] + | *cl::space_p >> "\"\"\"`" + >> (*(cl::anychar_p - "\"\"\"")) + [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)] >> "\"\"\"" ; } - rule + cl::rule start_, identifier, code_elements, start_snippet, end_snippet, escaped_comment, ignore; - rule const& + cl::rule const& start() const { return start_; } }; @@ -142,7 +143,7 @@ namespace quickbook }; struct cpp_code_snippet_grammar - : grammar + : cl::grammar { typedef code_snippet_actions actions_type; @@ -160,7 +161,7 @@ namespace quickbook start_ = *code_elements; identifier = - (alpha_p | '_') >> *(alnum_p | '_') + (cl::alpha_p | '_') >> *(cl::alnum_p | '_') ; code_elements = @@ -170,64 +171,65 @@ namespace quickbook | ignore | line_callout | inline_callout - | anychar_p [boost::bind(&actions_type::pass_thru_char, &actions, _1)] + | cl::anychar_p [boost::bind(&actions_type::pass_thru_char, &actions, _1)] ; start_snippet = - "//[" >> *space_p - >> identifier [assign_a(actions.id)] + "//[" >> *cl::space_p + >> identifier [cl::assign_a(actions.id)] | - "/*[" >> *space_p - >> identifier [assign_a(actions.id)] - >> *space_p >> "*/" + "/*[" >> *cl::space_p + >> identifier [cl::assign_a(actions.id)] + >> *cl::space_p >> "*/" ; end_snippet = - str_p("//]") | "/*]*/" + cl::str_p("//]") | "/*]*/" ; inline_callout = "/*<" - >> *space_p - >> (*(anychar_p - ">*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)] + >> *cl::space_p + >> (*(cl::anychar_p - ">*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)] >> ">*/" ; line_callout = "/*<<" - >> *space_p - >> (*(anychar_p - ">>*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)] + >> *cl::space_p + >> (*(cl::anychar_p - ">>*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)] >> ">>*/" - >> *space_p + >> *cl::space_p ; ignore = - *blank_p >> "//<-" - >> (*(anychar_p - "//->")) - >> "//->" >> *blank_p >> eol_p + *cl::blank_p >> "//<-" + >> (*(cl::anychar_p - "//->")) + >> "//->" >> *cl::blank_p >> cl::eol_p | "/*<-*/" - >> (*(anychar_p - "/*->*/")) + >> (*(cl::anychar_p - "/*->*/")) >> "/*->*/" | "/*<-" - >> (*(anychar_p - "->*/")) + >> (*(cl::anychar_p - "->*/")) >> "->*/" ; escaped_comment = - *space_p >> "//`" - >> ((*(anychar_p - eol_p)) - >> eol_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)] - | *space_p >> "/*`" - >> (*(anychar_p - "*/")) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)] + *cl::space_p >> "//`" + >> ((*(cl::anychar_p - cl::eol_p)) + >> cl::eol_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)] + | *cl::space_p >> "/*`" + >> (*(cl::anychar_p - "*/")) + [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)] >> "*/" ; } - rule + cl::rule start_, identifier, code_elements, start_snippet, end_snippet, escaped_comment, inline_callout, line_callout, ignore; - rule const& + cl::rule const& start() const { return start_; } }; diff --git a/src/doc_info_grammar.cpp b/src/doc_info_grammar.cpp index d3deb15..73ea1a5 100644 --- a/src/doc_info_grammar.cpp +++ b/src/doc_info_grammar.cpp @@ -19,26 +19,27 @@ namespace quickbook { - using namespace boost::spirit::classic; + namespace cl = boost::spirit::classic; template struct doc_info_grammar::definition { definition(doc_info_grammar const&); - typedef uint_parser uint2_t; + typedef cl::uint_parser uint2_t; bool unused; std::string category; - rule doc_info, doc_title, doc_version, doc_id, doc_dirname, + cl::rule + doc_info, doc_title, doc_version, doc_id, doc_dirname, doc_copyright, doc_purpose, doc_category, doc_authors, doc_author, comment, space, hard_space, doc_license, doc_last_revision, doc_source_mode, phrase, quickbook_version, char_; phrase_grammar common; - symbols<> doc_types; + cl::symbols<> doc_types; - rule const& + cl::rule const& start() const { return doc_info; } }; @@ -57,9 +58,9 @@ namespace quickbook doc_info = space >> '[' >> space - >> (doc_types >> eps_p) [assign_a(actions.doc_type)] + >> (doc_types >> cl::eps_p) [cl::assign_a(actions.doc_type)] >> hard_space - >> ( *(~eps_p(ch_p('[') | ']' | eol_p) >> char_) + >> ( *(~cl::eps_p(cl::ch_p('[') | ']' | cl::eol_p) >> char_) ) [actions.extract_doc_title] >> !( space >> '[' >> @@ -73,7 +74,7 @@ namespace quickbook doc_version | doc_id | doc_dirname - | doc_copyright [push_back_a(actions.doc_copyrights, actions.copyright)] + | doc_copyright [cl::push_back_a(actions.doc_copyrights, actions.copyright)] | doc_purpose | doc_category | doc_authors @@ -81,43 +82,48 @@ namespace quickbook | doc_last_revision | doc_source_mode ) - >> space >> ']' >> +eol_p + >> space >> ']' >> +cl::eol_p ) - >> space >> ']' >> +eol_p + >> space >> ']' >> +cl::eol_p ; quickbook_version = "quickbook" >> hard_space - >> ( uint_p [assign_a(qbk_major_version)] + >> ( cl::uint_p [cl::assign_a(qbk_major_version)] >> '.' - >> uint2_t() [assign_a(qbk_minor_version)] + >> uint2_t() [cl::assign_a(qbk_minor_version)] ) ; doc_version = "version" >> hard_space - >> (*(~eps_p(']') >> char_)) [actions.extract_doc_version] + >> (*(~cl::eps_p(']') >> char_)) + [actions.extract_doc_version] ; // TODO: Restrictions on doc_id? doc_id = "id" >> hard_space - >> (*(~eps_p(']') >> char_)) [actions.extract_doc_id] + >> (*(~cl::eps_p(']') >> char_)) + [actions.extract_doc_id] ; // TODO: Restrictions on doc_dirname? doc_dirname = "dirname" >> hard_space - >> (*(~eps_p(']') >> char_)) [actions.extract_doc_dirname] + >> (*(~cl::eps_p(']') >> char_)) + [actions.extract_doc_dirname] ; doc_copyright = - "copyright" >> hard_space [clear_a(actions.copyright.first)] - >> +( repeat_p(4)[digit_p] [push_back_a(actions.copyright.first)] + "copyright" >> hard_space [cl::clear_a(actions.copyright.first)] + >> +( cl::repeat_p(4)[cl::digit_p] + [cl::push_back_a(actions.copyright.first)] >> space ) >> space - >> (*(~eps_p(']') >> char_)) [actions.extract_copyright_second] + >> (*(~cl::eps_p(']') >> char_)) + [actions.extract_copyright_second] ; doc_purpose = @@ -127,25 +133,28 @@ namespace quickbook doc_category = "category" >> hard_space - >> (*(~eps_p(']') >> char_)) [actions.extract_doc_category] - [push_back_a(actions.doc_categories, actions.doc_category)] + >> (*(~cl::eps_p(']') >> char_)) + [actions.extract_doc_category] + [cl::push_back_a(actions.doc_categories, actions.doc_category)] ; doc_author = '[' >> space - >> (*(~eps_p(',') >> char_)) [actions.extract_name_second] // surname + >> (*(~cl::eps_p(',') >> char_)) + [actions.extract_name_second] >> ',' >> space - >> (*(~eps_p(']') >> char_)) [actions.extract_name_first] // firstname + >> (*(~cl::eps_p(']') >> char_)) + [actions.extract_name_first] >> ']' ; doc_authors = "authors" >> hard_space - >> doc_author [push_back_a(actions.doc_authors, actions.name)] + >> doc_author [cl::push_back_a(actions.doc_authors, actions.name)] >> space - >> *( !(ch_p(',') >> space) - >> doc_author [push_back_a(actions.doc_authors, actions.name)] + >> *( !(cl::ch_p(',') >> space) + >> doc_author [cl::push_back_a(actions.doc_authors, actions.name)] >> space ) ; @@ -157,55 +166,58 @@ namespace quickbook doc_last_revision = "last-revision" >> hard_space - >> (*(~eps_p(']') >> char_)) [actions.extract_doc_last_revision] + >> (*(~cl::eps_p(']') >> char_)) + [actions.extract_doc_last_revision] ; doc_source_mode = "source-mode" >> hard_space >> ( - str_p("c++") + cl::str_p("c++") | "python" | "teletype" - ) [assign_a(actions.source_mode)] + ) [cl::assign_a(actions.source_mode)] ; comment = - "[/" >> *(anychar_p - ']') >> ']' + "[/" >> *(cl::anychar_p - ']') >> ']' ; space = - *(space_p | comment) + *(cl::space_p | comment) ; hard_space = - (eps_p - (alnum_p | '_')) >> space // must not be preceded by + (cl::eps_p - (cl::alnum_p | '_')) >> space // must not be preceded by ; // alpha-numeric or underscore phrase = *( common | comment - | (anychar_p - ']') [actions.plain_char] + | (cl::anychar_p - ']') [actions.plain_char] ) ; char_ = - str_p("\\n") [actions.break_] + cl::str_p("\\n") [actions.break_] | "\\ " // ignore an escaped space - | '\\' >> punct_p [actions.raw_char] - | "\\u" >> repeat_p(4) [chset<>("0-9a-fA-F")] + | '\\' >> cl::punct_p [actions.raw_char] + | "\\u" >> cl::repeat_p(4) + [cl::chset<>("0-9a-fA-F")] [actions.escape_unicode] - | "\\U" >> repeat_p(8) [chset<>("0-9a-fA-F")] + | "\\U" >> cl::repeat_p(8) + [cl::chset<>("0-9a-fA-F")] [actions.escape_unicode] | ( - ("'''" >> !eol_p) [actions.escape_pre] - >> *(anychar_p - "'''") [actions.raw_char] - >> str_p("'''") [actions.escape_post] + ("'''" >> !cl::eol_p) [actions.escape_pre] + >> *(cl::anychar_p - "'''")[actions.raw_char] + >> cl::str_p("'''") [actions.escape_post] ) - | anychar_p [actions.plain_char] + | cl::anychar_p [actions.plain_char] ; } - parse_info call_parse( + cl::parse_info call_parse( iterator& first, iterator last, doc_info_grammar& g) { return boost::spirit::classic::parse(first, last, g); diff --git a/src/phrase_grammar.cpp b/src/phrase_grammar.cpp index bd6a5d8..3dbd58a 100644 --- a/src/phrase_grammar.cpp +++ b/src/phrase_grammar.cpp @@ -23,24 +23,24 @@ namespace quickbook phrase = *( common | comment - | (anychar_p - ']') [actions.plain_char] + | (cl::anychar_p - ']') [actions.plain_char] ) ; comment = - "[/" >> *(dummy_block | (anychar_p - ']')) >> ']' + "[/" >> *(dummy_block | (cl::anychar_p - ']')) >> ']' ; dummy_block = - '[' >> *(dummy_block | (anychar_p - ']')) >> ']' + '[' >> *(dummy_block | (cl::anychar_p - ']')) >> ']' ; } bool unused; - rule phrase, comment, dummy_block; + cl::rule phrase, comment, dummy_block; phrase_grammar common; - rule const& + cl::rule const& start() const { return phrase; } }; @@ -53,49 +53,49 @@ namespace quickbook quickbook::actions& actions = self.actions; macro = - *space_p + *cl::space_p >> macro_identifier [actions.macro_identifier] - >> *space_p + >> *cl::space_p >> ( '=' - >> *space_p + >> *cl::space_p >> phrase [actions.macro_definition] - >> *space_p + >> *cl::space_p ) - | eps_p [actions.macro_definition] + | cl::eps_p [actions.macro_definition] ; macro_identifier = - +(anychar_p - (space_p | ']' | '=')) + +(cl::anychar_p - (cl::space_p | ']' | '=')) ; phrase = *( common - | (anychar_p - ']') [actions.plain_char] + | (cl::anychar_p - ']') [actions.plain_char] ) ; } bool unused; - rule macro, macro_identifier, phrase; + cl::rule macro, macro_identifier, phrase; phrase_grammar common; - rule const& + cl::rule const& start() const { return macro; } }; - parse_info call_parse( + cl::parse_info call_parse( iterator& first, iterator last, phrase_grammar& g) { return boost::spirit::classic::parse(first, last, g); } - parse_info call_parse( + cl::parse_info call_parse( iterator& first, iterator last, simple_phrase_grammar& g) { return boost::spirit::classic::parse(first, last, g); } - parse_info call_parse( + cl::parse_info call_parse( iterator& first, iterator last, command_line_grammar& g) { return boost::spirit::classic::parse(first, last, g); diff --git a/src/phrase_grammar.hpp b/src/phrase_grammar.hpp index 31181c9..c5ed102 100644 --- a/src/phrase_grammar.hpp +++ b/src/phrase_grammar.hpp @@ -25,7 +25,6 @@ namespace quickbook { namespace cl = boost::spirit::classic; - using namespace boost::spirit::classic; template inline void @@ -40,20 +39,20 @@ namespace quickbook mark >> ( ( - graph_p // A single char. e.g. *c* - >> eps_p(mark - >> (space_p | punct_p | end_p)) + cl::graph_p // A single char. e.g. *c* + >> cl::eps_p(mark + >> (cl::space_p | cl::punct_p | cl::end_p)) // space_p, punct_p or end_p ) // must follow mark | - ( graph_p >> // graph_p must follow mark - *(anychar_p - - ( (graph_p >> mark) // Make sure that we don't go - | close // past a single block + ( cl::graph_p >> // graph_p must follow mark + *(cl::anychar_p - + ( (cl::graph_p >> mark) // Make sure that we don't go + | close // past a single block ) - ) >> graph_p // graph_p must precede mark - >> eps_p(mark - >> (space_p | punct_p | end_p)) + ) >> cl::graph_p // graph_p must precede mark + >> cl::eps_p(mark + >> (cl::space_p | cl::punct_p | cl::end_p)) // space_p, punct_p or end_p ) // must follow mark ) [action] @@ -93,34 +92,36 @@ namespace quickbook quickbook::actions& actions = self.actions; space = - *(space_p | comment) + *(cl::space_p | comment) ; blank = - *(blank_p | comment) + *(cl::blank_p | comment) ; - eol = blank >> eol_p + eol = blank >> cl::eol_p ; phrase_end = ']' | - if_p(var(self.no_eols)) + cl::if_p(var(self.no_eols)) [ eol >> eol // 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. hard_space = - (eps_p - (alnum_p | '_')) >> space // must not be preceded by - ; // alpha-numeric or underscore + (cl::eps_p - (cl::alnum_p | '_')) >> space + ; comment = - "[/" >> *(dummy_block | (anychar_p - ']')) >> ']' + "[/" >> *(dummy_block | (cl::anychar_p - ']')) >> ']' ; dummy_block = - '[' >> *(dummy_block | (anychar_p - ']')) >> ']' + '[' >> *(dummy_block | (cl::anychar_p - ']')) >> ']' ; common = @@ -134,8 +135,9 @@ namespace quickbook ; macro = - eps_p(actions.macro // must not be followed by - >> (eps_p - (alpha_p | '_'))) // alpha or underscore + // must not be followed by alpha or underscore + cl::eps_p(actions.macro + >> (cl::eps_p - (cl::alpha_p | '_'))) >> actions.macro [actions.do_macro] ; @@ -144,30 +146,30 @@ namespace quickbook template_ = ( - ch_p('`') [assign_a(actions.template_escape,true_)] + cl::ch_p('`') [cl::assign_a(actions.template_escape,true_)] | - eps_p [assign_a(actions.template_escape,false_)] + cl::eps_p [cl::assign_a(actions.template_escape,false_)] ) >> ( ( - (eps_p(punct_p) + (cl::eps_p(cl::punct_p) >> actions.templates.scope - ) [assign_a(actions.template_identifier)] - [clear_a(actions.template_args)] + ) [cl::assign_a(actions.template_identifier)] + [cl::clear_a(actions.template_args)] >> !template_args ) | ( (actions.templates.scope - >> eps_p(hard_space) - ) [assign_a(actions.template_identifier)] - [clear_a(actions.template_args)] + >> cl::eps_p(hard_space) + ) [cl::assign_a(actions.template_identifier)] + [cl::clear_a(actions.template_args)] >> space >> !template_args ) ) - >> eps_p(']') + >> cl::eps_p(']') ; template_args = - if_p(qbk_since(105u)) [ + cl::if_p(qbk_since(105u)) [ template_args_1_5 ].else_p [ template_args_1_4 @@ -177,14 +179,15 @@ namespace quickbook template_args_1_4 = template_arg_1_4 >> *(".." >> template_arg_1_4); template_arg_1_4 = - ( eps_p(*blank_p >> eol_p) [assign_a(actions.template_block, true_)] - | eps_p [assign_a(actions.template_block, false_)] + ( 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_)] ) >> template_inner_arg_1_4 [actions.template_arg] ; template_inner_arg_1_4 = - +(brackets_1_4 | (anychar_p - (str_p("..") | ']'))) + +(brackets_1_4 | (cl::anychar_p - (cl::str_p("..") | ']'))) ; brackets_1_4 = @@ -194,15 +197,16 @@ namespace quickbook template_args_1_5 = template_arg_1_5 >> *(".." >> template_arg_1_5); template_arg_1_5 = - ( eps_p(*blank_p >> eol_p) [assign_a(actions.template_block, true_)] - | eps_p [assign_a(actions.template_block, false_)] + ( 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_)] ) - >> (+(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p("..") | '[' | ']')))) + >> (+(brackets_1_5 | ('\\' >> cl::anychar_p) | (cl::anychar_p - (cl::str_p("..") | '[' | ']')))) [actions.template_arg] ; template_inner_arg_1_5 = - +(brackets_1_5 | ('\\' >> anychar_p) | (anychar_p - (str_p('[') | ']'))) + +(brackets_1_5 | ('\\' >> cl::anychar_p) | (cl::anychar_p - (cl::str_p('[') | ']'))) ; brackets_1_5 = @@ -212,11 +216,11 @@ namespace quickbook inline_code = '`' >> ( - *(anychar_p - + *(cl::anychar_p - ( '`' | (eol >> eol) // Make sure that we don't go ) // past a single block - ) >> eps_p('`') + ) >> cl::eps_p('`') ) [actions.inline_code] >> '`' ; @@ -225,16 +229,16 @@ namespace quickbook ( "```" >> ( - *(anychar_p - "```") - >> eps_p("```") + *(cl::anychar_p - "```") + >> cl::eps_p("```") ) [actions.code_block] >> "```" ) | ( "``" >> ( - *(anychar_p - "``") - >> eps_p("``") + *(cl::anychar_p - "``") + >> cl::eps_p("``") ) [actions.code_block] >> "``" ) @@ -261,7 +265,7 @@ namespace quickbook phrase = *( common | comment - | (anychar_p - phrase_end) [actions.plain_char] + | (cl::anychar_p - phrase_end) [actions.plain_char] ) ; @@ -290,27 +294,27 @@ namespace quickbook | replaceable | footnote | template_ [actions.do_template] - | str_p("br") [actions.break_] + | cl::str_p("br") [actions.break_] ) >> ']' ; escape = - str_p("\\ ") // ignore an escaped space - | '\\' >> punct_p [actions.raw_char] - | "\\u" >> repeat_p(4) [chset<>("0-9a-fA-F")] + cl::str_p("\\ ") // ignore an escaped space + | '\\' >> cl::punct_p [actions.raw_char] + | "\\u" >> cl::repeat_p(4) [cl::chset<>("0-9a-fA-F")] [actions.escape_unicode] - | "\\U" >> repeat_p(8) [chset<>("0-9a-fA-F")] + | "\\U" >> cl::repeat_p(8) [cl::chset<>("0-9a-fA-F")] [actions.escape_unicode] | ( ("'''" >> !eol) [actions.escape_pre] - >> *(anychar_p - "'''") [actions.raw_char] - >> str_p("'''") [actions.escape_post] + >> *(cl::anychar_p - "'''") [actions.raw_char] + >> cl::str_p("'''") [actions.escape_post] ) ; macro_identifier = - +(anychar_p - (space_p | ']')) + +(cl::anychar_p - (cl::space_p | ']')) ; cond_phrase = @@ -320,43 +324,43 @@ namespace quickbook ; image = - '$' >> blank [clear_a(actions.attributes)] - >> if_p(qbk_since(105u)) [ + '$' >> blank [cl::clear_a(actions.attributes)] + >> cl::if_p(qbk_since(105u)) [ (+( - *space_p - >> +(anychar_p - (space_p | phrase_end | '[')) - )) [assign_a(actions.image_fileref)] + *cl::space_p + >> +(cl::anychar_p - (cl::space_p | phrase_end | '[')) + )) [cl::assign_a(actions.image_fileref)] >> hard_space >> *( '[' - >> (*(alnum_p | '_')) [assign_a(actions.attribute_name)] + >> (*(cl::alnum_p | '_')) [cl::assign_a(actions.attribute_name)] >> space - >> (*(anychar_p - (phrase_end | '['))) + >> (*(cl::anychar_p - (phrase_end | '['))) [actions.attribute] >> ']' >> space ) ].else_p [ - (*(anychar_p - - phrase_end)) [assign_a(actions.image_fileref)] + (*(cl::anychar_p - phrase_end)) + [cl::assign_a(actions.image_fileref)] ] - >> eps_p(']') [actions.image] + >> cl::eps_p(']') [actions.image] ; url = '@' - >> (*(anychar_p - + >> (*(cl::anychar_p - (']' | hard_space))) [actions.url_pre] - >> ( eps_p(']') + >> ( cl::eps_p(']') | (hard_space >> phrase) ) [actions.url_post] ; link = "link" >> hard_space - >> (*(anychar_p - + >> (*(cl::anychar_p - (']' | hard_space))) [actions.link_pre] - >> ( eps_p(']') + >> ( cl::eps_p(']') | (hard_space >> phrase) ) [actions.link_post] ; @@ -364,128 +368,127 @@ namespace quickbook anchor = '#' >> blank - >> ( *(anychar_p - - phrase_end) + >> ( *(cl::anychar_p - phrase_end) ) [actions.anchor] ; funcref = "funcref" >> hard_space - >> (*(anychar_p - + >> (*(cl::anychar_p - (']' | hard_space))) [actions.funcref_pre] - >> ( eps_p(']') + >> ( cl::eps_p(']') | (hard_space >> phrase) ) [actions.funcref_post] ; classref = "classref" >> hard_space - >> (*(anychar_p - + >> (*(cl::anychar_p - (']' | hard_space))) [actions.classref_pre] - >> ( eps_p(']') + >> ( cl::eps_p(']') | (hard_space >> phrase) ) [actions.classref_post] ; memberref = "memberref" >> hard_space - >> (*(anychar_p - + >> (*(cl::anychar_p - (']' | hard_space))) [actions.memberref_pre] - >> ( eps_p(']') + >> ( cl::eps_p(']') | (hard_space >> phrase) ) [actions.memberref_post] ; enumref = "enumref" >> hard_space - >> (*(anychar_p - + >> (*(cl::anychar_p - (']' | hard_space))) [actions.enumref_pre] - >> ( eps_p(']') + >> ( cl::eps_p(']') | (hard_space >> phrase) ) [actions.enumref_post] ; macroref = "macroref" >> hard_space - >> (*(anychar_p - + >> (*(cl::anychar_p - (']' | hard_space))) [actions.macroref_pre] - >> ( eps_p(']') + >> ( cl::eps_p(']') | (hard_space >> phrase) ) [actions.macroref_post] ; headerref = "headerref" >> hard_space - >> (*(anychar_p - + >> (*(cl::anychar_p - (']' | hard_space))) [actions.headerref_pre] - >> ( eps_p(']') + >> ( cl::eps_p(']') | (hard_space >> phrase) ) [actions.headerref_post] ; conceptref = "conceptref" >> hard_space - >> (*(anychar_p - + >> (*(cl::anychar_p - (']' | hard_space))) [actions.conceptref_pre] - >> ( eps_p(']') + >> ( cl::eps_p(']') | (hard_space >> phrase) ) [actions.conceptref_post] ; globalref = "globalref" >> hard_space - >> (*(anychar_p - + >> (*(cl::anychar_p - (']' | hard_space))) [actions.globalref_pre] - >> ( eps_p(']') + >> ( cl::eps_p(']') | (hard_space >> phrase) ) [actions.globalref_post] ; bold = - ch_p('*') [actions.bold_pre] + cl::ch_p('*') [actions.bold_pre] >> blank >> phrase [actions.bold_post] ; italic = - ch_p('\'') [actions.italic_pre] + cl::ch_p('\'') [actions.italic_pre] >> blank >> phrase [actions.italic_post] ; underline = - ch_p('_') [actions.underline_pre] + cl::ch_p('_') [actions.underline_pre] >> blank >> phrase [actions.underline_post] ; teletype = - ch_p('^') [actions.teletype_pre] + cl::ch_p('^') [actions.teletype_pre] >> blank >> phrase [actions.teletype_post] ; strikethrough = - ch_p('-') [actions.strikethrough_pre] + cl::ch_p('-') [actions.strikethrough_pre] >> blank >> phrase [actions.strikethrough_post] ; quote = - ch_p('"') [actions.quote_pre] + cl::ch_p('"') [actions.quote_pre] >> blank >> phrase [actions.quote_post] ; replaceable = - ch_p('~') [actions.replaceable_pre] + cl::ch_p('~') [actions.replaceable_pre] >> blank >> phrase [actions.replaceable_post] ; source_mode = ( - str_p("c++") + cl::str_p("c++") | "python" | "teletype" - ) [assign_a(actions.source_mode)] + ) [cl::assign_a(actions.source_mode)] ; footnote = - str_p("footnote") [actions.footnote_pre] + cl::str_p("footnote") [actions.footnote_pre] >> blank >> phrase [actions.footnote_post] ; } diff --git a/src/post_process.cpp b/src/post_process.cpp index 8e48380..9c98aa2 100644 --- a/src/post_process.cpp +++ b/src/post_process.cpp @@ -16,8 +16,7 @@ namespace quickbook { - using namespace boost::spirit::classic; - using boost::bind; + namespace cl = boost::spirit::classic; typedef std::string::const_iterator iter_type; struct printer @@ -256,7 +255,7 @@ namespace quickbook std::string current_tag; }; - struct tidy_grammar : grammar + struct tidy_grammar : cl::grammar { tidy_grammar(tidy_compiler& state, int indent) : state(state), indent(indent) {} @@ -266,43 +265,43 @@ namespace quickbook { definition(tidy_grammar const& self) { - tag = (lexeme_d[+(alpha_p | '_' | ':')]) [boost::bind(&tidy_grammar::do_tag, &self, _1, _2)]; + tag = (cl::lexeme_d[+(cl::alpha_p | '_' | ':')]) [boost::bind(&tidy_grammar::do_tag, &self, _1, _2)]; code = "" - >> *(anychar_p - "") + >> *(cl::anychar_p - "") >> "" ; - // What's the business of lexeme_d['>' >> *space_p]; ? + // What's the business of cl::lexeme_d['>' >> *cl::space_p]; ? // It is there to preserve the space after the tag that is - // otherwise consumed by the space_p skipper. + // otherwise consumed by the cl::space_p skipper. escape = - str_p("") >> - (*(anychar_p - str_p(""))) + cl::str_p("") >> + (*(cl::anychar_p - cl::str_p(""))) [ boost::bind(&tidy_grammar::do_escape, &self, _1, _2) ] - >> lexeme_d + >> cl::lexeme_d [ - str_p("") >> - (*space_p) + cl::str_p("") >> + (*cl::space_p) [ boost::bind(&tidy_grammar::do_escape_post, &self, _1, _2) ] ] ; - start_tag = '<' >> tag >> *(anychar_p - '>') >> lexeme_d['>' >> *space_p]; + start_tag = '<' >> tag >> *(cl::anychar_p - '>') >> cl::lexeme_d['>' >> *cl::space_p]; start_end_tag = - '<' >> tag >> *(anychar_p - ("/>" | ch_p('>'))) >> lexeme_d["/>" >> *space_p] - | "> tag >> *(anychar_p - '?') >> lexeme_d["?>" >> *space_p] - | "") >> lexeme_d["-->" >> *space_p] - | "> tag >> *(anychar_p - '>') >> lexeme_d['>' >> *space_p] + '<' >> tag >> *(cl::anychar_p - ("/>" | cl::ch_p('>'))) >> cl::lexeme_d["/>" >> *cl::space_p] + | "> tag >> *(cl::anychar_p - '?') >> cl::lexeme_d["?>" >> *cl::space_p] + | "") >> cl::lexeme_d["-->" >> *cl::space_p] + | "> tag >> *(cl::anychar_p - '>') >> cl::lexeme_d['>' >> *cl::space_p] ; - content = lexeme_d[ +(anychar_p - '<') ]; - end_tag = "> +(anychar_p - '>') >> lexeme_d['>' >> *space_p]; + content = cl::lexeme_d[ +(cl::anychar_p - '<') ]; + end_tag = "> +(cl::anychar_p - '>') >> cl::lexeme_d['>' >> *cl::space_p]; markup = escape @@ -316,10 +315,11 @@ namespace quickbook tidy = +markup; } - rule const& + cl::rule const& start() { return tidy; } - rule tidy, tag, start_tag, start_end_tag, + cl::rule + tidy, tag, start_tag, start_end_tag, content, end_tag, markup, code, escape; }; @@ -435,7 +435,7 @@ namespace quickbook std::string tidy; tidy_compiler state(tidy, linewidth); tidy_grammar g(state, indent); - parse_info r = parse(in.begin(), in.end(), g, space_p); + cl::parse_info r = parse(in.begin(), in.end(), g, cl::space_p); if (r.full) { out << tidy; diff --git a/src/quickbook.cpp b/src/quickbook.cpp index e66fa2e..d894a4c 100644 --- a/src/quickbook.cpp +++ b/src/quickbook.cpp @@ -32,8 +32,9 @@ namespace quickbook { - using namespace boost::spirit::classic; + namespace cl = boost::spirit::classic; namespace fs = boost::filesystem; + tm* current_time; // the current time tm* current_gm_time; // the current UTC time bool debug_mode; // for quickbook developers only @@ -84,7 +85,7 @@ namespace quickbook iterator last(storage.end(), storage.end()); doc_info_grammar l(actor); - parse_info info = call_parse(first, last, l); + cl::parse_info info = call_parse(first, last, l); if (info.hit || ignore_docinfo) { diff --git a/src/syntax_highlight.hpp b/src/syntax_highlight.hpp index 2592cc5..703ae90 100644 --- a/src/syntax_highlight.hpp +++ b/src/syntax_highlight.hpp @@ -19,7 +19,7 @@ namespace quickbook { - using namespace boost::spirit::classic; + namespace cl = boost::spirit::classic; // Grammar for C++ highlighting template < @@ -32,7 +32,7 @@ namespace quickbook , typename Unexpected , typename Out> struct cpp_highlight - : public grammar > + : public cl::grammar > { cpp_highlight(Out& out, Macro const& macro, DoMacro do_macro, actions& escape_actions) : out(out), macro(macro), do_macro(do_macro), escape_actions(escape_actions) {} @@ -46,7 +46,7 @@ namespace quickbook { program = - *( (+space_p) [Space(self.out)] + *( (+cl::space_p) [Space(self.out)] | macro | escape | preprocessor [Process("preprocessor", self.out)] @@ -57,51 +57,54 @@ namespace quickbook | string_ [Process("string", self.out)] | char_ [Process("char", self.out)] | number [Process("number", self.out)] - | repeat_p(1)[anychar_p] [Unexpected(self.out)] + | cl::repeat_p(1)[cl::anychar_p] + [Unexpected(self.out)] ) ; - macro = - eps_p(self.macro // must not be followed by - >> (eps_p - (alpha_p | '_'))) // alpha or underscore + macro = + // must not be followed by alpha or underscore + cl::eps_p(self.macro + >> (cl::eps_p - (cl::alpha_p | '_'))) >> self.macro [self.do_macro] ; qbk_phrase = *( common - | (anychar_p - str_p("``")) [self.escape_actions.plain_char] + | (cl::anychar_p - cl::str_p("``")) + [self.escape_actions.plain_char] ) ; escape = - str_p("``") [PreEscape(self.escape_actions, save)] + cl::str_p("``") [PreEscape(self.escape_actions, save)] >> ( ( ( - (+(anychar_p - "``") >> eps_p("``")) + (+(cl::anychar_p - "``") >> cl::eps_p("``")) & qbk_phrase ) - >> str_p("``") + >> cl::str_p("``") ) | ( - eps_p [self.escape_actions.error] - >> *anychar_p + cl::eps_p [self.escape_actions.error] + >> *cl::anychar_p ) ) [PostEscape(self.out, self.escape_actions, save)] ; preprocessor - = '#' >> *space_p >> ((alpha_p | '_') >> *(alnum_p | '_')) + = '#' >> *cl::space_p >> ((cl::alpha_p | '_') >> *(cl::alnum_p | '_')) ; comment - = comment_p("//") | comment_p("/*", "*/") + = cl::comment_p("//") | cl::comment_p("/*", "*/") ; keyword - = keyword_ >> (eps_p - (alnum_p | '_')) + = keyword_ >> (cl::eps_p - (cl::alnum_p | '_')) ; // make sure we recognize whole words only keyword_ @@ -122,43 +125,44 @@ namespace quickbook ; special - = +chset_p("~!%^&*()+={[}]:;,<.>?/|\\-") + = +cl::chset_p("~!%^&*()+={[}]:;,<.>?/|\\-") ; - string_char = ('\\' >> anychar_p) | (anychar_p - '\\'); + string_char = ('\\' >> cl::anychar_p) | (cl::anychar_p - '\\'); string_ - = !as_lower_d['l'] >> confix_p('"', *string_char, '"') + = !cl::as_lower_d['l'] >> cl::confix_p('"', *string_char, '"') ; char_ - = !as_lower_d['l'] >> confix_p('\'', *string_char, '\'') + = !cl::as_lower_d['l'] >> cl::confix_p('\'', *string_char, '\'') ; number = ( - as_lower_d["0x"] >> hex_p - | '0' >> oct_p - | real_p + cl::as_lower_d["0x"] >> cl::hex_p + | '0' >> cl::oct_p + | cl::real_p ) - >> *as_lower_d[chset_p("ldfu")] + >> *cl::as_lower_d[cl::chset_p("ldfu")] ; identifier - = (alpha_p | '_') >> *(alnum_p | '_') + = (cl::alpha_p | '_') >> *(cl::alnum_p | '_') ; } - rule program, macro, preprocessor, comment, special, string_, + cl::rule + program, macro, preprocessor, comment, special, string_, char_, number, identifier, keyword, qbk_phrase, escape, string_char; - symbols<> keyword_; + cl::symbols<> keyword_; phrase_grammar common; std::string save; bool unused; - rule const& + cl::rule const& start() const { return program; } }; @@ -181,7 +185,7 @@ namespace quickbook , typename Unexpected , typename Out> struct python_highlight - : public grammar > + : public cl::grammar > { python_highlight(Out& out, Macro const& macro, DoMacro do_macro, actions& escape_actions) : out(out), macro(macro), do_macro(do_macro), escape_actions(escape_actions) {} @@ -195,7 +199,7 @@ namespace quickbook { program = - *( (+space_p) [Space(self.out)] + *( (+cl::space_p) [Space(self.out)] | macro | escape | comment [Process("comment", self.out)] @@ -204,47 +208,50 @@ namespace quickbook | special [Process("special", self.out)] | string_ [Process("string", self.out)] | number [Process("number", self.out)] - | repeat_p(1)[anychar_p] [Unexpected(self.out)] + | cl::repeat_p(1)[cl::anychar_p] + [Unexpected(self.out)] ) ; macro = - eps_p(self.macro // must not be followed by - >> (eps_p - (alpha_p | '_'))) // alpha or underscore + // must not be followed by alpha or underscore + cl::eps_p(self.macro + >> (cl::eps_p - (cl::alpha_p | '_'))) >> self.macro [self.do_macro] ; qbk_phrase = *( common - | (anychar_p - str_p("``")) [self.escape_actions.plain_char] + | (cl::anychar_p - cl::str_p("``")) + [self.escape_actions.plain_char] ) ; escape = - str_p("``") [PreEscape(self.escape_actions, save)] + cl::str_p("``") [PreEscape(self.escape_actions, save)] >> ( ( ( - (+(anychar_p - "``") >> eps_p("``")) + (+(cl::anychar_p - "``") >> cl::eps_p("``")) & qbk_phrase ) - >> str_p("``") + >> cl::str_p("``") ) | ( - eps_p [self.escape_actions.error] - >> *anychar_p + cl::eps_p [self.escape_actions.error] + >> *cl::anychar_p ) ) [PostEscape(self.out, self.escape_actions, save)] ; comment - = comment_p("#") + = cl::comment_p("#") ; keyword - = keyword_ >> (eps_p - (alnum_p | '_')) + = keyword_ >> (cl::eps_p - (cl::alnum_p | '_')) ; // make sure we recognize whole words only keyword_ @@ -264,55 +271,56 @@ namespace quickbook ; special - = +chset_p("~!%^&*()+={[}]:;,<.>/|\\-") + = +cl::chset_p("~!%^&*()+={[}]:;,<.>/|\\-") ; string_prefix - = as_lower_d[str_p("u") >> ! str_p("r")] + = cl::as_lower_d[cl::str_p("u") >> ! cl::str_p("r")] ; string_ = ! string_prefix >> (long_string | short_string) ; - string_char = ('\\' >> anychar_p) | (anychar_p - '\\'); + string_char = ('\\' >> cl::anychar_p) | (cl::anychar_p - '\\'); short_string - = confix_p('\'', * string_char, '\'') | - confix_p('"', * string_char, '"') + = cl::confix_p('\'', * string_char, '\'') | + cl::confix_p('"', * string_char, '"') ; long_string - // Note: the "str_p" on the next two lines work around + // Note: the "cl::str_p" on the next two lines work around // an INTERNAL COMPILER ERROR when using VC7.1 - = confix_p(str_p("'''"), * string_char, "'''") | - confix_p(str_p("\"\"\""), * string_char, "\"\"\"") + = cl::confix_p(cl::str_p("'''"), * string_char, "'''") | + cl::confix_p(cl::str_p("\"\"\""), * string_char, "\"\"\"") ; number = ( - as_lower_d["0x"] >> hex_p - | '0' >> oct_p - | real_p + cl::as_lower_d["0x"] >> cl::hex_p + | '0' >> cl::oct_p + | cl::real_p ) - >> *as_lower_d[chset_p("lj")] + >> *cl::as_lower_d[cl::chset_p("lj")] ; identifier - = (alpha_p | '_') >> *(alnum_p | '_') + = (cl::alpha_p | '_') >> *(cl::alnum_p | '_') ; } - rule program, macro, comment, special, string_, string_prefix, + cl::rule + program, macro, comment, special, string_, string_prefix, short_string, long_string, number, identifier, keyword, qbk_phrase, escape, string_char; - symbols<> keyword_; + cl::symbols<> keyword_; phrase_grammar common; std::string save; bool unused; - rule const& + cl::rule const& start() const { return program; } }; @@ -331,7 +339,7 @@ namespace quickbook , typename PostEscape , typename Out> struct teletype_highlight - : public grammar > + : public cl::grammar > { teletype_highlight(Out& out, Macro const& macro, DoMacro do_macro, actions& escape_actions) : out(out), macro(macro), do_macro(do_macro), escape_actions(escape_actions) {} @@ -347,49 +355,51 @@ namespace quickbook = *( macro | escape - | repeat_p(1)[anychar_p] [CharProcess(self.out)] + | cl::repeat_p(1)[cl::anychar_p] [CharProcess(self.out)] ) ; - macro = - eps_p(self.macro // must not be followed by - >> (eps_p - (alpha_p | '_'))) // alpha or underscore - >> self.macro [self.do_macro] + macro = + // must not be followed by alpha or underscore + cl::eps_p(self.macro + >> (cl::eps_p - (cl::alpha_p | '_'))) + >> self.macro [self.do_macro] ; qbk_phrase = *( common - | (anychar_p - str_p("``")) [self.escape_actions.plain_char] + | (cl::anychar_p - cl::str_p("``")) + [self.escape_actions.plain_char] ) ; escape = - str_p("``") [PreEscape(self.escape_actions, save)] + cl::str_p("``") [PreEscape(self.escape_actions, save)] >> ( ( ( - (+(anychar_p - "``") >> eps_p("``")) + (+(cl::anychar_p - "``") >> cl::eps_p("``")) & qbk_phrase ) - >> str_p("``") + >> cl::str_p("``") ) | ( - eps_p [self.escape_actions.error] - >> *anychar_p + cl::eps_p [self.escape_actions.error] + >> *cl::anychar_p ) ) [PostEscape(self.out, self.escape_actions, save)] ; } - rule program, macro, qbk_phrase, escape; + cl::rule program, macro, qbk_phrase, escape; phrase_grammar common; std::string save; bool unused; - rule const& + cl::rule const& start() const { return program; } };