diff --git a/src/Jamfile.v2 b/src/Jamfile.v2
index 9372559..d45fe98 100644
--- a/src/Jamfile.v2
+++ b/src/Jamfile.v2
@@ -24,7 +24,7 @@ exe quickbook
quickbook.cpp
actions.cpp
doc_info_actions.cpp
- actions_class.cpp
+ state.cpp
utils.cpp
files.cpp
string_ref.cpp
diff --git a/src/actions.cpp b/src/actions.cpp
index d52925d..f9ceef8 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -26,8 +26,8 @@
#include "utils.hpp"
#include "files.hpp"
#include "markups.hpp"
-#include "actions_class.hpp"
-#include "actions_state.hpp"
+#include "state.hpp"
+#include "state_save.hpp"
#include "grammar.hpp"
#include "input_path.hpp"
#include "block_tags.hpp"
@@ -38,21 +38,21 @@
namespace quickbook
{
namespace {
- void write_anchors(quickbook::actions& actions, collector& tgt)
+ void write_anchors(quickbook::state& state, collector& tgt)
{
// TODO: This works but is a bit of an odd place to put it.
// Might need to redefine the purpose of this function.
- if (!actions.source_mode_next.empty()) {
- detail::outwarn(actions.source_mode_next.get_file(),
- actions.source_mode_next.get_position())
+ if (!state.source_mode_next.empty()) {
+ detail::outwarn(state.source_mode_next.get_file(),
+ state.source_mode_next.get_position())
<< "Temporary source mode unsupported here."
<< std::endl;
- actions.source_mode_next = value();
+ state.source_mode_next = value();
}
- for(quickbook::actions::string_list::iterator
- it = actions.anchors.begin(),
- end = actions.anchors.end();
+ for(quickbook::state::string_list::iterator
+ it = state.anchors.begin(),
+ end = state.anchors.end();
it != end; ++it)
{
tgt << "";
}
- actions.anchors.clear();
+ state.anchors.clear();
}
- std::string add_anchor(quickbook::actions& actions,
+ std::string add_anchor(quickbook::state& state,
std::string const& id,
id_category::categories category =
id_category::explicit_anchor_id)
{
- std::string placeholder = actions.ids.add_anchor(id, category);
- actions.anchors.push_back(placeholder);
+ std::string placeholder = state.ids.add_anchor(id, category);
+ state.anchors.push_back(placeholder);
return placeholder;
}
}
@@ -78,34 +78,34 @@ namespace quickbook
return qbk_version_n >= min_ && qbk_version_n < max_;
}
- void explicit_list_action(quickbook::actions&, value);
- void header_action(quickbook::actions&, value);
- void begin_section_action(quickbook::actions&, value);
- void end_section_action(quickbook::actions&, value, string_iterator);
- void block_action(quickbook::actions&, value);
- void block_empty_action(quickbook::actions&, value);
- void macro_definition_action(quickbook::actions&, value);
- void template_body_action(quickbook::actions&, value);
- void variable_list_action(quickbook::actions&, value);
- void table_action(quickbook::actions&, value);
- void xinclude_action(quickbook::actions&, value);
- void include_action(quickbook::actions&, value, string_iterator);
- void image_action(quickbook::actions&, value);
- void anchor_action(quickbook::actions&, value);
- void link_action(quickbook::actions&, value);
- void phrase_action(quickbook::actions&, value);
- void role_action(quickbook::actions&, value);
- void footnote_action(quickbook::actions&, value);
- void raw_phrase_action(quickbook::actions&, value);
- void source_mode_action(quickbook::actions&, value);
- void next_source_mode_action(quickbook::actions&, value);
- void code_action(quickbook::actions&, value);
- void do_template_action(quickbook::actions&, value, string_iterator);
+ void explicit_list_action(quickbook::state&, value);
+ void header_action(quickbook::state&, value);
+ void begin_section_action(quickbook::state&, value);
+ void end_section_action(quickbook::state&, value, string_iterator);
+ void block_action(quickbook::state&, value);
+ void block_empty_action(quickbook::state&, value);
+ void macro_definition_action(quickbook::state&, value);
+ void template_body_action(quickbook::state&, value);
+ void variable_list_action(quickbook::state&, value);
+ void table_action(quickbook::state&, value);
+ void xinclude_action(quickbook::state&, value);
+ void include_action(quickbook::state&, value, string_iterator);
+ void image_action(quickbook::state&, value);
+ void anchor_action(quickbook::state&, value);
+ void link_action(quickbook::state&, value);
+ void phrase_action(quickbook::state&, value);
+ void role_action(quickbook::state&, value);
+ void footnote_action(quickbook::state&, value);
+ void raw_phrase_action(quickbook::state&, value);
+ void source_mode_action(quickbook::state&, value);
+ void next_source_mode_action(quickbook::state&, value);
+ void code_action(quickbook::state&, value);
+ void do_template_action(quickbook::state&, value, string_iterator);
void element_action::operator()(parse_iterator first, parse_iterator) const
{
- value_consumer values = actions.values.release();
- if(!values.check() || !actions.conditional) return;
+ value_consumer values = state.values.release();
+ if(!values.check() || !state.conditional) return;
value v = values.consume();
values.finish();
@@ -113,7 +113,7 @@ namespace quickbook
{
case block_tags::ordered_list:
case block_tags::itemized_list:
- return explicit_list_action(actions, v);
+ return explicit_list_action(state, v);
case block_tags::generic_heading:
case block_tags::heading1:
case block_tags::heading2:
@@ -121,11 +121,11 @@ namespace quickbook
case block_tags::heading4:
case block_tags::heading5:
case block_tags::heading6:
- return header_action(actions, v);
+ return header_action(state, v);
case block_tags::begin_section:
- return begin_section_action(actions, v);
+ return begin_section_action(state, v);
case block_tags::end_section:
- return end_section_action(actions, v, first.base());
+ return end_section_action(state, v, first.base());
case block_tags::blurb:
case block_tags::preformatted:
case block_tags::blockquote:
@@ -135,26 +135,26 @@ namespace quickbook
case block_tags::note:
case block_tags::tip:
case block_tags::block:
- return block_action(actions,v);
+ return block_action(state,v);
case block_tags::hr:
- return block_empty_action(actions,v);
+ return block_empty_action(state,v);
case block_tags::macro_definition:
- return macro_definition_action(actions,v);
+ return macro_definition_action(state,v);
case block_tags::template_definition:
- return template_body_action(actions,v);
+ return template_body_action(state,v);
case block_tags::variable_list:
- return variable_list_action(actions, v);
+ return variable_list_action(state, v);
case block_tags::table:
- return table_action(actions, v);
+ return table_action(state, v);
case block_tags::xinclude:
- return xinclude_action(actions, v);
+ return xinclude_action(state, v);
case block_tags::import:
case block_tags::include:
- return include_action(actions, v, first.base());
+ return include_action(state, v, first.base());
case phrase_tags::image:
- return image_action(actions, v);
+ return image_action(state, v);
case phrase_tags::anchor:
- return anchor_action(actions, v);
+ return anchor_action(state, v);
case phrase_tags::url:
case phrase_tags::link:
case phrase_tags::funcref:
@@ -165,7 +165,7 @@ namespace quickbook
case phrase_tags::headerref:
case phrase_tags::conceptref:
case phrase_tags::globalref:
- return link_action(actions, v);
+ return link_action(state, v);
case phrase_tags::bold:
case phrase_tags::italic:
case phrase_tags::underline:
@@ -173,25 +173,25 @@ namespace quickbook
case phrase_tags::strikethrough:
case phrase_tags::quote:
case phrase_tags::replaceable:
- return phrase_action(actions, v);
+ return phrase_action(state, v);
case phrase_tags::footnote:
- return footnote_action(actions, v);
+ return footnote_action(state, v);
case phrase_tags::escape:
- return raw_phrase_action(actions, v);
+ return raw_phrase_action(state, v);
case phrase_tags::role:
- return role_action(actions, v);
+ return role_action(state, v);
case source_mode_tags::cpp:
case source_mode_tags::python:
case source_mode_tags::teletype:
- return source_mode_action(actions, v);
+ return source_mode_action(state, v);
case code_tags::next_source_mode:
- return next_source_mode_action(actions, v);
+ return next_source_mode_action(state, v);
case code_tags::code_block:
case code_tags::inline_code_block:
case code_tags::inline_code:
- return code_action(actions, v);
+ return code_action(state, v);
case template_tags::template_:
- return do_template_action(actions, v, first.base());
+ return do_template_action(state, v, first.base());
default:
break;
}
@@ -199,22 +199,22 @@ namespace quickbook
void break_action::operator()(parse_iterator first, parse_iterator) const
{
- write_anchors(actions, phrase);
+ write_anchors(state, phrase);
if(*first == '\\')
{
- detail::outwarn(actions.current_file, first.base())
+ detail::outwarn(state.current_file, first.base())
//<< "in column:" << pos.column << ", "
<< "'\\n' is deprecated, pleases use '[br]' instead" << ".\n";
}
- if(!actions.warned_about_breaks)
+ if(!state.warned_about_breaks)
{
- detail::outwarn(actions.current_file, first.base())
+ detail::outwarn(state.current_file, first.base())
<< "line breaks generate invalid boostbook "
"(will only note first occurrence).\n";
- actions.warned_about_breaks = true;
+ state.warned_about_breaks = true;
}
phrase << detail::get_markup(phrase_tags::break_mark).pre;
@@ -222,7 +222,7 @@ namespace quickbook
void error_message_action::operator()(parse_iterator first, parse_iterator last) const
{
- file_position const pos = actions.current_file->position_of(first.base());
+ file_position const pos = state.current_file->position_of(first.base());
std::string value(first, last);
std::string formatted_message = message;
@@ -230,91 +230,91 @@ namespace quickbook
boost::replace_all(formatted_message, "%c",
boost::lexical_cast(pos.column));
- detail::outerr(actions.current_file->path, pos.line)
+ detail::outerr(state.current_file->path, pos.line)
<< detail::utf8(formatted_message) << std::endl;
- ++actions.error_count;
+ ++state.error_count;
}
void error_action::operator()(parse_iterator first, parse_iterator /*last*/) const
{
- file_position const pos = actions.current_file->position_of(first.base());
+ file_position const pos = state.current_file->position_of(first.base());
- detail::outerr(actions.current_file->path, pos.line)
+ detail::outerr(state.current_file->path, pos.line)
<< "Syntax Error near column " << pos.column << ".\n";
- ++actions.error_count;
+ ++state.error_count;
}
- void block_action(quickbook::actions& actions, value block)
+ void block_action(quickbook::state& state, value block)
{
- write_anchors(actions, actions.out);
+ write_anchors(state, state.out);
detail::markup markup = detail::get_markup(block.get_tag());
value_consumer values = block;
- actions.out << markup.pre << values.consume().get_encoded() << markup.post;
+ state.out << markup.pre << values.consume().get_encoded() << markup.post;
values.finish();
}
- void block_empty_action(quickbook::actions& actions, value block)
+ void block_empty_action(quickbook::state& state, value block)
{
- write_anchors(actions, actions.out);
+ write_anchors(state, state.out);
detail::markup markup = detail::get_markup(block.get_tag());
- actions.out << markup.pre;
+ state.out << markup.pre;
}
- void phrase_action(quickbook::actions& actions, value phrase)
+ void phrase_action(quickbook::state& state, value phrase)
{
- write_anchors(actions, actions.phrase);
+ write_anchors(state, state.phrase);
detail::markup markup = detail::get_markup(phrase.get_tag());
value_consumer values = phrase;
- actions.phrase << markup.pre << values.consume().get_encoded() << markup.post;
+ state.phrase << markup.pre << values.consume().get_encoded() << markup.post;
values.finish();
}
- void role_action(quickbook::actions& actions, value role)
+ void role_action(quickbook::state& state, value role)
{
- write_anchors(actions, actions.phrase);
+ write_anchors(state, state.phrase);
value_consumer values = role;
- actions.phrase
+ state.phrase
<< ""
<< values.consume().get_encoded()
<< "";
values.finish();
}
- void footnote_action(quickbook::actions& actions, value phrase)
+ void footnote_action(quickbook::state& state, value phrase)
{
- write_anchors(actions, actions.phrase);
+ write_anchors(state, state.phrase);
value_consumer values = phrase;
- actions.phrase
+ state.phrase
<< ""
<< values.consume().get_encoded()
<< "";
values.finish();
}
- void raw_phrase_action(quickbook::actions& actions, value phrase)
+ void raw_phrase_action(quickbook::state& state, value phrase)
{
- write_anchors(actions, actions.phrase);
+ write_anchors(state, state.phrase);
detail::markup markup = detail::get_markup(phrase.get_tag());
- actions.phrase << markup.pre << phrase.get_quickbook() << markup.post;
+ state.phrase << markup.pre << phrase.get_quickbook() << markup.post;
}
void paragraph_action::operator()() const
{
std::string str;
- actions.phrase.swap(str);
+ state.phrase.swap(str);
std::string::const_iterator
pos = str.begin(),
@@ -324,53 +324,53 @@ namespace quickbook
if(pos != end) {
detail::markup markup = detail::get_markup(block_tags::paragraph);
- actions.out << markup.pre << str;
- write_anchors(actions, actions.out);
- actions.out << markup.post;
+ state.out << markup.pre << str;
+ write_anchors(state, state.out);
+ state.out << markup.post;
}
}
void list_item_action::operator()() const
{
std::string str;
- actions.phrase.swap(str);
- actions.out << str;
- write_anchors(actions, actions.out);
+ state.phrase.swap(str);
+ state.out << str;
+ write_anchors(state, state.out);
}
void phrase_end_action::operator()() const
{
- write_anchors(actions, actions.phrase);
+ write_anchors(state, state.phrase);
}
namespace {
- void write_bridgehead(quickbook::actions& actions, int level,
+ void write_bridgehead(quickbook::state& state, int level,
std::string const& str, std::string const& id, bool self_link)
{
if (self_link && !id.empty())
{
- actions.out << "";
- actions.out << "";
- actions.out << "";
- actions.out << str;
- actions.out << "";
- actions.out << "";
+ state.out << "";
+ state.out << "";
+ state.out << "";
+ state.out << str;
+ state.out << "";
+ state.out << "";
}
else
{
- actions.out << "";
- actions.out << str;
- actions.out << "";
+ state.out << "";
+ state.out << str;
+ state.out << "";
}
}
}
- void header_action(quickbook::actions& actions, value heading_list)
+ void header_action(quickbook::state& state, value heading_list)
{
value_consumer values = heading_list;
@@ -383,7 +383,7 @@ namespace quickbook
if (generic)
{
- level = actions.ids.section_level() + 1;
+ level = state.ids.section_level() + 1;
// We need to use a heading which is one greater
// than the current.
if (level > 6 ) // The max is h6, clip it if it goes
@@ -394,51 +394,51 @@ namespace quickbook
level = heading_list.get_tag() - block_tags::heading1 + 1;
}
- write_anchors(actions, actions.out);
+ write_anchors(state, state.out);
if (!element_id.empty())
{
- std::string anchor = actions.ids.add_id(
+ std::string anchor = state.ids.add_id(
element_id.get_quickbook(),
id_category::explicit_id);
- write_bridgehead(actions, level,
+ write_bridgehead(state, level,
content.get_encoded(), anchor, self_linked_headers);
}
- else if (!generic && actions.ids.compatibility_version() < 103) // version 1.2 and below
+ else if (!generic && state.ids.compatibility_version() < 103) // version 1.2 and below
{
// This generates the old id style if both the interpreting
// version and the generation version are less then 103u.
- std::string anchor = actions.ids.old_style_id(
+ std::string anchor = state.ids.old_style_id(
detail::make_identifier(
- actions.ids.replace_placeholders_with_unresolved_ids(
+ state.ids.replace_placeholders_with_unresolved_ids(
content.get_encoded())),
id_category::generated_heading);
- write_bridgehead(actions, level,
+ write_bridgehead(state, level,
content.get_encoded(), anchor, false);
}
else
{
- std::string anchor = actions.ids.add_id(
+ std::string anchor = state.ids.add_id(
detail::make_identifier(
- actions.ids.compatibility_version() >= 106 ?
+ state.ids.compatibility_version() >= 106 ?
content.get_quickbook() :
- actions.ids.replace_placeholders_with_unresolved_ids(
+ state.ids.replace_placeholders_with_unresolved_ids(
content.get_encoded())
),
id_category::generated_heading);
- write_bridgehead(actions, level,
+ write_bridgehead(state, level,
content.get_encoded(), anchor, self_linked_headers);
}
}
void simple_phrase_action::operator()(char mark) const
{
- write_anchors(actions, out);
+ write_anchors(state, out);
int tag =
mark == '*' ? phrase_tags::bold :
@@ -450,7 +450,7 @@ namespace quickbook
assert(tag != 0);
detail::markup markup = detail::get_markup(tag);
- value_consumer values = actions.values.release();
+ value_consumer values = state.values.release();
value content = values.consume();
values.finish();
@@ -461,21 +461,21 @@ namespace quickbook
bool cond_phrase_push::start()
{
- value_consumer values = actions.values.release();
+ value_consumer values = state.values.release();
- saved_conditional = actions.conditional;
+ saved_conditional = state.conditional;
if (saved_conditional)
{
string_ref macro1 = values.consume().get_quickbook();
std::string macro(macro1.begin(), macro1.end());
- actions.conditional = find(actions.macro, macro.c_str());
+ state.conditional = find(state.macro, macro.c_str());
- if (!actions.conditional) {
- actions.phrase.push();
- actions.out.push();
- actions.anchors.swap(anchors);
+ if (!state.conditional) {
+ state.phrase.push();
+ state.out.push();
+ state.anchors.swap(anchors);
}
}
@@ -484,14 +484,14 @@ namespace quickbook
void cond_phrase_push::cleanup()
{
- if (saved_conditional && !actions.conditional)
+ if (saved_conditional && !state.conditional)
{
- actions.phrase.pop();
- actions.out.pop();
- actions.anchors.swap(anchors);
+ state.phrase.pop();
+ state.out.pop();
+ state.anchors.swap(anchors);
}
- actions.conditional = saved_conditional;
+ state.conditional = saved_conditional;
}
namespace {
@@ -513,27 +513,27 @@ namespace quickbook
}
}
- void actions::start_list(char mark)
+ void state::start_list(char mark)
{
write_anchors(*this, out);
assert(mark == '*' || mark == '#');
out << ((mark == '#') ? "\n" : "\n");
}
- void actions::end_list(char mark)
+ void state::end_list(char mark)
{
write_anchors(*this, out);
assert(mark == '*' || mark == '#');
out << ((mark == '#') ? "\n" : "\n");
}
- void actions::start_list_item()
+ void state::start_list_item()
{
out << "";
write_anchors(*this, out);
}
- void actions::end_list_item()
+ void state::end_list_item()
{
write_anchors(*this, out);
out << "";
@@ -541,15 +541,15 @@ namespace quickbook
namespace
{
- bool parse_template(value const&, quickbook::actions& actions);
+ bool parse_template(value const&, quickbook::state& state);
}
- void actions::start_callouts()
+ void state::start_callouts()
{
++callout_depth;
}
- std::string actions::add_callout(value v)
+ std::string state::add_callout(value v)
{
std::string callout_id1 = ids.add_id("c", id_category::numbered);
std::string callout_id2 = ids.add_id("c", id_category::numbered);
@@ -565,7 +565,7 @@ namespace quickbook
return code;
}
- std::string actions::end_callouts()
+ std::string state::end_callouts()
{
assert(callout_depth > 0);
std::string block;
@@ -616,38 +616,38 @@ namespace quickbook
return block;
}
- void explicit_list_action(quickbook::actions& actions, value list)
+ void explicit_list_action(quickbook::state& state, value list)
{
- write_anchors(actions, actions.out);
+ write_anchors(state, state.out);
detail::markup markup = detail::get_markup(list.get_tag());
- actions.out << markup.pre;
+ state.out << markup.pre;
BOOST_FOREACH(value item, list)
{
- actions.out << "";
- actions.out << item.get_encoded();
- actions.out << "";
+ state.out << "";
+ state.out << item.get_encoded();
+ state.out << "";
}
- actions.out << markup.post;
+ state.out << markup.post;
}
- void anchor_action(quickbook::actions& actions, value anchor)
+ void anchor_action(quickbook::state& state, value anchor)
{
value_consumer values = anchor;
value anchor_id = values.consume();
// Note: anchor_id is never encoded as boostbook. If it
// is encoded, it's just things like escapes.
- add_anchor(actions, anchor_id.is_encoded() ?
+ add_anchor(state, anchor_id.is_encoded() ?
anchor_id.get_encoded() : anchor_id.get_quickbook());
values.finish();
}
void do_macro_action::operator()(std::string const& str) const
{
- write_anchors(actions, phrase);
+ write_anchors(state, phrase);
if (str == quickbook_get_date)
{
@@ -678,19 +678,19 @@ namespace quickbook
out << *first++;
}
- void source_mode_action(quickbook::actions& actions, value source_mode)
+ void source_mode_action(quickbook::state& state, value source_mode)
{
- actions.source_mode = source_mode_tags::name(source_mode.get_tag());
+ state.source_mode = source_mode_tags::name(source_mode.get_tag());
}
- void next_source_mode_action(quickbook::actions& actions, value source_mode)
+ void next_source_mode_action(quickbook::state& state, value source_mode)
{
value_consumer values = source_mode;
- actions.source_mode_next = values.consume();
+ state.source_mode_next = values.consume();
values.finish();
}
- void code_action(quickbook::actions& actions, value code_block)
+ void code_action(quickbook::state& state, value code_block)
{
int code_tag = code_block.get_tag();
@@ -702,23 +702,23 @@ namespace quickbook
(code_tag == code_tags::inline_code_block && qbk_version_n < 106u);
bool block = code_tag != code_tags::inline_code;
- std::string source_mode = actions.source_mode_next.empty() ?
- actions.source_mode : actions.source_mode_next.get_quickbook();
- actions.source_mode_next = value();
+ std::string source_mode = state.source_mode_next.empty() ?
+ state.source_mode : state.source_mode_next.get_quickbook();
+ state.source_mode_next = value();
if (inline_code) {
- write_anchors(actions, actions.phrase);
+ write_anchors(state, state.phrase);
}
else {
- paragraph_action para(actions);
+ paragraph_action para(state);
para();
- write_anchors(actions, actions.out);
+ write_anchors(state, state.out);
}
if (block) {
// preprocess the code section to remove the initial indentation
mapped_file_builder mapped;
- mapped.start(actions.current_file);
+ mapped.start(state.current_file);
mapped.unindent_and_add(code_value.begin(), code_value.end());
file_ptr f = mapped.release();
@@ -726,21 +726,21 @@ namespace quickbook
if (f->source.empty())
return; // Nothing left to do here. The program is empty.
- if (qbk_version_n >= 107u) actions.start_callouts();
+ if (qbk_version_n >= 107u) state.start_callouts();
parse_iterator first_(f->source.begin());
parse_iterator last_(f->source.end());
file_ptr saved_file = f;
- boost::swap(actions.current_file, saved_file);
+ boost::swap(state.current_file, saved_file);
// print the code with syntax coloring
- std::string str = syntax_highlight(first_, last_, actions,
+ std::string str = syntax_highlight(first_, last_, state,
source_mode, block);
- boost::swap(actions.current_file, saved_file);
+ boost::swap(state.current_file, saved_file);
- collector& output = inline_code ? actions.phrase : actions.out;
+ collector& output = inline_code ? state.phrase : state.out;
// We must not place a \n after the tag
// otherwise PDF output starts code blocks with a blank line:
@@ -749,30 +749,30 @@ namespace quickbook
output << str;
output << "\n";
- if (qbk_version_n >= 107u) output << actions.end_callouts();
+ if (qbk_version_n >= 107u) output << state.end_callouts();
}
else {
parse_iterator first_(code_value.begin());
parse_iterator last_(code_value.end());
- std::string str = syntax_highlight(first_, last_, actions,
+ std::string str = syntax_highlight(first_, last_, state,
source_mode, block);
- actions.phrase << "";
- actions.phrase << str;
- actions.phrase << "";
+ state.phrase << "";
+ state.phrase << str;
+ state.phrase << "";
}
}
void plain_char_action::operator()(char ch) const
{
- write_anchors(actions, phrase);
+ write_anchors(state, phrase);
detail::print_char(ch, phrase.get());
}
void plain_char_action::operator()(parse_iterator first, parse_iterator last) const
{
- write_anchors(actions, phrase);
+ write_anchors(state, phrase);
while (first != last)
detail::print_char(*first++, phrase.get());
@@ -780,7 +780,7 @@ namespace quickbook
void escape_unicode_action::operator()(parse_iterator first, parse_iterator last) const
{
- write_anchors(actions, phrase);
+ write_anchors(state, phrase);
while(first != last && *first == '0') ++first;
@@ -817,9 +817,9 @@ namespace quickbook
}
}
- void image_action(quickbook::actions& actions, value image)
+ void image_action(quickbook::state& state, value image)
{
- write_anchors(actions, actions.phrase);
+ write_anchors(state, state.phrase);
// Note: attributes are never encoded as boostbook, if they're
// encoded, it's just things like escapes.
@@ -867,7 +867,7 @@ namespace quickbook
<< detail::utf8(fileref)
<< "'"
<< std::endl;
- if (qbk_version_n >= 106u) ++actions.error_count;
+ if (qbk_version_n >= 106u) ++state.error_count;
}
boost::replace(fileref, '\\', '/');
@@ -969,31 +969,31 @@ namespace quickbook
}
}
- actions.phrase << "";
+ state.phrase << "";
- actions.phrase << "";
+ state.phrase << ">";
// Add a textobject containing the alt tag from earlier.
// This will be used for the alt tag in html.
if (alt_text.check()) {
- actions.phrase << "";
- write_plain_text(actions.phrase.get(), alt_text);
- actions.phrase << "";
+ state.phrase << "";
+ write_plain_text(state.phrase.get(), alt_text);
+ state.phrase << "";
}
- actions.phrase << "";
+ state.phrase << "";
}
- void macro_definition_action(quickbook::actions& actions, quickbook::value macro_definition)
+ void macro_definition_action(quickbook::state& state, quickbook::value macro_definition)
{
value_consumer values = macro_definition;
std::string macro_id = values.consume().get_quickbook();
@@ -1003,7 +1003,7 @@ namespace quickbook
values.finish();
std::string* existing_macro =
- boost::spirit::classic::find(actions.macro, macro_id.c_str());
+ boost::spirit::classic::find(state.macro, macro_id.c_str());
quickbook::ignore_variable(&existing_macro);
if (existing_macro)
@@ -1016,13 +1016,13 @@ namespace quickbook
// return;
}
- actions.macro.add(
+ state.macro.add(
macro_id.begin()
, macro_id.end()
, phrase);
}
- void template_body_action(quickbook::actions& actions, quickbook::value template_definition)
+ void template_body_action(quickbook::state& state, quickbook::value template_definition)
{
value_consumer values = template_definition;
std::string identifier = values.consume().get_quickbook();
@@ -1036,16 +1036,16 @@ namespace quickbook
value body = values.consume();
BOOST_ASSERT(!values.check());
- if (!actions.templates.add(
+ if (!state.templates.add(
template_symbol(
identifier,
template_values,
body,
- &actions.templates.top_scope())))
+ &state.templates.top_scope())))
{
detail::outwarn(body.get_file(), body.get_position())
<< "Template Redefinition: " << detail::utf8(identifier) << std::endl;
- ++actions.error_count;
+ ++state.error_count;
}
}
@@ -1166,7 +1166,7 @@ namespace quickbook
, std::vector const& params
, template_scope const& scope
, string_iterator first
- , quickbook::actions& actions
+ , quickbook::state& state
)
{
std::vector::const_iterator arg = args.begin();
@@ -1176,12 +1176,12 @@ namespace quickbook
// Store each of the argument passed in as local templates:
while (arg != args.end())
{
- if (!actions.templates.add(
+ if (!state.templates.add(
template_symbol(*tpl, empty_params, *arg, &scope)))
{
- detail::outerr(actions.current_file, first)
+ detail::outerr(state.current_file, first)
<< "Duplicate Symbol Found" << std::endl;
- ++actions.error_count;
+ ++state.error_count;
return std::make_pair(false, tpl);
}
++arg; ++tpl;
@@ -1191,12 +1191,12 @@ namespace quickbook
bool parse_template(
value const& content
- , quickbook::actions& actions
+ , quickbook::state& state
)
{
- file_ptr saved_current_file = actions.current_file;
+ file_ptr saved_current_file = state.current_file;
- actions.current_file = content.get_file();
+ state.current_file = content.get_file();
string_ref source = content.get_quickbook();
parse_iterator first(source.begin());
@@ -1204,17 +1204,17 @@ namespace quickbook
bool r = cl::parse(first, last,
content.get_tag() == template_tags::phrase ?
- actions.grammar().inline_phrase :
- actions.grammar().block
+ state.grammar().inline_phrase :
+ state.grammar().block
).full;
- boost::swap(actions.current_file, saved_current_file);
+ boost::swap(state.current_file, saved_current_file);
return r;
}
}
- void call_template(quickbook::actions& actions,
+ void call_template(quickbook::state& state,
template_symbol const* symbol,
std::vector const& args,
string_iterator first)
@@ -1228,13 +1228,13 @@ namespace quickbook
{
if (is_block)
{
- paragraph_action para(actions);
+ paragraph_action para(state);
para();
- actions.out << symbol->content.get_encoded();
+ state.out << symbol->content.get_encoded();
}
else
{
- actions.phrase << symbol->content.get_encoded();
+ state.phrase << symbol->content.get_encoded();
}
return;
@@ -1245,36 +1245,36 @@ namespace quickbook
//
// Note that for quickbook 1.4- this value is just ignored when the
// arguments are expanded.
- template_scope const& call_scope = actions.templates.top_scope();
+ template_scope const& call_scope = state.templates.top_scope();
std::string block;
std::string phrase;
{
- template_state state(actions);
- actions.templates.start_template(symbol);
+ template_state save(state);
+ state.templates.start_template(symbol);
qbk_version_n = symbol->content.get_file()->version();
- ++actions.template_depth;
- if (actions.template_depth > actions.max_template_depth)
+ ++state.template_depth;
+ if (state.template_depth > state.max_template_depth)
{
- detail::outerr(actions.current_file, first)
+ detail::outerr(state.current_file, first)
<< "Infinite loop detected" << std::endl;
- ++actions.error_count;
+ ++state.error_count;
return;
}
// Store the current section level so that we can ensure that
// [section] and [endsect] tags in the template are balanced.
- actions.min_section_level = actions.ids.section_level();
+ state.min_section_level = state.ids.section_level();
///////////////////////////////////
// Prepare the arguments as local templates
bool get_arg_result;
std::vector::const_iterator tpl;
boost::tie(get_arg_result, tpl) =
- get_arguments(args, symbol->params, call_scope, first, actions);
+ get_arguments(args, symbol->params, call_scope, first, state);
if (!get_arg_result)
{
@@ -1284,9 +1284,9 @@ namespace quickbook
///////////////////////////////////
// parse the template body:
- if (!parse_template(symbol->content, actions))
+ if (!parse_template(symbol->content, state))
{
- detail::outerr(actions.current_file, first)
+ detail::outerr(state.current_file, first)
<< "Expanding "
<< (is_block ? "block" : "phrase")
<< " template: " << detail::utf8(symbol->identifier) << std::endl
@@ -1295,37 +1295,37 @@ namespace quickbook
<< detail::utf8(symbol->content.get_quickbook())
<< "------------------end--------------------" << std::endl
<< std::endl;
- ++actions.error_count;
+ ++state.error_count;
return;
}
- if (actions.ids.section_level() != actions.min_section_level)
+ if (state.ids.section_level() != state.min_section_level)
{
- detail::outerr(actions.current_file, first)
+ detail::outerr(state.current_file, first)
<< "Mismatched sections in template "
<< detail::utf8(symbol->identifier)
<< std::endl;
- ++actions.error_count;
+ ++state.error_count;
return;
}
- actions.out.swap(block);
- actions.phrase.swap(phrase);
+ state.out.swap(block);
+ state.phrase.swap(phrase);
}
if(is_block || !block.empty()) {
- paragraph_action para(actions);
+ paragraph_action para(state);
para(); // For paragraphs before the template call.
- actions.out << block;
- actions.phrase << phrase;
+ state.out << block;
+ state.phrase << phrase;
para();
}
else {
- actions.phrase << phrase;
+ state.phrase << phrase;
}
}
- void call_code_snippet(quickbook::actions& actions,
+ void call_code_snippet(quickbook::state& state,
template_symbol const* symbol,
string_iterator first)
{
@@ -1339,12 +1339,12 @@ namespace quickbook
symbol->content,
symbol->lexical_parent);
- actions.start_callouts();
- call_template(actions, &t, args, first);
- actions.out << actions.end_callouts();
+ state.start_callouts();
+ call_template(state, &t, args, first);
+ state.out << state.end_callouts();
}
- void do_template_action(quickbook::actions& actions, value template_list,
+ void do_template_action(quickbook::state& state, value template_list,
string_iterator first)
{
// Get the arguments
@@ -1364,7 +1364,7 @@ namespace quickbook
values.finish();
- template_symbol const* symbol = actions.templates.find(identifier);
+ template_symbol const* symbol = state.templates.find(identifier);
BOOST_ASSERT(symbol);
// Deal with escaped templates.
@@ -1373,19 +1373,19 @@ namespace quickbook
{
if (!args.empty())
{
- detail::outerr(actions.current_file, first)
+ detail::outerr(state.current_file, first)
<< "Arguments for escaped template."
<content.is_encoded())
{
- actions.phrase << symbol->content.get_encoded();
+ state.phrase << symbol->content.get_encoded();
}
else
{
- actions.phrase << symbol->content.get_quickbook();
+ state.phrase << symbol->content.get_quickbook();
/*
@@ -1397,7 +1397,7 @@ namespace quickbook
quickbook::detail::markup escape_markup
= detail::get_markup(phrase_tags::escape);
- actions.phrase
+ state.phrase
<< escape_markup.pre
<< symbol->content.get_quickbook()
<< escape_markup.post
@@ -1417,11 +1417,11 @@ namespace quickbook
case template_tags::phrase:
// Break the arguments for a template
- break_arguments(args, symbol->params, actions.current_file->path);
+ break_arguments(args, symbol->params, state.current_file->path);
if (args.size() != symbol->params.size())
{
- detail::outerr(actions.current_file, first)
+ detail::outerr(state.current_file, first)
<< "Invalid number of arguments passed. Expecting: "
<< symbol->params.size()
<< " argument(s), got: "
@@ -1429,26 +1429,26 @@ namespace quickbook
<< " argument(s) instead."
<< std::endl;
- ++actions.error_count;
+ ++state.error_count;
return;
}
- call_template(actions, symbol, args, first);
+ call_template(state, symbol, args, first);
break;
case template_tags::snippet:
if (!args.empty())
{
- detail::outerr(actions.current_file, first)
+ detail::outerr(state.current_file, first)
<< "Arguments for code snippet."
<";
+ state.phrase << markup.pre;
+ detail::print_string(dst, state.phrase.get());
+ state.phrase << "\">";
if (content.empty())
- detail::print_string(dst, actions.phrase.get());
+ detail::print_string(dst, state.phrase.get());
else
- actions.phrase << content.get_encoded();
+ state.phrase << content.get_encoded();
- actions.phrase << markup.post;
+ state.phrase << markup.post;
}
- void variable_list_action(quickbook::actions& actions, value variable_list)
+ void variable_list_action(quickbook::state& state, value variable_list)
{
- write_anchors(actions, actions.out);
+ write_anchors(state, state.out);
value_consumer values = variable_list;
std::string title = values.consume(table_tags::title).get_quickbook();
- actions.out << "\n";
+ state.out << "\n";
- actions.out << "";
- detail::print_string(title, actions.out.get());
- actions.out << "\n";
+ state.out << "";
+ detail::print_string(title, state.out.get());
+ state.out << "\n";
BOOST_FOREACH(value_consumer entry, values) {
- actions.out << "";
+ state.out << "";
if(entry.check()) {
- actions.out << "";
- actions.out << entry.consume().get_encoded();
- actions.out << "";
+ state.out << "";
+ state.out << entry.consume().get_encoded();
+ state.out << "";
}
if(entry.check()) {
- actions.out << "";
- BOOST_FOREACH(value phrase, entry) actions.out << phrase.get_encoded();
- actions.out << "";
+ state.out << "";
+ BOOST_FOREACH(value phrase, entry) state.out << phrase.get_encoded();
+ state.out << "";
}
- actions.out << "\n";
+ state.out << "\n";
}
- actions.out << "\n";
+ state.out << "\n";
values.finish();
}
- void table_action(quickbook::actions& actions, value table)
+ void table_action(quickbook::state& state, value table)
{
- write_anchors(actions, actions.out);
+ write_anchors(state, state.out);
value_consumer values = table;
@@ -1536,14 +1536,14 @@ namespace quickbook
std::string table_id;
if (!element_id.empty()) {
- table_id = actions.ids.add_id(element_id, id_category::explicit_id);
+ table_id = state.ids.add_id(element_id, id_category::explicit_id);
}
else if (has_title) {
- if (actions.ids.compatibility_version() >= 105) {
- table_id = actions.ids.add_id(detail::make_identifier(title.get_quickbook()), id_category::generated);
+ if (state.ids.compatibility_version() >= 105) {
+ table_id = state.ids.add_id(detail::make_identifier(title.get_quickbook()), id_category::generated);
}
else {
- table_id = actions.ids.add_id("t", id_category::numbered);
+ table_id = state.ids.add_id("t", id_category::numbered);
}
}
@@ -1561,64 +1561,64 @@ namespace quickbook
if (has_title)
{
- actions.out << "\n";
- actions.out << "";
+ state.out << " id=\"" << table_id << "\"";
+ state.out << ">\n";
+ state.out << "";
if (qbk_version_n < 106u) {
- detail::print_string(title.get_quickbook(), actions.out.get());
+ detail::print_string(title.get_quickbook(), state.out.get());
}
else {
- actions.out << title.get_encoded();
+ state.out << title.get_encoded();
}
- actions.out << "";
+ state.out << "";
}
else
{
- actions.out << "\n";
+ state.out << " id=\"" << table_id << "\"";
+ state.out << ">\n";
}
- actions.out << "\n";
+ state.out << "\n";
if (row_count > 1)
{
- actions.out << "" << "";
+ state.out << "" << "";
BOOST_FOREACH(value cell, values.consume()) {
- actions.out << "" << cell.get_encoded() << "";
+ state.out << "" << cell.get_encoded() << "";
}
- actions.out << "
\n" << "\n";
+ state.out << "
\n" << "\n";
}
- actions.out << "\n";
+ state.out << "\n";
BOOST_FOREACH(value row, values) {
- actions.out << "";
+ state.out << "";
BOOST_FOREACH(value cell, row) {
- actions.out << "" << cell.get_encoded() << "";
+ state.out << "" << cell.get_encoded() << "";
}
- actions.out << "
\n";
+ state.out << "
\n";
}
values.finish();
- actions.out << "\n"
- << "\n";
+ state.out << "\n"
+ << "\n";
if (has_title)
{
- actions.out << "
\n";
+ state.out << "\n";
}
else
{
- actions.out << "\n";
+ state.out << "\n";
}
}
- void begin_section_action(quickbook::actions& actions, value begin_section_list)
+ void begin_section_action(quickbook::state& state, value begin_section_list)
{
value_consumer values = begin_section_list;
@@ -1626,7 +1626,7 @@ namespace quickbook
value content = values.consume();
values.finish();
- std::string full_id = actions.ids.begin_section(
+ std::string full_id = state.ids.begin_section(
!element_id.empty() ?
element_id.get_quickbook() :
detail::make_identifier(content.get_quickbook()),
@@ -1634,48 +1634,48 @@ namespace quickbook
id_category::explicit_section_id :
id_category::generated_section);
- actions.out << "\n\n";
- actions.out << "";
+ state.out << "\n\n";
+ state.out << "";
- write_anchors(actions, actions.out);
+ write_anchors(state, state.out);
- if (self_linked_headers && actions.ids.compatibility_version() >= 103)
+ if (self_linked_headers && state.ids.compatibility_version() >= 103)
{
- actions.out << ""
+ state.out << ""
<< content.get_encoded()
<< ""
;
}
else
{
- actions.out << content.get_encoded();
+ state.out << content.get_encoded();
}
- actions.out << "\n";
+ state.out << "\n";
}
- void end_section_action(quickbook::actions& actions, value end_section, string_iterator first)
+ void end_section_action(quickbook::state& state, value end_section, string_iterator first)
{
- write_anchors(actions, actions.out);
+ write_anchors(state, state.out);
- if (actions.ids.section_level() <= actions.min_section_level)
+ if (state.ids.section_level() <= state.min_section_level)
{
- file_position const pos = actions.current_file->position_of(first);
+ file_position const pos = state.current_file->position_of(first);
- detail::outerr(actions.current_file->path, pos.line)
+ detail::outerr(state.current_file->path, pos.line)
<< "Mismatched [endsect] near column " << pos.column << ".\n";
- ++actions.error_count;
+ ++state.error_count;
return;
}
- actions.out << "";
- actions.ids.end_section();
+ state.out << "";
+ state.ids.end_section();
}
void element_id_warning_action::operator()(parse_iterator first, parse_iterator) const
{
- detail::outwarn(actions.current_file, first.base()) << "Empty id.\n";
+ detail::outwarn(state.current_file, first.base()) << "Empty id.\n";
}
// Not a general purpose normalization function, just
@@ -1766,7 +1766,7 @@ namespace quickbook
}
};
- path_details check_path(value const& path, quickbook::actions& actions)
+ path_details check_path(value const& path, quickbook::state& state)
{
// Paths are encoded for quickbook 1.6+ and also xmlbase
// values (technically xmlbase is a 1.6 feature, but that
@@ -1786,7 +1786,7 @@ namespace quickbook
if (qbk_version_n >= 106u) {
err = &detail::outerr(path.get_file(), path.get_position());
- ++actions.error_count;
+ ++state.error_count;
}
else {
err = &detail::outwarn(path.get_file(), path.get_position());
@@ -1804,9 +1804,9 @@ namespace quickbook
is_glob ? path_details::glob : path_details::path);
}
- xinclude_path calculate_xinclude_path(value const& p, quickbook::actions& actions)
+ xinclude_path calculate_xinclude_path(value const& p, quickbook::state& state)
{
- path_details details = check_path(p, actions);
+ path_details details = check_path(p, state);
if (details.type == path_details::glob) {
// TODO: Should know if this is an xinclude or an xmlbase.
@@ -1814,8 +1814,8 @@ namespace quickbook
detail::outerr(p.get_file(), p.get_position())
<< "Glob used in xinclude/xmlbase."
<< std::endl;
- ++actions.error_count;
- return xinclude_path(actions.current_file->path.parent_path(), "");
+ ++state.error_count;
+ return xinclude_path(state.current_file->path.parent_path(), "");
}
fs::path path = detail::generic_to_path(details.value);
@@ -1825,26 +1825,26 @@ namespace quickbook
if (!path.has_root_directory())
{
// Resolve the path from the current file
- full_path = actions.current_file->path.parent_path() / path;
+ full_path = state.current_file->path.parent_path() / path;
// Then calculate relative to the current xinclude_base.
- path = path_difference(actions.xinclude_base, full_path);
+ path = path_difference(state.xinclude_base, full_path);
}
return xinclude_path(full_path, detail::escape_uri(detail::path_to_generic(path)));
}
- void xinclude_action(quickbook::actions& actions, value xinclude)
+ void xinclude_action(quickbook::state& state, value xinclude)
{
- write_anchors(actions, actions.out);
+ write_anchors(state, state.out);
value_consumer values = xinclude;
- xinclude_path x = calculate_xinclude_path(values.consume(), actions);
+ xinclude_path x = calculate_xinclude_path(values.consume(), state);
values.finish();
- actions.out << "\n\n";
+ state.out << "\n\n";
}
namespace
@@ -1882,7 +1882,7 @@ namespace quickbook
#endif
void include_search_glob(std::set & result,
- fs::path dir, fs::path path, quickbook::actions const & actions)
+ fs::path dir, fs::path path, quickbook::state const & state)
{
// Split the glob into the current dir/glob/rest to search.
fs::path glob;
@@ -1915,22 +1915,22 @@ namespace quickbook
{
result.insert(include_search_return(
dir/f,
- actions.filename_relative.parent_path()/dir/f
+ state.filename_relative.parent_path()/dir/f
));
}
// If it's a matching dir, we recurse looking for more files.
else
{
- include_search_glob(result,dir,f/rest,actions);
+ include_search_glob(result,dir,f/rest,state);
}
}
}
std::set include_search(path_details const& details,
- quickbook::actions const& actions)
+ quickbook::state const& state)
{
std::set result;
- fs::path current = actions.current_file->path.parent_path();
+ fs::path current = state.current_file->path.parent_path();
// If the path has some glob match characters
// we do a discovery of all the matches..
@@ -1939,11 +1939,11 @@ namespace quickbook
fs::path path(details.value);
// Search for the current dir accumulating to the result.
- include_search_glob(result,current,path,actions);
+ include_search_glob(result,current,path,state);
// Search the include path dirs accumulating to the result.
BOOST_FOREACH(fs::path dir, include_path)
{
- include_search_glob(result,dir,path,actions);
+ include_search_glob(result,dir,path,state);
}
// Done.
return result;
@@ -1960,7 +1960,7 @@ namespace quickbook
{
result.insert(include_search_return(
current / path,
- actions.filename_relative.parent_path() / path));
+ state.filename_relative.parent_path() / path));
return result;
}
@@ -1977,13 +1977,13 @@ namespace quickbook
}
result.insert(include_search_return(path,
- actions.filename_relative.parent_path() / path));
+ state.filename_relative.parent_path() / path));
return result;
}
}
}
- void load_quickbook(quickbook::actions& actions,
+ void load_quickbook(quickbook::state& state,
include_search_return const& paths,
value::tag_type load_type,
value const& include_doc_id = value())
@@ -2002,32 +2002,32 @@ namespace quickbook
//
// For old versions of quickbook, templates aren't scoped by the
// file.
- file_state state(actions,
+ file_state save(state,
load_type == block_tags::import ? file_state::scope_output :
qbk_version_n >= 106u ? file_state::scope_callables :
file_state::scope_macros);
- actions.current_file = load(paths.filename); // Throws load_error
- actions.filename_relative = paths.filename_relative;
- actions.imported = (load_type == block_tags::import);
+ state.current_file = load(paths.filename); // Throws load_error
+ state.filename_relative = paths.filename_relative;
+ state.imported = (load_type == block_tags::import);
// update the __FILENAME__ macro
- *boost::spirit::classic::find(actions.macro, "__FILENAME__")
- = detail::path_to_generic(actions.filename_relative);
+ *boost::spirit::classic::find(state.macro, "__FILENAME__")
+ = detail::path_to_generic(state.filename_relative);
// parse the file
- quickbook::parse_file(actions, include_doc_id, true);
+ quickbook::parse_file(state, include_doc_id, true);
// Don't restore source_mode on older versions.
- if (keep_inner_source_mode) state.source_mode = actions.source_mode;
+ if (keep_inner_source_mode) save.source_mode = state.source_mode;
}
// restore the __FILENAME__ macro
- *boost::spirit::classic::find(actions.macro, "__FILENAME__")
- = detail::path_to_generic(actions.filename_relative);
+ *boost::spirit::classic::find(state.macro, "__FILENAME__")
+ = detail::path_to_generic(state.filename_relative);
}
- void load_source_file(quickbook::actions& actions,
+ void load_source_file(quickbook::state& state,
include_search_return const& paths,
value::tag_type load_type,
string_iterator first,
@@ -2039,12 +2039,12 @@ namespace quickbook
std::string ext = paths.filename.extension().generic_string();
std::vector storage;
// Throws load_error
- actions.error_count +=
+ state.error_count +=
load_snippets(paths.filename, storage, ext, load_type);
if (load_type == block_tags::include)
{
- actions.templates.push();
+ state.templates.push();
}
BOOST_FOREACH(template_symbol& ts, storage)
@@ -2052,12 +2052,12 @@ namespace quickbook
std::string tname = ts.identifier;
if (tname != "!")
{
- ts.lexical_parent = &actions.templates.top_scope();
- if (!actions.templates.add(ts))
+ ts.lexical_parent = &state.templates.top_scope();
+ if (!state.templates.add(ts))
{
detail::outerr(ts.content.get_file(), ts.content.get_position())
<< "Template Redefinition: " << detail::utf8(tname) << std::endl;
- ++actions.error_count;
+ ++state.error_count;
}
}
}
@@ -2070,25 +2070,25 @@ namespace quickbook
if (tname == "!")
{
- ts.lexical_parent = &actions.templates.top_scope();
- call_code_snippet(actions, &ts, first);
+ ts.lexical_parent = &state.templates.top_scope();
+ call_code_snippet(state, &ts, first);
}
}
- actions.templates.pop();
+ state.templates.pop();
}
}
- void include_action(quickbook::actions& actions, value include, string_iterator first)
+ void include_action(quickbook::state& state, value include, string_iterator first)
{
- write_anchors(actions, actions.out);
+ write_anchors(state, state.out);
value_consumer values = include;
value include_doc_id = values.optional_consume(general_tags::include_id);
- path_details details = check_path(values.consume(), actions);
+ path_details details = check_path(values.consume(), state);
values.finish();
- std::set search = include_search(details, actions);
+ std::set search = include_search(details, state);
std::set::iterator i = search.begin();
std::set::iterator e = search.end();
for (; i != e; ++i)
@@ -2097,36 +2097,36 @@ namespace quickbook
try {
if (qbk_version_n >= 106)
{
- if (actions.imported && include.get_tag() == block_tags::include)
+ if (state.imported && include.get_tag() == block_tags::include)
return;
std::string ext = paths.filename.extension().generic_string();
if (ext == ".qbk" || ext == ".quickbook")
{
- load_quickbook(actions, paths, include.get_tag(), include_doc_id);
+ load_quickbook(state, paths, include.get_tag(), include_doc_id);
}
else
{
- load_source_file(actions, paths, include.get_tag(), first, include_doc_id);
+ load_source_file(state, paths, include.get_tag(), first, include_doc_id);
}
}
else
{
if (include.get_tag() == block_tags::include)
{
- load_quickbook(actions, paths, include.get_tag(), include_doc_id);
+ load_quickbook(state, paths, include.get_tag(), include_doc_id);
}
else
{
- load_source_file(actions, paths, include.get_tag(), first, include_doc_id);
+ load_source_file(state, paths, include.get_tag(), first, include_doc_id);
}
}
}
catch (load_error& e) {
- ++actions.error_count;
+ ++state.error_count;
- detail::outerr(actions.current_file, first)
+ detail::outerr(state.current_file, first)
<< "Loading file "
<< paths.filename
<< ": "
@@ -2138,9 +2138,9 @@ namespace quickbook
bool to_value_scoped_action::start(value::tag_type t)
{
- actions.out.push();
- actions.phrase.push();
- actions.anchors.swap(saved_anchors);
+ state.out.push();
+ state.phrase.push();
+ state.anchors.swap(saved_anchors);
tag = t;
return true;
@@ -2150,28 +2150,28 @@ namespace quickbook
{
std::string value;
- if (!actions.out.str().empty())
+ if (!state.out.str().empty())
{
- paragraph_action para(actions);
+ paragraph_action para(state);
para(); // For paragraphs before the template call.
- write_anchors(actions, actions.out);
- actions.out.swap(value);
+ write_anchors(state, state.out);
+ state.out.swap(value);
}
else
{
- write_anchors(actions, actions.phrase);
- actions.phrase.swap(value);
+ write_anchors(state, state.phrase);
+ state.phrase.swap(value);
}
- actions.values.builder.insert(encoded_qbk_value(
- actions.current_file, first.base(), last.base(), value, tag));
+ state.values.builder.insert(encoded_qbk_value(
+ state.current_file, first.base(), last.base(), value, tag));
}
void to_value_scoped_action::cleanup()
{
- actions.phrase.pop();
- actions.out.pop();
- actions.anchors.swap(saved_anchors);
+ state.phrase.pop();
+ state.out.pop();
+ state.anchors.swap(saved_anchors);
}
}
diff --git a/src/actions.hpp b/src/actions.hpp
index e057b33..133b560 100644
--- a/src/actions.hpp
+++ b/src/actions.hpp
@@ -52,7 +52,7 @@ namespace quickbook
std::string syntax_highlight(
parse_iterator first, parse_iterator last,
- actions& escape_actions,
+ quickbook::state& state,
std::string const& source_mode,
bool is_block);
@@ -64,20 +64,20 @@ namespace quickbook
std::string uri;
};
- xinclude_path calculate_xinclude_path(value const&, quickbook::actions&);
+ xinclude_path calculate_xinclude_path(value const&, quickbook::state&);
struct error_message_action
{
// Prints an error message to std::cerr
- error_message_action(quickbook::actions& actions, std::string const& m)
- : actions(actions)
+ error_message_action(quickbook::state& state, std::string const& m)
+ : state(state)
, message(m)
{}
void operator()(parse_iterator, parse_iterator) const;
- quickbook::actions& actions;
+ quickbook::state& state;
std::string message;
};
@@ -85,27 +85,27 @@ namespace quickbook
{
// Prints an error message to std::cerr
- error_action(quickbook::actions& actions)
- : actions(actions) {}
+ error_action(quickbook::state& state)
+ : state(state) {}
void operator()(parse_iterator first, parse_iterator last) const;
error_message_action operator()(std::string const& message)
{
- return error_message_action(actions, message);
+ return error_message_action(state, message);
}
- quickbook::actions& actions;
+ quickbook::state& state;
};
struct element_action
{
- element_action(quickbook::actions& actions)
- : actions(actions) {}
+ element_action(quickbook::state& state)
+ : state(state) {}
void operator()(parse_iterator, parse_iterator) const;
- quickbook::actions& actions;
+ quickbook::state& state;
};
struct paragraph_action
@@ -114,13 +114,13 @@ namespace quickbook
// doesn't output the paragraph if it's only whitespace.
paragraph_action(
- quickbook::actions& actions)
- : actions(actions) {}
+ quickbook::state& state)
+ : state(state) {}
void operator()() const;
void operator()(parse_iterator, parse_iterator) const { (*this)(); }
- quickbook::actions& actions;
+ quickbook::state& state;
};
struct list_item_action
@@ -129,24 +129,24 @@ namespace quickbook
// doesn't output the paragraph if it's only whitespace.
list_item_action(
- quickbook::actions& actions)
- : actions(actions) {}
+ quickbook::state& state)
+ : state(state) {}
void operator()() const;
void operator()(parse_iterator, parse_iterator) const { (*this)(); }
- quickbook::actions& actions;
+ quickbook::state& state;
};
struct phrase_end_action
{
- phrase_end_action(quickbook::actions& actions) :
- actions(actions) {}
+ phrase_end_action(quickbook::state& state) :
+ state(state) {}
void operator()() const;
void operator()(parse_iterator, parse_iterator) const { (*this)(); }
- quickbook::actions& actions;
+ quickbook::state& state;
};
struct simple_phrase_action
@@ -155,25 +155,25 @@ namespace quickbook
simple_phrase_action(
collector& out
- , quickbook::actions& actions)
+ , quickbook::state& state)
: out(out)
- , actions(actions) {}
+ , state(state) {}
void operator()(char) const;
collector& out;
- quickbook::actions& actions;
+ quickbook::state& state;
};
struct cond_phrase_push : scoped_action_base
{
- cond_phrase_push(quickbook::actions& x)
- : actions(x) {}
+ cond_phrase_push(quickbook::state& x)
+ : state(x) {}
bool start();
void cleanup();
- quickbook::actions& actions;
+ quickbook::state& state;
bool saved_conditional;
std::vector anchors;
};
@@ -182,13 +182,13 @@ namespace quickbook
{
// Handles macro substitutions
- do_macro_action(collector& phrase, quickbook::actions& actions)
+ do_macro_action(collector& phrase, quickbook::state& state)
: phrase(phrase)
- , actions(actions) {}
+ , state(state) {}
void operator()(std::string const& str) const;
collector& phrase;
- quickbook::actions& actions;
+ quickbook::state& state;
};
struct raw_char_action
@@ -209,63 +209,63 @@ namespace quickbook
// Prints a single plain char.
// Converts '<' to "<"... etc See utils.hpp
- plain_char_action(collector& phrase, quickbook::actions& actions)
+ plain_char_action(collector& phrase, quickbook::state& state)
: phrase(phrase)
- , actions(actions) {}
+ , state(state) {}
void operator()(char ch) const;
void operator()(parse_iterator first, parse_iterator last) const;
collector& phrase;
- quickbook::actions& actions;
+ quickbook::state& state;
};
struct escape_unicode_action
{
- escape_unicode_action(collector& phrase, quickbook::actions& actions)
+ escape_unicode_action(collector& phrase, quickbook::state& state)
: phrase(phrase)
- , actions(actions) {}
+ , state(state) {}
void operator()(parse_iterator first, parse_iterator last) const;
collector& phrase;
- quickbook::actions& actions;
+ quickbook::state& state;
};
struct break_action
{
- break_action(collector& phrase, quickbook::actions& actions)
- : phrase(phrase), actions(actions) {}
+ break_action(collector& phrase, quickbook::state& state)
+ : phrase(phrase), state(state) {}
void operator()(parse_iterator f, parse_iterator) const;
collector& phrase;
- quickbook::actions& actions;
+ quickbook::state& state;
};
struct element_id_warning_action
{
- element_id_warning_action(quickbook::actions& actions_)
- : actions(actions_) {}
+ element_id_warning_action(quickbook::state& state_)
+ : state(state_) {}
void operator()(parse_iterator first, parse_iterator last) const;
- quickbook::actions& actions;
+ quickbook::state& state;
};
// Returns the doc_type, or an empty string if there isn't one.
- std::string pre(quickbook::actions& actions, parse_iterator pos, value include_doc_id, bool nested_file);
- void post(quickbook::actions& actions, std::string const& doc_type);
+ std::string pre(quickbook::state& state, parse_iterator pos, value include_doc_id, bool nested_file);
+ void post(quickbook::state& state, std::string const& doc_type);
struct to_value_scoped_action : scoped_action_base
{
- to_value_scoped_action(quickbook::actions& actions)
- : actions(actions) {}
+ to_value_scoped_action(quickbook::state& state)
+ : state(state) {}
bool start(value::tag_type = value::default_tag);
void success(parse_iterator, parse_iterator);
void cleanup();
- quickbook::actions& actions;
+ quickbook::state& state;
std::vector saved_anchors;
value::tag_type tag;
};
diff --git a/src/block_element_grammar.cpp b/src/block_element_grammar.cpp
index db9ddfb..44d9b8b 100644
--- a/src/block_element_grammar.cpp
+++ b/src/block_element_grammar.cpp
@@ -9,7 +9,7 @@
=============================================================================*/
#include "utils.hpp"
-#include "actions_class.hpp"
+#include "state.hpp"
#include "actions.hpp"
#include "grammar_impl.hpp"
#include "block_tags.hpp"
@@ -45,15 +45,15 @@ namespace quickbook
new block_element_grammar_local);
// Actions
- error_action error(actions);
- element_id_warning_action element_id_warning(actions);
- raw_char_action raw_char(actions.phrase);
- scoped_parser to_value(actions);
+ error_action error(state);
+ element_id_warning_action element_id_warning(state);
+ raw_char_action raw_char(state.phrase);
+ scoped_parser to_value(state);
local.element_id =
!( ':'
>> ( !(qbk_since(105u) >> space)
- >> (+(cl::alnum_p | '_')) [actions.values.entry(ph::arg1, ph::arg2, general_tags::element_id)]
+ >> (+(cl::alnum_p | '_')) [state.values.entry(ph::arg1, ph::arg2, general_tags::element_id)]
| cl::eps_p [element_id_warning]
)
)
@@ -132,7 +132,7 @@ namespace quickbook
local.def_macro =
space
- >> macro_identifier [actions.values.entry(ph::arg1, ph::arg2)]
+ >> macro_identifier [state.values.entry(ph::arg1, ph::arg2)]
>> blank
>> local.inner_phrase
;
@@ -151,20 +151,20 @@ namespace quickbook
local.template_ =
space
- >> local.template_id [actions.values.entry(ph::arg1, ph::arg2)]
- >> actions.values.list()[
+ >> local.template_id [state.values.entry(ph::arg1, ph::arg2)]
+ >> state.values.list()[
!(
space >> '['
>> *(
space
- >> local.template_id [actions.values.entry(ph::arg1, ph::arg2)]
+ >> local.template_id [state.values.entry(ph::arg1, ph::arg2)]
)
>> space >> ']'
)
]
>> ( cl::eps_p(*cl::blank_p >> cl::eol_p)
- >> local.template_body [actions.values.entry(ph::arg1, ph::arg2, template_tags::block)]
- | local.template_body [actions.values.entry(ph::arg1, ph::arg2, template_tags::phrase)]
+ >> local.template_body [state.values.entry(ph::arg1, ph::arg2, template_tags::block)]
+ | local.template_body [state.values.entry(ph::arg1, ph::arg2, template_tags::phrase)]
)
;
@@ -187,7 +187,7 @@ namespace quickbook
local.varlistentry =
space
>> cl::ch_p('[')
- >> actions.values.list()
+ >> state.values.list()
[
(
local.varlistterm
@@ -231,7 +231,7 @@ namespace quickbook
>>
(
(
- actions.values.list(table_tags::row)
+ state.values.list(table_tags::row)
[ *local.cell
]
>> cl::ch_p(']')
@@ -243,7 +243,7 @@ namespace quickbook
local.table_title =
qbk_before(106)
- >> (*(cl::anychar_p - eol)) [actions.values.entry(ph::arg1, ph::arg2, table_tags::title)]
+ >> (*(cl::anychar_p - eol)) [state.values.entry(ph::arg1, ph::arg2, table_tags::title)]
>> (+eol)
| qbk_since(106)
>> to_value(table_tags::title)
@@ -292,7 +292,7 @@ namespace quickbook
!(
':'
>> (*((cl::alnum_p | '_') - cl::space_p))
- [actions.values.entry(ph::arg1, ph::arg2, general_tags::include_id)]
+ [state.values.entry(ph::arg1, ph::arg2, general_tags::include_id)]
>> space
)
>> local.include_filename
@@ -300,7 +300,7 @@ namespace quickbook
local.include_filename =
qbk_before(106u)
- >> (*(cl::anychar_p - phrase_end)) [actions.values.entry(ph::arg1, ph::arg2)]
+ >> (*(cl::anychar_p - phrase_end)) [state.values.entry(ph::arg1, ph::arg2)]
| qbk_since(106u)
>> to_value()
[ *( raw_escape
diff --git a/src/code_snippet.cpp b/src/code_snippet.cpp
index a6a6224..b6a6128 100644
--- a/src/code_snippet.cpp
+++ b/src/code_snippet.cpp
@@ -16,7 +16,7 @@
#include "block_tags.hpp"
#include "template_stack.hpp"
#include "actions.hpp"
-#include "actions_class.hpp"
+#include "state.hpp"
#include "values.hpp"
#include "files.hpp"
#include "input_path.hpp"
diff --git a/src/doc_info_actions.cpp b/src/doc_info_actions.cpp
index e4f69d8..f9e209c 100644
--- a/src/doc_info_actions.cpp
+++ b/src/doc_info_actions.cpp
@@ -17,7 +17,7 @@
#include "utils.hpp"
#include "files.hpp"
#include "input_path.hpp"
-#include "actions_class.hpp"
+#include "state.hpp"
#include "actions.hpp"
#include "doc_info_tags.hpp"
#include "id_manager.hpp"
@@ -87,7 +87,7 @@ namespace quickbook
return values;
}
- unsigned get_version(quickbook::actions& actions, bool using_docinfo,
+ unsigned get_version(quickbook::state& state, bool using_docinfo,
value version)
{
unsigned result = 0;
@@ -106,13 +106,13 @@ namespace quickbook
if(result < 100 || result > 107)
{
- detail::outerr(actions.current_file->path)
+ detail::outerr(state.current_file->path)
<< "Unknown version: "
<< major_verison
<< "."
<< minor_verison
<< std::endl;
- ++actions.error_count;
+ ++state.error_count;
}
}
}
@@ -120,7 +120,7 @@ namespace quickbook
return result;
}
- std::string pre(quickbook::actions& actions, parse_iterator pos,
+ std::string pre(quickbook::state& state, parse_iterator pos,
value include_doc_id, bool nested_file)
{
// The doc_info in the file has been parsed. Here's what we'll do
@@ -129,7 +129,7 @@ namespace quickbook
// If there isn't a doc info block, then values will be empty, so most
// of the following code won't actually do anything.
- value_consumer values = actions.values.release();
+ value_consumer values = state.values.release();
// Skip over invalid attributes
@@ -149,15 +149,15 @@ namespace quickbook
{
if (!nested_file)
{
- detail::outerr(actions.current_file, pos.base())
+ detail::outerr(state.current_file, pos.base())
<< "No doc_info block."
<< std::endl;
- ++actions.error_count;
+ ++state.error_count;
// Create a fake document info block in order to continue.
doc_type = "article";
- doc_title = qbk_value(actions.current_file,
+ doc_title = qbk_value(state.current_file,
pos.base(), pos.base(),
doc_info_tags::type);
use_doc_info = true;
@@ -187,7 +187,7 @@ namespace quickbook
if(!duplicates.empty())
{
- detail::outwarn(actions.current_file->path)
+ detail::outwarn(state.current_file->path)
<< (duplicates.size() > 1 ?
"Duplicate attributes" : "Duplicate attribute")
<< ":" << detail::utf8(boost::algorithm::join(duplicates, ", "))
@@ -204,11 +204,11 @@ namespace quickbook
// Quickbook version
- unsigned new_version = get_version(actions, use_doc_info, qbk_version);
+ unsigned new_version = get_version(state, use_doc_info, qbk_version);
if (new_version != qbk_version_n && new_version >= 106)
{
- detail::outwarn(actions.current_file->path)
+ detail::outwarn(state.current_file->path)
<< "Quickbook " << (new_version / 100) << "." << (new_version % 100)
<< " is still under development and is "
"likely to change in the future." << std::endl;
@@ -220,34 +220,34 @@ namespace quickbook
else if (use_doc_info) {
// hard code quickbook version to v1.1
qbk_version_n = 101;
- detail::outwarn(actions.current_file, pos.base())
+ detail::outwarn(state.current_file, pos.base())
<< "Quickbook version undefined. "
"Version 1.1 is assumed" << std::endl;
}
- actions.current_file->version(qbk_version_n);
+ state.current_file->version(qbk_version_n);
// Compatibility Version
unsigned compatibility_version =
- get_version(actions, use_doc_info, compatibility_mode);
+ get_version(state, use_doc_info, compatibility_mode);
if (!compatibility_version) {
compatibility_version = use_doc_info ?
- qbk_version_n : actions.ids.compatibility_version();
+ qbk_version_n : state.ids.compatibility_version();
}
// Start file, finish here if not generating document info.
if (!use_doc_info)
{
- actions.ids.start_file(compatibility_version, include_doc_id_, id_,
+ state.ids.start_file(compatibility_version, include_doc_id_, id_,
doc_title);
return "";
}
std::string id_placeholder =
- actions.ids.start_file_with_docinfo(
+ state.ids.start_file_with_docinfo(
compatibility_version, include_doc_id_, id_, doc_title);
// Make sure we really did have a document info block.
@@ -260,7 +260,7 @@ namespace quickbook
if (!xmlbase.empty())
{
- xinclude_path x = calculate_xinclude_path(xmlbase, actions);
+ xinclude_path x = calculate_xinclude_path(xmlbase, state);
if (!fs::is_directory(x.path))
{
@@ -270,12 +270,12 @@ namespace quickbook
<< "\" isn't a directory."
<< std::endl;
- ++actions.error_count;
+ ++state.error_count;
}
else
{
xmlbase_value = x.uri;
- actions.xinclude_base = x.path;
+ state.xinclude_base = x.path;
}
}
@@ -296,7 +296,7 @@ namespace quickbook
if(!invalid_attributes.empty())
{
- detail::outwarn(actions.current_file->path)
+ detail::outwarn(state.current_file->path)
<< (invalid_attributes.size() > 1 ?
"Invalid attributes" : "Invalid attribute")
<< " for '" << detail::utf8(doc_type) << " document info': "
@@ -310,7 +310,7 @@ namespace quickbook
if (!nested_file)
{
- actions.out << "\n"
+ state.out << "\n"
<< "\n";
+ state.out << " xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n";
std::ostringstream tmp;
@@ -431,9 +431,9 @@ namespace quickbook
year_start;
if (year_end < year_start) {
- ++actions.error_count;
+ ++state.error_count;
- detail::outerr(actions.current_file, copyright.begin()->get_position())
+ detail::outerr(state.current_file, copyright.begin()->get_position())
<< "Invalid year range: "
<< year_start
<< "-"
@@ -458,7 +458,7 @@ namespace quickbook
if (!license.empty())
{
tmp << " \n"
<< " \n"
<< " " << doc_info_output(license, 103) << "\n"
@@ -505,13 +505,13 @@ namespace quickbook
}
if(doc_type != "library") {
- write_document_title(actions.out, doc_title, version);
+ write_document_title(state.out, doc_title, version);
}
std::string docinfo = tmp.str();
if(!docinfo.empty())
{
- actions.out << " <" << doc_type << "info>\n"
+ state.out << " <" << doc_type << "info>\n"
<< docinfo
<< " " << doc_type << "info>\n"
<< "\n"
@@ -519,31 +519,31 @@ namespace quickbook
}
if(doc_type == "library") {
- write_document_title(actions.out, doc_title, version);
+ write_document_title(state.out, doc_title, version);
}
return doc_type;
}
- void post(quickbook::actions& actions, std::string const& doc_type)
+ void post(quickbook::state& state, std::string const& doc_type)
{
// We've finished generating our output. Here's what we'll do
// *after* everything else.
// Close any open sections.
- if (!doc_type.empty() && actions.ids.section_level() > 1) {
- detail::outwarn(actions.current_file->path)
+ if (!doc_type.empty() && state.ids.section_level() > 1) {
+ detail::outwarn(state.current_file->path)
<< "Missing [endsect] detected at end of file."
<< std::endl;
- while(actions.ids.section_level() > 1) {
- actions.out << "";
- actions.ids.end_section();
+ while(state.ids.section_level() > 1) {
+ state.out << "";
+ state.ids.end_section();
}
}
- actions.ids.end_file();
- if (!doc_type.empty()) actions.out << "\n" << doc_type << ">\n\n";
+ state.ids.end_file();
+ if (!doc_type.empty()) state.out << "\n" << doc_type << ">\n\n";
}
static void write_document_title(collector& out, value const& title, value const& version)
diff --git a/src/doc_info_grammar.cpp b/src/doc_info_grammar.cpp
index 5ede325..c376c9c 100644
--- a/src/doc_info_grammar.cpp
+++ b/src/doc_info_grammar.cpp
@@ -19,7 +19,7 @@
#include
#include
#include "grammar_impl.hpp"
-#include "actions_class.hpp"
+#include "state.hpp"
#include "actions.hpp"
#include "doc_info_tags.hpp"
#include "phrase_tags.hpp"
@@ -116,9 +116,9 @@ namespace quickbook
}
// Actions
- error_action error(actions);
- plain_char_action plain_char(actions.phrase, actions);
- scoped_parser to_value(actions);
+ error_action error(state);
+ plain_char_action plain_char(state.phrase, state);
+ scoped_parser to_value(state);
doc_info_details =
space [ph::var(local.source_mode_unset) = true]
@@ -132,7 +132,7 @@ namespace quickbook
'['
>> space
>> (local.doc_types >> cl::eps_p)
- [actions.values.entry(ph::arg1, ph::arg2, doc_info_tags::type)]
+ [state.values.entry(ph::arg1, ph::arg2, doc_info_tags::type)]
>> hard_space
>> to_value(doc_info_tags::title)
[ *( ~cl::eps_p(blank >> (cl::ch_p('[') | ']' | cl::eol_p))
@@ -144,11 +144,11 @@ namespace quickbook
]
>> space
>> !(qbk_since(106u) >> cl::eps_p(ph::var(local.source_mode_unset))
- [cl::assign_a(actions.source_mode, "c++")]
+ [cl::assign_a(state.source_mode, "c++")]
)
>> (*( local.doc_info_attribute
>> space
- )) [actions.values.sort()]
+ )) [state.values.sort()]
>> ( ']'
>> (+eol | cl::end_p)
| cl::eps_p [error]
@@ -160,8 +160,8 @@ namespace quickbook
>> space
>> local.doc_attributes [local.assign_attribute]
>> hard_space
- >> actions.values.list(ph::var(local.attribute_tag))
- [ cl::eps_p [actions.values.entry(ph::arg1, ph::arg2, doc_info_tags::before_docinfo)]
+ >> state.values.list(ph::var(local.attribute_tag))
+ [ cl::eps_p [state.values.entry(ph::arg1, ph::arg2, doc_info_tags::before_docinfo)]
>> local.attribute_rule
]
>> space
@@ -178,7 +178,7 @@ namespace quickbook
[error("Unrecognized document attribute: '%s'.")]
)
>> hard_space
- >> actions.values.list(ph::var(local.attribute_tag))
+ >> state.values.list(ph::var(local.attribute_tag))
[local.attribute_rule]
>> space
>> ']'
@@ -191,17 +191,17 @@ namespace quickbook
// Document Attributes
local.quickbook_version =
- cl::uint_p [actions.values.entry(ph::arg1)]
+ cl::uint_p [state.values.entry(ph::arg1)]
>> '.'
- >> uint2_t() [actions.values.entry(ph::arg1)]
+ >> uint2_t() [state.values.entry(ph::arg1)]
;
local.attribute_rules[doc_attributes::qbk_version] = &local.quickbook_version;
local.doc_compatibility_mode =
- cl::uint_p [actions.values.entry(ph::arg1)]
+ cl::uint_p [state.values.entry(ph::arg1)]
>> '.'
- >> uint2_t() [actions.values.entry(ph::arg1)]
+ >> uint2_t() [state.values.entry(ph::arg1)]
;
local.attribute_rules[doc_attributes::compatibility_mode] = &local.doc_compatibility_mode;
@@ -211,7 +211,7 @@ namespace quickbook
cl::str_p("c++")
| "python"
| "teletype"
- ) [cl::assign_a(actions.source_mode)]
+ ) [cl::assign_a(state.source_mode)]
[ph::var(local.source_mode_unset) = false]
;
@@ -238,12 +238,12 @@ namespace quickbook
local.doc_copyright =
*( +( local.doc_copyright_year
- [actions.values.entry(ph::arg1, doc_info_tags::copyright_year)]
+ [state.values.entry(ph::arg1, doc_info_tags::copyright_year)]
>> space
>> !( '-'
>> space
>> local.doc_copyright_year
- [actions.values.entry(ph::arg1, doc_info_tags::copyright_year_end)]
+ [state.values.entry(ph::arg1, doc_info_tags::copyright_year_end)]
>> space
)
>> !cl::ch_p(',')
@@ -282,7 +282,7 @@ namespace quickbook
local.attribute_rules[doc_info_attributes::authors] = &local.doc_authors;
local.doc_biblioid =
- (+cl::alnum_p) [actions.values.entry(ph::arg1, ph::arg2, doc_info_tags::biblioid_class)]
+ (+cl::alnum_p) [state.values.entry(ph::arg1, ph::arg2, doc_info_tags::biblioid_class)]
>> hard_space
>> to_value(doc_info_tags::biblioid_value)
[+(~cl::eps_p(']') >> local.char_)]
diff --git a/src/fwd.hpp b/src/fwd.hpp
index 4e7d029..7cccde8 100644
--- a/src/fwd.hpp
+++ b/src/fwd.hpp
@@ -16,7 +16,7 @@
namespace quickbook
{
- struct actions;
+ struct state;
struct quickbook_grammar;
struct collector;
struct id_manager;
diff --git a/src/grammar.cpp b/src/grammar.cpp
index a0e2e57..8f244f1 100644
--- a/src/grammar.cpp
+++ b/src/grammar.cpp
@@ -13,8 +13,8 @@
namespace quickbook
{
- quickbook_grammar::quickbook_grammar(quickbook::actions& a)
- : impl_(new impl(a))
+ quickbook_grammar::quickbook_grammar(quickbook::state& s)
+ : impl_(new impl(s))
, command_line_macro(impl_->command_line, "command_line_macro")
, inline_phrase(impl_->inline_phrase, "inline_phrase")
, phrase(impl_->phrase_start, "phrase")
@@ -27,8 +27,8 @@ namespace quickbook
{
}
- quickbook_grammar::impl::impl(quickbook::actions& a)
- : actions(a)
+ quickbook_grammar::impl::impl(quickbook::state& s)
+ : state(s)
, cleanup_()
{
init_main();
diff --git a/src/grammar.hpp b/src/grammar.hpp
index 73aae4a..54aaf2b 100644
--- a/src/grammar.hpp
+++ b/src/grammar.hpp
@@ -62,7 +62,7 @@ namespace quickbook
grammar block;
grammar doc_info;
- quickbook_grammar(quickbook::actions&);
+ quickbook_grammar(quickbook::state&);
~quickbook_grammar();
};
}
diff --git a/src/grammar_impl.hpp b/src/grammar_impl.hpp
index c968111..dd267c6 100644
--- a/src/grammar_impl.hpp
+++ b/src/grammar_impl.hpp
@@ -59,7 +59,7 @@ namespace quickbook
struct quickbook_grammar::impl
{
- quickbook::actions& actions;
+ quickbook::state& state;
cleanup cleanup_;
// Main Grammar
@@ -92,7 +92,7 @@ namespace quickbook
// Doc Info
cl::rule doc_info_details;
- impl(quickbook::actions&);
+ impl(quickbook::state&);
private:
diff --git a/src/main_grammar.cpp b/src/main_grammar.cpp
index 43fdaa0..0af4a4c 100644
--- a/src/main_grammar.cpp
+++ b/src/main_grammar.cpp
@@ -9,7 +9,7 @@
=============================================================================*/
#include "grammar_impl.hpp"
-#include "actions_class.hpp"
+#include "state.hpp"
#include "actions.hpp"
#include "utils.hpp"
#include "template_tags.hpp"
@@ -179,17 +179,17 @@ namespace quickbook
element_info info;
element_info::type_enum element_type;
- // actions
- quickbook::actions& actions_;
+ // state
+ quickbook::state& state_;
////////////////////////////////////////////////////////////////////////
// Local constructor
- main_grammar_local(quickbook::actions& actions)
+ main_grammar_local(quickbook::state& state)
: list_stack()
, list_indent(0)
, no_eols(true)
- , actions_(actions)
+ , state_(state)
{}
};
@@ -208,18 +208,18 @@ namespace quickbook
if (info_.type != element_info::phrase &&
info_.type != element_info::maybe_block)
{
- quickbook::paragraph_action para(l.actions_);
+ paragraph_action para(l.state_);
para();
}
- assert(l.actions_.values.builder.empty());
+ assert(l.state_.values.builder.empty());
- if (!l.actions_.source_mode_next.empty() &&
+ if (!l.state_.source_mode_next.empty() &&
info_.type != element_info::maybe_block)
{
- l.actions_.source_mode.swap(saved_source_mode_);
- l.actions_.source_mode = l.actions_.source_mode_next.get_quickbook();
- l.actions_.source_mode_next = value();
+ l.state_.source_mode.swap(saved_source_mode_);
+ l.state_.source_mode = l.state_.source_mode_next.get_quickbook();
+ l.state_.source_mode_next = value();
}
return true;
@@ -231,7 +231,7 @@ namespace quickbook
if (result || info_.type & element_info::in_phrase)
return result;
- error_action error(l.actions_);
+ error_action error(l.state_);
error(scan.first, scan.first);
return true;
}
@@ -241,7 +241,7 @@ namespace quickbook
void cleanup() {
if (!saved_source_mode_.empty())
- l.actions_.source_mode.swap(saved_source_mode_);
+ l.state_.source_mode.swap(saved_source_mode_);
}
main_grammar_local& l;
@@ -286,27 +286,27 @@ namespace quickbook
void quickbook_grammar::impl::init_main()
{
main_grammar_local& local = cleanup_.add(
- new main_grammar_local(actions));
+ new main_grammar_local(state));
// Global Actions
- element_action element(actions);
- paragraph_action paragraph(actions);
- list_item_action list_item(actions);
+ element_action element(state);
+ paragraph_action paragraph(state);
+ list_item_action list_item(state);
- phrase_end_action end_phrase(actions);
- raw_char_action raw_char(actions.phrase);
- plain_char_action plain_char(actions.phrase, actions);
- escape_unicode_action escape_unicode(actions.phrase, actions);
+ phrase_end_action end_phrase(state);
+ raw_char_action raw_char(state.phrase);
+ plain_char_action plain_char(state.phrase, state);
+ escape_unicode_action escape_unicode(state.phrase, state);
- simple_phrase_action simple_markup(actions.phrase, actions);
+ simple_phrase_action simple_markup(state.phrase, state);
- break_action break_(actions.phrase, actions);
- do_macro_action do_macro(actions.phrase, actions);
+ break_action break_(state.phrase, state);
+ do_macro_action do_macro(state.phrase, state);
- error_action error(actions);
- element_id_warning_action element_id_warning(actions);
+ error_action error(state);
+ element_id_warning_action element_id_warning(state);
- scoped_parser to_value(actions);
+ scoped_parser to_value(state);
// Local Actions
scoped_parser process_element(local);
@@ -331,7 +331,7 @@ namespace quickbook
// nested_phrase is used for a phrase nested inside square
// brackets.
nested_phrase =
- actions.values.save()
+ state.values.save()
[ *( ~cl::eps_p(']')
>> local.common(element_info::in_phrase)
)
@@ -341,7 +341,7 @@ namespace quickbook
// paragraph_phrase is like a nested_phrase but is also terminated
// by a paragraph end.
paragraph_phrase =
- actions.values.save()
+ state.values.save()
[ *( ~cl::eps_p(phrase_end)
>> local.common(element_info::in_phrase)
)
@@ -351,7 +351,7 @@ namespace quickbook
// extended_phrase is like a paragraph_phrase but allows some block
// elements.
extended_phrase =
- actions.values.save()
+ state.values.save()
[ *( ~cl::eps_p(phrase_end)
>> local.common(element_info::in_conditional)
)
@@ -363,13 +363,13 @@ namespace quickbook
// is expanding a template, which is parsed separately but
// is part of the paragraph that contains it.
inline_phrase =
- actions.values.save()
+ state.values.save()
[ *local.common(element_info::in_phrase)
]
;
table_title_phrase =
- actions.values.save()
+ state.values.save()
[ *( ~cl::eps_p(space >> (']' | '[' >> space >> '['))
>> local.common(element_info::in_phrase)
)
@@ -456,7 +456,7 @@ namespace quickbook
// Blocks contains within an element, e.g. a table cell or a footnote.
inside_paragraph =
- actions.values.save()
+ state.values.save()
[ *( local.paragraph_separator [paragraph]
>> *eol
| ~cl::eps_p(']')
@@ -467,7 +467,7 @@ namespace quickbook
local.hr =
cl::str_p("----")
- >> actions.values.list(block_tags::hr)
+ >> state.values.list(block_tags::hr)
[ ( qbk_since(106u)
>> *(line_comment | (cl::anychar_p - (cl::eol_p | '[' | ']')))
| qbk_before(106u)
@@ -485,7 +485,7 @@ namespace quickbook
>> (cl::eps_p - (cl::alnum_p | '_'))
)
>> process_element()
- [ actions.values.list(ph::var(local.info.tag))
+ [ state.values.list(ph::var(local.info.tag))
[ cl::lazy_p(*ph::var(local.info.rule))
>> space
>> ']'
@@ -494,10 +494,10 @@ namespace quickbook
;
local.code =
- actions.values.list(code_tags::code_block)
+ state.values.list(code_tags::code_block)
[( local.code_line
>> *(*local.blank_line >> local.code_line)
- ) [actions.values.entry(ph::arg1, ph::arg2)]
+ ) [state.values.entry(ph::arg1, ph::arg2)]
] [element]
>> *eol
;
@@ -543,23 +543,23 @@ namespace quickbook
local.macro =
cl::eps_p
- ( ( actions.macro
+ ( ( state.macro
>> ~cl::eps_p(cl::alpha_p | '_')
// must not be followed by alpha or underscore
)
& macro_identifier // must be a valid macro for the current version
)
- >> actions.macro [do_macro]
+ >> state.macro [do_macro]
;
local.template_ =
( '['
>> space
- >> actions.values.list(template_tags::template_)
- [ !cl::str_p("`") [actions.values.entry(ph::arg1, ph::arg2, template_tags::escape)]
+ >> state.values.list(template_tags::template_)
+ [ !cl::str_p("`") [state.values.entry(ph::arg1, ph::arg2, template_tags::escape)]
>> ( cl::eps_p(cl::punct_p)
- >> actions.templates.scope [actions.values.entry(ph::arg1, ph::arg2, template_tags::identifier)]
- | actions.templates.scope [actions.values.entry(ph::arg1, ph::arg2, template_tags::identifier)]
+ >> state.templates.scope [state.values.entry(ph::arg1, ph::arg2, template_tags::identifier)]
+ | state.templates.scope [state.values.entry(ph::arg1, ph::arg2, template_tags::identifier)]
>> cl::eps_p(hard_space)
)
>> space
@@ -578,8 +578,8 @@ namespace quickbook
local.template_arg_1_4 =
( cl::eps_p(*cl::blank_p >> cl::eol_p)
- >> local.template_inner_arg_1_4 [actions.values.entry(ph::arg1, ph::arg2, template_tags::block)]
- | local.template_inner_arg_1_4 [actions.values.entry(ph::arg1, ph::arg2, template_tags::phrase)]
+ >> local.template_inner_arg_1_4 [state.values.entry(ph::arg1, ph::arg2, template_tags::block)]
+ | local.template_inner_arg_1_4 [state.values.entry(ph::arg1, ph::arg2, template_tags::phrase)]
)
;
@@ -595,8 +595,8 @@ namespace quickbook
local.template_arg_1_5 =
( cl::eps_p(*cl::blank_p >> cl::eol_p)
- >> local.template_arg_1_5_content [actions.values.entry(ph::arg1, ph::arg2, template_tags::block)]
- | local.template_arg_1_5_content [actions.values.entry(ph::arg1, ph::arg2, template_tags::phrase)]
+ >> local.template_arg_1_5_content [state.values.entry(ph::arg1, ph::arg2, template_tags::block)]
+ | local.template_arg_1_5_content [state.values.entry(ph::arg1, ph::arg2, template_tags::phrase)]
)
;
@@ -622,7 +622,7 @@ namespace quickbook
;
local.inline_code =
- '`' >> actions.values.list(code_tags::inline_code)
+ '`' >> state.values.list(code_tags::inline_code)
[(
*(cl::anychar_p -
( '`'
@@ -630,7 +630,7 @@ namespace quickbook
// Make sure that we don't go
) // past a single block
) >> cl::eps_p('`')
- ) [actions.values.entry(ph::arg1, ph::arg2)]
+ ) [state.values.entry(ph::arg1, ph::arg2)]
>> '`'
] [element]
;
@@ -638,7 +638,7 @@ namespace quickbook
local.code_block =
"```"
>> ~cl::eps_p("`")
- >> ( actions.values.list(code_tags::inline_code_block)
+ >> ( state.values.list(code_tags::inline_code_block)
[ *(*cl::blank_p >> cl::eol_p)
>> ( *( "````" >> *cl::ch_p('`')
| ( cl::anychar_p
@@ -646,7 +646,7 @@ namespace quickbook
)
)
>> !(*cl::blank_p >> cl::eol_p)
- ) [actions.values.entry(ph::arg1, ph::arg2)]
+ ) [state.values.entry(ph::arg1, ph::arg2)]
>> (*cl::space_p >> "```")
] [element]
| cl::eps_p [error("Unfinished code block")]
@@ -654,7 +654,7 @@ namespace quickbook
)
| "``"
>> ~cl::eps_p("`")
- >> ( actions.values.list(code_tags::inline_code_block)
+ >> ( state.values.list(code_tags::inline_code_block)
[ *(*cl::blank_p >> cl::eol_p)
>> ( *( "```" >> *cl::ch_p('`')
| ( cl::anychar_p
@@ -662,7 +662,7 @@ namespace quickbook
)
)
>> !(*cl::blank_p >> cl::eol_p)
- ) [actions.values.entry(ph::arg1, ph::arg2)]
+ ) [state.values.entry(ph::arg1, ph::arg2)]
>> (*cl::space_p >> "``")
] [element]
| cl::eps_p [error("Unfinished code block")]
@@ -683,12 +683,12 @@ namespace quickbook
// by space or punctuation or the
// mark character or a the start.
]
- >> actions.values.save()
+ >> state.values.save()
[
to_value()
[
- cl::eps_p((actions.macro & macro_identifier) >> local.simple_markup_end)
- >> actions.macro [do_macro]
+ cl::eps_p((state.macro & macro_identifier) >> local.simple_markup_end)
+ >> state.macro [do_macro]
| ~cl::eps_p(cl::f_ch_p(local.simple_markup.mark))
>> +( ~cl::eps_p
( lookback [~cl::f_ch_p(local.simple_markup.mark)]
@@ -728,8 +728,8 @@ namespace quickbook
| "\\U" >> cl::repeat_p(8) [cl::chset<>("0-9a-fA-F")]
[escape_unicode]
| ("'''" >> !eol)
- >> actions.values.save()
- [ (*(cl::anychar_p - "'''")) [actions.values.entry(ph::arg1, ph::arg2, phrase_tags::escape)]
+ >> state.values.save()
+ [ (*(cl::anychar_p - "'''")) [state.values.entry(ph::arg1, ph::arg2, phrase_tags::escape)]
>> ( cl::str_p("'''")
| cl::eps_p [error("Unclosed boostbook escape.")]
) [element]
@@ -758,10 +758,10 @@ namespace quickbook
//
command_line =
- actions.values.list(block_tags::macro_definition)
+ state.values.list(block_tags::macro_definition)
[ *cl::space_p
>> local.command_line_macro_identifier
- [actions.values.entry(ph::arg1, ph::arg2)]
+ [state.values.entry(ph::arg1, ph::arg2)]
>> *cl::space_p
>> !( '='
>> *cl::space_p
@@ -896,8 +896,8 @@ namespace quickbook
else {
while (!list_stack.top().root && new_indent < list_stack.top().indent)
{
- actions_.end_list_item();
- actions_.end_list(list_stack.top().mark);
+ state_.end_list_item();
+ state_.end_list(list_stack.top().mark);
list_stack.pop();
list_indent = list_stack.top().indent;
}
@@ -930,8 +930,8 @@ namespace quickbook
new_indent > list_stack.top().indent);
if (new_indent <= list_stack.top().indent2) {
- actions_.end_list_item();
- actions_.end_list(save.mark);
+ state_.end_list_item();
+ state_.end_list(save.mark);
list_indent = list_stack.top().indent;
}
else {
@@ -966,44 +966,44 @@ namespace quickbook
if (list_stack.top().root || new_indent > list_indent) {
list_stack.push(list_stack_item(mark, new_indent, new_indent2));
- actions_.start_list(mark);
+ state_.start_list(mark);
}
else if (new_indent == list_indent) {
- actions_.end_list_item();
+ state_.end_list_item();
}
else {
// This should never reach root, since the first list
// has indentation 0.
while(!list_stack.top().root && new_indent < list_stack.top().indent)
{
- actions_.end_list_item();
- actions_.end_list(list_stack.top().mark);
+ state_.end_list_item();
+ state_.end_list(list_stack.top().mark);
list_stack.pop();
}
- actions_.end_list_item();
+ state_.end_list_item();
}
list_indent = new_indent;
if (mark != list_stack.top().mark)
{
- detail::outerr(actions_.current_file, first)
+ detail::outerr(state_.current_file, first)
<< "Illegal change of list style.\n";
- detail::outwarn(actions_.current_file, first)
+ detail::outwarn(state_.current_file, first)
<< "Ignoring change of list style." << std::endl;
- ++actions_.error_count;
+ ++state_.error_count;
}
- actions_.start_list_item();
+ state_.start_list_item();
block_type = block_types::list;
}
void main_grammar_local::clear_stack()
{
while (!list_stack.top().root) {
- actions_.end_list_item();
- actions_.end_list(list_stack.top().mark);
+ state_.end_list_item();
+ state_.end_list(list_stack.top().mark);
list_stack.pop();
}
}
diff --git a/src/phrase_element_grammar.cpp b/src/phrase_element_grammar.cpp
index 3249c12..75a7bad 100644
--- a/src/phrase_element_grammar.cpp
+++ b/src/phrase_element_grammar.cpp
@@ -9,7 +9,7 @@
=============================================================================*/
#include "grammar_impl.hpp"
-#include "actions_class.hpp"
+#include "state.hpp"
#include "actions.hpp"
#include "utils.hpp"
#include "phrase_tags.hpp"
@@ -37,10 +37,10 @@ namespace quickbook
phrase_element_grammar_local& local = cleanup_.add(
new phrase_element_grammar_local);
- error_action error(actions);
- raw_char_action raw_char(actions.phrase);
- scoped_parser scoped_cond_phrase(actions);
- scoped_parser to_value(actions);
+ error_action error(state);
+ raw_char_action raw_char(state.phrase);
+ scoped_parser scoped_cond_phrase(state);
+ scoped_parser to_value(state);
elements.add
("?", element_info(element_info::phrase, &local.cond_phrase))
@@ -48,7 +48,7 @@ namespace quickbook
local.cond_phrase =
blank
- >> macro_identifier [actions.values.entry(ph::arg1, ph::arg2)]
+ >> macro_identifier [state.values.entry(ph::arg1, ph::arg2)]
>> scoped_cond_phrase() [extended_phrase]
;
@@ -65,7 +65,7 @@ namespace quickbook
>> (+(
*cl::space_p
>> +(cl::anychar_p - (cl::space_p | phrase_end | '['))
- )) [actions.values.entry(ph::arg1, ph::arg2)]
+ )) [state.values.entry(ph::arg1, ph::arg2)]
| qbk_since(106u)
>> to_value()
[ +( raw_escape
@@ -77,14 +77,14 @@ namespace quickbook
]
)
>> hard_space
- >> *actions.values.list()
+ >> *state.values.list()
[ '['
>> (*(cl::alnum_p | '_'))
- [actions.values.entry(ph::arg1, ph::arg2)]
+ [state.values.entry(ph::arg1, ph::arg2)]
>> space
>> ( qbk_before(106u)
>> (*(cl::anychar_p - (phrase_end | '[')))
- [actions.values.entry(ph::arg1, ph::arg2)]
+ [state.values.entry(ph::arg1, ph::arg2)]
| qbk_since(106u)
>> to_value()
[ *( raw_escape
@@ -99,7 +99,7 @@ namespace quickbook
>> cl::eps_p(']')
| qbk_before(105u)
>> blank
- >> (*(cl::anychar_p - phrase_end)) [actions.values.entry(ph::arg1, ph::arg2)]
+ >> (*(cl::anychar_p - phrase_end)) [state.values.entry(ph::arg1, ph::arg2)]
>> cl::eps_p(']')
;
@@ -120,7 +120,7 @@ namespace quickbook
space
>> ( qbk_before(106u)
>> (*(cl::anychar_p - (']' | space)))
- [actions.values.entry(ph::arg1, ph::arg2)]
+ [state.values.entry(ph::arg1, ph::arg2)]
| qbk_since(106u)
>> to_value()
[ *( raw_escape
@@ -143,7 +143,7 @@ namespace quickbook
local.anchor =
blank
>> ( qbk_before(106u)
- >> (*(cl::anychar_p - phrase_end)) [actions.values.entry(ph::arg1, ph::arg2)]
+ >> (*(cl::anychar_p - phrase_end)) [state.values.entry(ph::arg1, ph::arg2)]
| qbk_since(106u)
>> to_value()
[ *( raw_escape
@@ -172,7 +172,7 @@ namespace quickbook
( cl::str_p("c++")
| "python"
| "teletype"
- ) [actions.values.entry(ph::arg1, ph::arg2)];
+ ) [state.values.entry(ph::arg1, ph::arg2)];
elements.add
("c++", element_info(element_info::phrase, &local.empty, source_mode_tags::cpp))
@@ -186,7 +186,7 @@ namespace quickbook
local.role
= space
- >> (+(cl::alnum_p | '_')) [actions.values.entry(ph::arg1, ph::arg2)]
+ >> (+(cl::alnum_p | '_')) [state.values.entry(ph::arg1, ph::arg2)]
>> hard_space
>> local.inner_phrase
;
diff --git a/src/quickbook.cpp b/src/quickbook.cpp
index effdcfa..b8a7f0b 100644
--- a/src/quickbook.cpp
+++ b/src/quickbook.cpp
@@ -9,7 +9,7 @@
=============================================================================*/
#include "grammar.hpp"
#include "quickbook.hpp"
-#include "actions_class.hpp"
+#include "state.hpp"
#include "actions.hpp"
#include "post_process.hpp"
#include "utils.hpp"
@@ -53,7 +53,7 @@ namespace quickbook
std::vector preset_defines;
fs::path image_location;
- static void set_macros(actions& actor)
+ static void set_macros(quickbook::state& state)
{
for(std::vector::const_iterator
it = preset_defines.begin(),
@@ -64,7 +64,7 @@ namespace quickbook
parse_iterator last(it->end());
cl::parse_info info =
- cl::parse(first, last, actor.grammar().command_line_macro);
+ cl::parse(first, last, state.grammar().command_line_macro);
if (!info.full) {
detail::outerr()
@@ -72,7 +72,7 @@ namespace quickbook
<< detail::utf8(*it)
<< "'"
<< std::endl;
- ++actor.error_count;
+ ++state.error_count;
}
}
}
@@ -82,29 +82,29 @@ namespace quickbook
// Parse a file
//
///////////////////////////////////////////////////////////////////////////
- void parse_file(actions& actor, value include_doc_id, bool nested_file)
+ void parse_file(quickbook::state& state, value include_doc_id, bool nested_file)
{
- parse_iterator first(actor.current_file->source.begin());
- parse_iterator last(actor.current_file->source.end());
+ parse_iterator first(state.current_file->source.begin());
+ parse_iterator last(state.current_file->source.end());
- cl::parse_info info = cl::parse(first, last, actor.grammar().doc_info);
+ cl::parse_info info = cl::parse(first, last, state.grammar().doc_info);
assert(info.hit);
- if (!actor.error_count)
+ if (!state.error_count)
{
parse_iterator pos = info.stop;
- std::string doc_type = pre(actor, pos, include_doc_id, nested_file);
+ std::string doc_type = pre(state, pos, include_doc_id, nested_file);
- info = cl::parse(info.hit ? info.stop : first, last, actor.grammar().block);
+ info = cl::parse(info.hit ? info.stop : first, last, state.grammar().block);
- post(actor, doc_type);
+ post(state, doc_type);
if (!info.full)
{
- file_position const& pos = actor.current_file->position_of(info.stop.base());
- detail::outerr(actor.current_file->path, pos.line)
+ file_position const& pos = state.current_file->position_of(info.stop.base());
+ detail::outerr(state.current_file->path, pos.line)
<< "Syntax Error near column " << pos.column << ".\n";
- ++actor.error_count;
+ ++state.error_count;
}
}
}
@@ -124,21 +124,21 @@ namespace quickbook
int result = 0;
try {
- actions actor(filein_, xinclude_base_, buffer, ids);
- set_macros(actor);
+ quickbook::state state(filein_, xinclude_base_, buffer, ids);
+ set_macros(state);
- if (actor.error_count == 0) {
- actor.current_file = load(filein_); // Throws load_error
+ if (state.error_count == 0) {
+ state.current_file = load(filein_); // Throws load_error
- parse_file(actor);
+ parse_file(state);
- if(actor.error_count) {
+ if(state.error_count) {
detail::outerr()
- << "Error count: " << actor.error_count << ".\n";
+ << "Error count: " << state.error_count << ".\n";
}
}
- result = actor.error_count ? 1 : 0;
+ result = state.error_count ? 1 : 0;
}
catch (load_error& e) {
detail::outerr(filein_) << detail::utf8(e.what()) << std::endl;
diff --git a/src/quickbook.hpp b/src/quickbook.hpp
index 265bc7e..4d2da69 100644
--- a/src/quickbook.hpp
+++ b/src/quickbook.hpp
@@ -31,7 +31,7 @@ namespace quickbook
extern std::vector preset_defines;
extern fs::path image_location;
- void parse_file(actions& actor,
+ void parse_file(quickbook::state& state,
value include_doc_id = value(),
bool nested_file = false);
// Some initialisation methods
diff --git a/src/actions_class.cpp b/src/state.cpp
similarity index 59%
rename from src/actions_class.cpp
rename to src/state.cpp
index cd90e78..9f2168a 100644
--- a/src/actions_class.cpp
+++ b/src/state.cpp
@@ -8,8 +8,8 @@
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
-#include "actions_class.hpp"
-#include "actions_state.hpp"
+#include "state.hpp"
+#include "state_save.hpp"
#include "quickbook.hpp"
#include "grammar.hpp"
#include "input_path.hpp"
@@ -25,7 +25,7 @@ namespace quickbook
unsigned qbk_version_n = 0; // qbk_major_version * 100 + qbk_minor_version
- actions::actions(fs::path const& filein_, fs::path const& xinclude_base_,
+ state::state(fs::path const& filein_, fs::path const& xinclude_base_,
string_stream& out_, id_manager& ids)
: grammar_()
@@ -60,63 +60,63 @@ namespace quickbook
("__TIME__", std::string(quickbook_get_time))
("__FILENAME__", detail::path_to_generic(filename_relative))
;
-
+
boost::scoped_ptr g(
new quickbook_grammar(*this));
grammar_.swap(g);
}
- quickbook_grammar& actions::grammar() const {
+ quickbook_grammar& state::grammar() const {
return *grammar_;
}
- file_state::file_state(actions& a, scope_flags scope)
- : a(a)
+ file_state::file_state(quickbook::state& state, scope_flags scope)
+ : state(state)
, scope(scope)
, qbk_version(qbk_version_n)
- , imported(a.imported)
- , current_file(a.current_file)
- , filename_relative(a.filename_relative)
- , xinclude_base(a.xinclude_base)
- , source_mode(a.source_mode)
+ , imported(state.imported)
+ , current_file(state.current_file)
+ , filename_relative(state.filename_relative)
+ , xinclude_base(state.xinclude_base)
+ , source_mode(state.source_mode)
, macro()
{
- if (scope & scope_macros) macro = a.macro;
- if (scope & scope_templates) a.templates.push();
+ if (scope & scope_macros) macro = state.macro;
+ if (scope & scope_templates) state.templates.push();
if (scope & scope_output) {
- a.out.push();
- a.phrase.push();
+ state.out.push();
+ state.phrase.push();
}
- a.values.builder.save();
+ state.values.builder.save();
}
file_state::~file_state()
{
- a.values.builder.restore();
+ state.values.builder.restore();
boost::swap(qbk_version_n, qbk_version);
- boost::swap(a.imported, imported);
- boost::swap(a.current_file, current_file);
- boost::swap(a.filename_relative, filename_relative);
- boost::swap(a.xinclude_base, xinclude_base);
- boost::swap(a.source_mode, source_mode);
+ boost::swap(state.imported, imported);
+ boost::swap(state.current_file, current_file);
+ boost::swap(state.filename_relative, filename_relative);
+ boost::swap(state.xinclude_base, xinclude_base);
+ boost::swap(state.source_mode, source_mode);
if (scope & scope_output) {
- a.out.pop();
- a.phrase.pop();
+ state.out.pop();
+ state.phrase.pop();
}
- if (scope & scope_templates) a.templates.pop();
- if (scope & scope_macros) a.macro = macro;
+ if (scope & scope_templates) state.templates.pop();
+ if (scope & scope_macros) state.macro = macro;
}
-
- template_state::template_state(actions& a)
- : file_state(a, file_state::scope_all)
- , template_depth(a.template_depth)
- , min_section_level(a.min_section_level)
+
+ template_state::template_state(quickbook::state& state)
+ : file_state(state, file_state::scope_all)
+ , template_depth(state.template_depth)
+ , min_section_level(state.min_section_level)
{
}
template_state::~template_state()
{
- boost::swap(a.template_depth, template_depth);
- boost::swap(a.min_section_level, min_section_level);
+ boost::swap(state.template_depth, template_depth);
+ boost::swap(state.min_section_level, min_section_level);
}
}
diff --git a/src/actions_class.hpp b/src/state.hpp
similarity index 96%
rename from src/actions_class.hpp
rename to src/state.hpp
index 892bc2c..aeee7f6 100644
--- a/src/actions_class.hpp
+++ b/src/state.hpp
@@ -22,9 +22,9 @@ namespace quickbook
namespace cl = boost::spirit::classic;
namespace fs = boost::filesystem;
- struct actions
+ struct state
{
- actions(fs::path const& filein_, fs::path const& xinclude_base, string_stream& out_,
+ state(fs::path const& filein_, fs::path const& xinclude_base, string_stream& out_,
id_manager&);
private:
@@ -38,7 +38,7 @@ namespace quickbook
typedef std::vector string_list;
static int const max_template_depth = 100;
-
+
// global state
fs::path xinclude_base;
template_stack templates;
@@ -91,4 +91,3 @@ namespace quickbook
}
#endif // BOOST_SPIRIT_ACTIONS_CLASS_HPP
-
diff --git a/src/actions_state.hpp b/src/state_save.hpp
similarity index 88%
rename from src/actions_state.hpp
rename to src/state_save.hpp
index aefa7f9..f8b53e7 100644
--- a/src/actions_state.hpp
+++ b/src/state_save.hpp
@@ -10,13 +10,13 @@
#if !defined(BOOST_SPIRIT_ACTIONS_STATE_HPP)
#define BOOST_SPIRIT_ACTIONS_STATE_HPP
-#include "actions_class.hpp"
+#include "state.hpp"
namespace quickbook
{
// State savers
//
- // Defined in actions_class.cpp
+ // Defined in state.cpp
struct file_state
{
@@ -29,10 +29,10 @@ namespace quickbook
scope_all = scope_callables + scope_output
};
- explicit file_state(actions&, scope_flags);
+ explicit file_state(quickbook::state&, scope_flags);
~file_state();
- quickbook::actions& a;
+ quickbook::state& state;
scope_flags scope;
unsigned qbk_version;
bool imported;
@@ -49,7 +49,7 @@ namespace quickbook
struct template_state : file_state
{
- explicit template_state(actions&);
+ explicit template_state(quickbook::state&);
~template_state();
int template_depth;
diff --git a/src/syntax_highlight.cpp b/src/syntax_highlight.cpp
index 22f66ad..d88f7e1 100644
--- a/src/syntax_highlight.cpp
+++ b/src/syntax_highlight.cpp
@@ -14,7 +14,7 @@
#include
#include "grammar.hpp"
#include "grammar_impl.hpp" // Just for context stuff. Should move?
-#include "actions_class.hpp"
+#include "state.hpp"
#include "actions.hpp"
#include "utils.hpp"
#include "files.hpp"
@@ -24,10 +24,6 @@ namespace quickbook
{
namespace cl = boost::spirit::classic;
- // quickbook::actions is used in a few places here, as 'escape_actions'.
- // It's named differently to distinguish it from the syntax highlighting
- // actions, declared below.
-
template
struct member_action_value
{
@@ -92,19 +88,18 @@ namespace quickbook
struct syntax_highlight_actions
{
quickbook::collector out;
- quickbook::actions& escape_actions;
+ quickbook::state& state;
do_macro_action do_macro_impl;
// State
bool support_callouts;
string_ref marked_text;
- syntax_highlight_actions(quickbook::actions& escape_actions,
- bool is_block) :
- out(), escape_actions(escape_actions),
- do_macro_impl(out, escape_actions),
+ syntax_highlight_actions(quickbook::state& state, bool is_block) :
+ out(), state(state),
+ do_macro_impl(out, state),
support_callouts(is_block && (qbk_version_n >= 107u ||
- escape_actions.current_file->is_code_snippets)),
+ state.current_file->is_code_snippets)),
marked_text()
{}
@@ -149,9 +144,9 @@ namespace quickbook
void syntax_highlight_actions::unexpected_char(parse_iterator first,
parse_iterator last)
{
- file_position const pos = escape_actions.current_file->position_of(first.base());
+ file_position const pos = state.current_file->position_of(first.base());
- detail::outwarn(escape_actions.current_file->path, pos.line)
+ detail::outwarn(state.current_file->path, pos.line)
<< "in column:" << pos.column
<< ", unexpected character: " << detail::utf8(first, last)
<< "\n";
@@ -173,14 +168,14 @@ namespace quickbook
void syntax_highlight_actions::pre_escape_back(parse_iterator,
parse_iterator)
{
- escape_actions.phrase.push(); // save the stream
+ state.phrase.push(); // save the stream
}
void syntax_highlight_actions::post_escape_back(parse_iterator,
parse_iterator)
{
- out << escape_actions.phrase.str();
- escape_actions.phrase.pop(); // restore the stream
+ out << state.phrase.str();
+ state.phrase.pop(); // restore the stream
}
void syntax_highlight_actions::do_macro(std::string const& v)
@@ -196,7 +191,7 @@ namespace quickbook
void syntax_highlight_actions::callout(parse_iterator, parse_iterator)
{
- out << escape_actions.add_callout(qbk_value(escape_actions.current_file,
+ out << state.add_callout(qbk_value(state.current_file,
marked_text.begin(), marked_text.end()));
marked_text.clear();
}
@@ -258,7 +253,7 @@ namespace quickbook
struct definition
{
definition(cpp_highlight const& self)
- : g(self.actions.escape_actions.grammar())
+ : g(self.actions.state.grammar())
{
member_action1
span(self.actions, &syntax_highlight_actions::span),
@@ -273,7 +268,7 @@ namespace quickbook
callout(self.actions, &syntax_highlight_actions::callout);
member_action_value
do_macro(self.actions, &syntax_highlight_actions::do_macro);
- error_action error(self.actions.escape_actions);
+ error_action error(self.actions.state);
program
=
@@ -298,9 +293,9 @@ namespace quickbook
macro =
// must not be followed by alpha or underscore
- cl::eps_p(self.actions.escape_actions.macro
+ cl::eps_p(self.actions.state.macro
>> (cl::eps_p - (cl::alpha_p | '_')))
- >> self.actions.escape_actions.macro
+ >> self.actions.state.macro
[do_macro]
;
@@ -419,7 +414,7 @@ namespace quickbook
struct definition
{
definition(python_highlight const& self)
- : g(self.actions.escape_actions.grammar())
+ : g(self.actions.state.grammar())
{
member_action1
span(self.actions, &syntax_highlight_actions::span),
@@ -434,7 +429,7 @@ namespace quickbook
callout(self.actions, &syntax_highlight_actions::callout);
member_action_value
do_macro(self.actions, &syntax_highlight_actions::do_macro);
- error_action error(self.actions.escape_actions);
+ error_action error(self.actions.state);
program
=
@@ -453,9 +448,9 @@ namespace quickbook
macro =
// must not be followed by alpha or underscore
- cl::eps_p(self.actions.escape_actions.macro
+ cl::eps_p(self.actions.state.macro
>> (cl::eps_p - (cl::alpha_p | '_')))
- >> self.actions.escape_actions.macro
+ >> self.actions.state.macro
[do_macro]
;
@@ -555,7 +550,7 @@ namespace quickbook
struct definition
{
definition(teletype_highlight const& self)
- : g(self.actions.escape_actions.grammar())
+ : g(self.actions.state.grammar())
{
member_action
plain_char(self.actions, &syntax_highlight_actions::plain_char),
@@ -563,7 +558,7 @@ namespace quickbook
post_escape_back(self.actions, &syntax_highlight_actions::post_escape_back);
member_action_value
do_macro(self.actions, &syntax_highlight_actions::do_macro);
- error_action error(self.actions.escape_actions);
+ error_action error(self.actions.state);
program
=
@@ -575,9 +570,9 @@ namespace quickbook
macro =
// must not be followed by alpha or underscore
- cl::eps_p(self.actions.escape_actions.macro
+ cl::eps_p(self.actions.state.macro
>> (cl::eps_p - (cl::alpha_p | '_')))
- >> self.actions.escape_actions.macro
+ >> self.actions.state.macro
[do_macro]
;
@@ -615,11 +610,11 @@ namespace quickbook
std::string syntax_highlight(
parse_iterator first,
parse_iterator last,
- actions& escape_actions,
+ quickbook::state& state,
std::string const& source_mode,
bool is_block)
{
- syntax_highlight_actions syn_actions(escape_actions, is_block);
+ syntax_highlight_actions syn_actions(state, is_block);
// print the code with syntax coloring
if (source_mode == "c++")