Use explicit namespaces.

[SVN r65357]
This commit is contained in:
Daniel James
2010-09-09 00:09:34 +00:00
parent d67b0e3931
commit ac0ea799eb
8 changed files with 405 additions and 372 deletions

View File

@@ -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<python_code_snippet_grammar>
: cl::grammar<python_code_snippet_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<Scanner>
cl::rule<Scanner>
start_, identifier, code_elements, start_snippet, end_snippet,
escaped_comment, ignore;
rule<Scanner> const&
cl::rule<Scanner> const&
start() const { return start_; }
};
@@ -142,7 +143,7 @@ namespace quickbook
};
struct cpp_code_snippet_grammar
: grammar<cpp_code_snippet_grammar>
: cl::grammar<cpp_code_snippet_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<Scanner>
cl::rule<Scanner>
start_, identifier, code_elements, start_snippet, end_snippet,
escaped_comment, inline_callout, line_callout, ignore;
rule<Scanner> const&
cl::rule<Scanner> const&
start() const { return start_; }
};