|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r59564 - branches/quickbook-1.5-spirit2
From: daniel_james_at_[hidden]
Date: 2010-02-07 04:12:25
Author: danieljames
Date: 2010-02-07 04:12:20 EST (Sun, 07 Feb 2010)
New Revision: 59564
URL: http://svn.boost.org/trac/boost/changeset/59564
Log:
Use state instead of actions in 'process'.
Text files modified:
branches/quickbook-1.5-spirit2/block_actions.cpp | 114 ++++++++++++++++++++--------------------
branches/quickbook-1.5-spirit2/block_actions.hpp | 22 +++---
branches/quickbook-1.5-spirit2/block_list.cpp | 5 -
branches/quickbook-1.5-spirit2/doc_info_actions.cpp | 14 ++--
branches/quickbook-1.5-spirit2/doc_info_actions.hpp | 2
branches/quickbook-1.5-spirit2/phrase_actions.cpp | 23 ++++---
branches/quickbook-1.5-spirit2/phrase_actions.hpp | 18 +++---
branches/quickbook-1.5-spirit2/phrase_image.cpp | 5 -
branches/quickbook-1.5-spirit2/process.cpp | 4
branches/quickbook-1.5-spirit2/quickbook.cpp | 16 ++--
branches/quickbook-1.5-spirit2/quickbook.hpp | 2
branches/quickbook-1.5-spirit2/template.cpp | 58 ++++++++++---------
12 files changed, 141 insertions(+), 142 deletions(-)
Modified: branches/quickbook-1.5-spirit2/block_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_actions.cpp 2010-02-07 04:12:20 EST (Sun, 07 Feb 2010)
@@ -35,7 +35,7 @@
}
}
- formatted process(quickbook::actions& actions, paragraph const& x)
+ formatted process(quickbook::state& state, paragraph const& x)
{
formatted r;
r.type="paragraph";
@@ -43,33 +43,33 @@
return r;
}
- begin_section2 process(quickbook::actions& actions, begin_section const& x)
+ begin_section2 process(quickbook::state& state, begin_section const& x)
{
// TODO: This uses the generated title.
- actions.state_.section_id = x.id ? *x.id :
+ state.section_id = x.id ? *x.id :
detail::make_identifier(
x.content.raw_markup.begin(),
x.content.raw_markup.end());
- if (actions.state_.section_level != 0) {
- actions.state_.qualified_section_id += '.';
+ if (state.section_level != 0) {
+ state.qualified_section_id += '.';
}
else {
- BOOST_ASSERT(actions.state_.qualified_section_id.empty());
+ BOOST_ASSERT(state.qualified_section_id.empty());
}
- actions.state_.qualified_section_id += actions.state_.section_id;
- ++actions.state_.section_level;
+ state.qualified_section_id += state.section_id;
+ ++state.section_level;
begin_section2 r;
if (qbk_version_n < 103) // version 1.2 and below
{
- r.id = actions.state_.doc_id + "." + actions.state_.section_id;
+ r.id = state.doc_id + "." + state.section_id;
}
else // version 1.3 and above
{
- r.linkend = r.id = actions.state_.doc_id + "." + actions.state_.qualified_section_id;
+ r.linkend = r.id = state.doc_id + "." + state.qualified_section_id;
}
r.content = x.content.content;
@@ -77,34 +77,34 @@
return r;
}
- end_section2 process(quickbook::actions& actions, end_section const& x)
+ end_section2 process(quickbook::state& state, end_section const& x)
{
- --actions.state_.section_level;
- if (actions.state_.section_level < 0)
+ --state.section_level;
+ if (state.section_level < 0)
{
detail::outerr(x.position.file,x.position.line)
<< "Mismatched [endsect] near column " << x.position.column << ".\n";
- ++actions.state_.error_count;
+ ++state.error_count;
// $$$ TODO: somehow fail parse else BOOST_ASSERT(std::string::npos != n)
// $$$ below will assert.
}
- if (actions.state_.section_level == 0)
+ if (state.section_level == 0)
{
- actions.state_.qualified_section_id.clear();
+ state.qualified_section_id.clear();
}
else
{
std::string::size_type const n =
- actions.state_.qualified_section_id.find_last_of('.');
+ state.qualified_section_id.find_last_of('.');
BOOST_ASSERT(std::string::npos != n);
- actions.state_.qualified_section_id.erase(n, std::string::npos);
+ state.qualified_section_id.erase(n, std::string::npos);
}
return end_section2();
}
- heading2 process(quickbook::actions& actions, heading const& x)
+ heading2 process(quickbook::state& state, heading const& x)
{
heading2 r;
@@ -113,7 +113,7 @@
r.level = x.level;
if(r.level < 0) {
- r.level = actions.state_.section_level + 2;
+ r.level = state.section_level + 2;
// section_level is zero-based. We need to use a
// one-based heading which is one greater
// than the current. Thus: section_level + 2.
@@ -123,7 +123,7 @@
if (!new_style) // version 1.2 and below
{
- r.id = actions.state_.section_id + "." +
+ r.id = state.section_id + "." +
detail::make_identifier(
x.content.raw_markup.begin(),
x.content.raw_markup.end());
@@ -131,7 +131,7 @@
else // version 1.3 and above
{
r.linkend = r.id = fully_qualified_id(
- actions.state_.doc_id, actions.state_.qualified_section_id,
+ state.doc_id, state.qualified_section_id,
detail::make_identifier(
x.content.raw_markup.begin(),
x.content.raw_markup.end()));
@@ -143,27 +143,27 @@
return r;
}
- nothing process(quickbook::actions& actions, def_macro const& x)
+ nothing process(quickbook::state& state, def_macro const& x)
{
- actions.state_.macro.add(
+ state.macro.add(
x.macro_identifier.begin()
, x.macro_identifier.end()
, quickbook::macro(x.content));
return nothing();
}
- nothing process(quickbook::actions& actions, define_template const& x)
+ nothing process(quickbook::state& state, define_template const& x)
{
- if(!actions.state_.templates.add(x)) {
+ if(!state.templates.add(x)) {
detail::outerr(x.position.file, x.position.line)
<< "Template Redefinition: " << x.id << std::endl;
- ++actions.state_.error_count;
+ ++state.error_count;
}
return nothing();
}
- table2 process(quickbook::actions& actions, table const& x)
+ table2 process(quickbook::state& state, table const& x)
{
table2 r;
@@ -171,12 +171,12 @@
if(qbk_version_n >= 105) {
if(x.id) {
- r.id = fully_qualified_id(actions.state_.doc_id,
- actions.state_.qualified_section_id, *x.id);
+ r.id = fully_qualified_id(state.doc_id,
+ state.qualified_section_id, *x.id);
}
else if(r.title) {
- r.id = fully_qualified_id(actions.state_.doc_id,
- actions.state_.qualified_section_id,
+ r.id = fully_qualified_id(state.doc_id,
+ state.qualified_section_id,
detail::make_identifier(x.title.begin(), x.title.end()));
}
}
@@ -279,84 +279,84 @@
return std::accumulate(file, path.end(), result, concat);
}
- fs::path calculate_relative_path(std::string const& x, quickbook::actions& actions)
+ fs::path calculate_relative_path(std::string const& x, quickbook::state& state)
{
// Given a source file and the current filename, calculate the
// path to the source file relative to the output directory.
fs::path path(x);
if (!path.is_complete())
{
- fs::path infile = fs::complete(actions.state_.filename).normalize();
+ fs::path infile = fs::complete(state.filename).normalize();
path = (infile.branch_path() / path).normalize();
- fs::path outdir = fs::complete(actions.state_.outdir).normalize();
+ fs::path outdir = fs::complete(state.outdir).normalize();
path = path_difference(outdir, path);
}
return path;
}
}
- xinclude2 process(quickbook::actions& actions, xinclude const& x)
+ xinclude2 process(quickbook::state& state, xinclude const& x)
{
xinclude2 r;
- r.path = calculate_relative_path(detail::escape_uri(x.path), actions).string();
+ r.path = calculate_relative_path(detail::escape_uri(x.path), state).string();
return r;
}
- nothing process(quickbook::actions& actions, include const& x)
+ nothing process(quickbook::state& state, include const& x)
{
- fs::path filein = include_search(actions.state_.filename.branch_path(), x.path);
+ fs::path filein = include_search(state.filename.branch_path(), x.path);
std::string doc_id;
// swap the filenames
- std::swap(actions.state_.filename, filein);
+ std::swap(state.filename, filein);
// save the doc info strings
- actions.state_.doc_id.swap(doc_id);
+ state.doc_id.swap(doc_id);
// scope the macros
- macro_symbols macro = actions.state_.macro;
+ macro_symbols macro = state.macro;
// scope the templates
- //~ template_symbols templates = actions.state_.templates; $$$ fixme $$$
+ //~ template_symbols templates = state.templates; $$$ fixme $$$
// if an id is specified in this include (as in [include:id foo.qbk])
// then use it as the doc_id.
- if (x.id) actions.state_.doc_id = *x.id;
+ if (x.id) state.doc_id = *x.id;
// update the __FILENAME__ macro
- *actions.state_.macro.find("__FILENAME__") =
- quickbook::macro(actions.state_.filename.native_file_string());
+ *state.macro.find("__FILENAME__") =
+ quickbook::macro(state.filename.native_file_string());
// parse the file
- quickbook::parse(actions.state_.filename.native_file_string().c_str(), actions, true);
+ quickbook::parse(state.filename.native_file_string().c_str(), state, true);
// restore the values
- std::swap(actions.state_.filename, filein);
+ std::swap(state.filename, filein);
- actions.state_.doc_id.swap(doc_id);
+ state.doc_id.swap(doc_id);
// restore the macros
- actions.state_.macro = macro;
+ state.macro = macro;
// restore the templates
- //~ actions.state_.templates = templates; $$$ fixme $$$
+ //~ state.templates = templates; $$$ fixme $$$
return nothing();
}
- nothing process(quickbook::actions& actions, import const& x)
+ nothing process(quickbook::state& state, import const& x)
{
- fs::path path = include_search(actions.state_.filename.branch_path(), x.path);
+ fs::path path = include_search(state.filename.branch_path(), x.path);
std::string ext = fs::extension(path);
std::vector<define_template> storage;
- actions.state_.error_count +=
- load_snippets(path.string(), storage, ext, actions.state_.doc_id);
+ state.error_count +=
+ load_snippets(path.string(), storage, ext, state.doc_id);
BOOST_FOREACH(define_template const& definition, storage)
{
- if (!actions.state_.templates.add(definition))
+ if (!state.templates.add(definition))
{
detail::outerr(definition.position.file, definition.position.line)
<< "Template Redefinition: " << definition.id << std::endl;
- ++actions.state_.error_count;
+ ++state.error_count;
}
}
Modified: branches/quickbook-1.5-spirit2/block_actions.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_actions.hpp (original)
+++ branches/quickbook-1.5-spirit2/block_actions.hpp 2010-02-07 04:12:20 EST (Sun, 07 Feb 2010)
@@ -16,17 +16,17 @@
namespace quickbook
{
// TODO: Just generate formatted.
- formatted process(quickbook::actions&, paragraph const&);
- begin_section2 process(quickbook::actions&, begin_section const&);
- end_section2 process(quickbook::actions&, end_section const&);
- heading2 process(quickbook::actions&, heading const&);
- nothing process(quickbook::actions&, def_macro const&);
- nothing process(quickbook::actions&, define_template const&);
- table2 process(quickbook::actions&, table const&);
- xinclude2 process(quickbook::actions&, xinclude const&);
- nothing process(quickbook::actions&, import const&);
- nothing process(quickbook::actions&, include const&);
- list2 process(quickbook::actions&, list const&);
+ formatted process(quickbook::state&, paragraph const&);
+ begin_section2 process(quickbook::state&, begin_section const&);
+ end_section2 process(quickbook::state&, end_section const&);
+ heading2 process(quickbook::state&, heading const&);
+ nothing process(quickbook::state&, def_macro const&);
+ nothing process(quickbook::state&, define_template const&);
+ table2 process(quickbook::state&, table const&);
+ xinclude2 process(quickbook::state&, xinclude const&);
+ nothing process(quickbook::state&, import const&);
+ nothing process(quickbook::state&, include const&);
+ list2 process(quickbook::state&, list const&);
}
#endif
\ No newline at end of file
Modified: branches/quickbook-1.5-spirit2/block_list.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_list.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_list.cpp 2010-02-07 04:12:20 EST (Sun, 07 Feb 2010)
@@ -10,7 +10,6 @@
#include <stack>
#include <boost/assert.hpp>
-#include "actions.hpp"
#include "state.hpp"
#include "gen_types.hpp"
#include "utils.hpp"
@@ -43,7 +42,7 @@
int indent;
};
- list2 process(quickbook::actions& actions, quickbook::list const& list)
+ list2 process(quickbook::state& state, quickbook::list const& list)
{
list::const_iterator it = list.begin(), end = list.end();
BOOST_ASSERT(it != end);
@@ -83,7 +82,7 @@
<< "Illegal change of list style near column " << pos.column << ".\n";
detail::outwarn(pos.file,pos.line)
<< "Ignoring change of list style" << std::endl;
- ++actions.state_.error_count;
+ ++state.error_count;
}
}
Modified: branches/quickbook-1.5-spirit2/doc_info_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info_actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/doc_info_actions.cpp 2010-02-07 04:12:20 EST (Sun, 07 Feb 2010)
@@ -16,13 +16,12 @@
#include "collector.hpp"
#include "quickbook.hpp"
#include "doc_info_actions.hpp"
-#include "actions.hpp"
#include "state.hpp"
#include "utils.hpp"
namespace quickbook
{
- doc_info process(quickbook::actions& actions, doc_info const& x)
+ doc_info process(quickbook::state& state, doc_info const& x)
{
doc_info info = x;
@@ -30,18 +29,17 @@
// *before* anything else.
if(!info.doc_title.empty())
- actions.state_.doc_title = info.doc_title;
+ state.doc_title = info.doc_title;
if(info.doc_id.empty())
info.doc_id = detail::make_identifier(
- actions.state_.doc_title.begin(),
- actions.state_.doc_title.end());
+ state.doc_title.begin(),state.doc_title.end());
- if(actions.state_.doc_id.empty())
- actions.state_.doc_id = info.doc_id;
+ if(state.doc_id.empty())
+ state.doc_id = info.doc_id;
if (info.doc_dirname.empty() && info.doc_type == "library")
- info.doc_dirname = actions.state_.doc_id;
+ info.doc_dirname = state.doc_id;
if (info.doc_last_revision.empty())
{
Modified: branches/quickbook-1.5-spirit2/doc_info_actions.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info_actions.hpp (original)
+++ branches/quickbook-1.5-spirit2/doc_info_actions.hpp 2010-02-07 04:12:20 EST (Sun, 07 Feb 2010)
@@ -17,7 +17,7 @@
namespace quickbook
{
- doc_info process(quickbook::actions&, doc_info const&);
+ doc_info process(quickbook::state&, doc_info const&);
}
#endif
Modified: branches/quickbook-1.5-spirit2/phrase_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_actions.cpp 2010-02-07 04:12:20 EST (Sun, 07 Feb 2010)
@@ -19,12 +19,12 @@
namespace quickbook
{
- nothing process(quickbook::actions& actions, source_mode const& s) {
- actions.state_.source_mode = s.mode;
+ nothing process(quickbook::state& state, source_mode const& s) {
+ state.source_mode = s.mode;
return nothing();
}
- std::string process(quickbook::actions& actions, macro const& x) {
+ std::string process(quickbook::state& state, macro const& x) {
if (x.raw_markup == quickbook_get_date)
{
char strdate[64];
@@ -43,7 +43,7 @@
}
}
- link process(quickbook::actions& actions, link const& x) {
+ link process(quickbook::state& state, link const& x) {
link r = x;
if(r.content.empty()) {
r.content = encode(x.destination);
@@ -51,7 +51,7 @@
return r;
}
- formatted process(quickbook::actions& actions, simple_markup const& x) {
+ formatted process(quickbook::state& state, simple_markup const& x) {
formatted r;
switch(x.symbol) {
case '*': r.type = "bold"; break;
@@ -66,20 +66,20 @@
return r;
}
- std::string process(quickbook::actions& actions, cond_phrase const& x) {
- bool symbol_found = actions.macro.find(x.macro_id.c_str());
+ std::string process(quickbook::state& state, cond_phrase const& x) {
+ bool symbol_found = state.macro.find(x.macro_id.c_str());
return (!x.content.empty() && symbol_found) ? x.content : "";
}
- break_ process(quickbook::actions& actions, break_ const& x) {
+ break_ process(quickbook::state& state, break_ const& x) {
detail::outwarn(x.position.file,x.position.line)
<< "in column:" << x.position.column << ", "
<< "[br] and \\n are deprecated" << ".\n";
return x;
}
- formatted process(quickbook::actions& actions, code const& x) {
+ formatted process(quickbook::state& state, code const& x) {
formatted r;
r.type = "";
@@ -98,12 +98,13 @@
// TODO: I don't need to save this, do I?
std::string save;
- actions.state_.phrase.swap(save);
+ state.phrase.swap(save);
// print the code with syntax coloring
+ quickbook::actions actions(state);
std::string str = actions.syntax_p(first_, last_);
- actions.state_.phrase.swap(save);
+ state.phrase.swap(save);
r.type = x.block ? "programlisting" : "code";
r.content = str;
Modified: branches/quickbook-1.5-spirit2/phrase_actions.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_actions.hpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_actions.hpp 2010-02-07 04:12:20 EST (Sun, 07 Feb 2010)
@@ -16,15 +16,15 @@
namespace quickbook
{
- nothing process(quickbook::actions&, source_mode const&);
- std::string process(quickbook::actions&, macro const&);
- link process(quickbook::actions&, link const&);
- formatted process(quickbook::actions&, simple_markup const&);
- std::string process(quickbook::actions&, cond_phrase const&);
- break_ process(quickbook::actions&, break_ const&);
- formatted process(quickbook::actions&, code const&);
- image2 process(quickbook::actions&, image const&);
- std::string process(quickbook::actions&, call_template const&);
+ nothing process(quickbook::state&, source_mode const&);
+ std::string process(quickbook::state&, macro const&);
+ link process(quickbook::state&, link const&);
+ formatted process(quickbook::state&, simple_markup const&);
+ std::string process(quickbook::state&, cond_phrase const&);
+ break_ process(quickbook::state&, break_ const&);
+ formatted process(quickbook::state&, code const&);
+ image2 process(quickbook::state&, image const&);
+ std::string process(quickbook::state&, call_template const&);
}
#endif
Modified: branches/quickbook-1.5-spirit2/phrase_image.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_image.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_image.cpp 2010-02-07 04:12:20 EST (Sun, 07 Feb 2010)
@@ -12,7 +12,6 @@
#include <boost/filesystem/fstream.hpp>
#include "phrase.hpp"
#include "gen_types.hpp"
-#include "actions.hpp"
#include "state.hpp"
#include "utils.hpp"
@@ -20,7 +19,7 @@
{
namespace fs = boost::filesystem;
- image2 process(quickbook::actions& actions, image const& x)
+ image2 process(quickbook::state& state, image const& x)
{
typedef image2::attribute_map attribute_map;
typedef attribute_map::value_type attribute;
@@ -42,7 +41,7 @@
<< "Duplicate image attribute: "
<< begin->first
<< std::endl;
- ++actions.state_.error_count;
+ ++state.error_count;
}
}
Modified: branches/quickbook-1.5-spirit2/process.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/process.cpp (original)
+++ branches/quickbook-1.5-spirit2/process.cpp 2010-02-07 04:12:20 EST (Sun, 07 Feb 2010)
@@ -25,11 +25,11 @@
template <typename T>
void process_action::operator()(T const& x) const
{
- output(actions.state_, process(actions, x));
+ output(actions.state_, process(actions.state_, x));
}
template <typename T>
- T const& process(quickbook::actions&, T const& x)
+ T const& process(quickbook::state&, T const& x)
{
return x;
}
Modified: branches/quickbook-1.5-spirit2/quickbook.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/quickbook.cpp (original)
+++ branches/quickbook-1.5-spirit2/quickbook.cpp 2010-02-07 04:12:20 EST (Sun, 07 Feb 2010)
@@ -48,7 +48,7 @@
//
///////////////////////////////////////////////////////////////////////////
int
- parse(char const* filein_, actions& actor, bool ignore_docinfo)
+ parse(char const* filein_, state& state_, bool ignore_docinfo)
{
using std::cerr;
using std::vector;
@@ -57,7 +57,7 @@
std::string storage;
int err = detail::load(filein_, storage);
if (err != 0) {
- ++actor.state_.error_count;
+ ++state_.error_count;
return err;
}
@@ -66,6 +66,7 @@
iterator start = first;
doc_info info;
+ actions actor(state_);
doc_info_grammar l(actor);
bool success = parse(first, last, l, info);
@@ -95,25 +96,24 @@
file_position const pos = first.get_position();
detail::outerr(pos.file,pos.line)
<< "Syntax Error near column " << pos.column << ".\n";
- ++actor.state_.error_count;
+ ++state_.error_count;
}
- if(actor.state_.error_count)
+ if(state_.error_count)
{
detail::outerr(filein_)
<< "Error count: " << actor.state_.error_count << ".\n";
}
- return actor.state_.error_count ? 1 : 0;
+ return state_.error_count ? 1 : 0;
}
static int
parse(char const* filein_, fs::path const& outdir, string_stream& out, bool ignore_docinfo = false)
{
quickbook::state state(filein_, outdir, out);
- actions actor(state);
- bool r = parse(filein_, actor);
- if (actor.state_.section_level != 0)
+ bool r = parse(filein_, state);
+ if (state.section_level != 0)
detail::outwarn(filein_)
<< "Warning missing [endsect] detected at end of file."
<< std::endl;
Modified: branches/quickbook-1.5-spirit2/quickbook.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/quickbook.hpp (original)
+++ branches/quickbook-1.5-spirit2/quickbook.hpp 2010-02-07 04:12:20 EST (Sun, 07 Feb 2010)
@@ -25,7 +25,7 @@
extern std::vector<std::string> include_path;
// forward declarations
- int parse(char const* filein_, actions& actor, bool ignore_docinfo = false);
+ int parse(char const* filein_, state&, bool ignore_docinfo = false);
}
#endif
Modified: branches/quickbook-1.5-spirit2/template.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/template.cpp (original)
+++ branches/quickbook-1.5-spirit2/template.cpp 2010-02-07 04:12:20 EST (Sun, 07 Feb 2010)
@@ -257,7 +257,7 @@
, std::vector<std::string> const& params
, template_scope const& scope
, file_position const& pos
- , quickbook::actions& actions
+ , quickbook::state& state
)
{
std::vector<std::string>::const_iterator arg = args.begin();
@@ -268,13 +268,13 @@
{
std::vector<std::string> empty_params;
- if (!actions.state_.templates.add(
+ if (!state.templates.add(
define_template(*tpl, empty_params, *arg, pos),
&scope))
{
detail::outerr(pos.file,pos.line)
<< "Duplicate Symbol Found" << std::endl;
- ++actions.state_.error_count;
+ ++state.error_count;
return std::make_pair(false, tpl);
}
++arg; ++tpl;
@@ -287,7 +287,7 @@
, std::string& result
, file_position const& template_pos
, bool template_escape
- , quickbook::actions& actions
+ , quickbook::state& state
)
{
// How do we know if we are to parse the template as a block or
@@ -312,17 +312,19 @@
}
else if (!is_block)
{
+ quickbook::actions actions(state);
simple_phrase_grammar phrase_p(actions);
// do a phrase level parse
- iterator first(body.begin(), body.end(), actions.state_.filename.native_file_string().c_str());
+ iterator first(body.begin(), body.end(), state.filename.native_file_string().c_str());
first.set_position(template_pos);
iterator last(body.end(), body.end());
r = boost::spirit::qi::parse(first, last, phrase_p) && first == last;
- actions.state_.phrase.swap(result);
+ state.phrase.swap(result);
}
else
{
+ quickbook::actions actions(state);
block_grammar block_p(actions);
// do a block level parse
@@ -331,25 +333,25 @@
body += "\n\n";
while (iter != body.end() && ((*iter == '\r') || (*iter == '\n')))
++iter; // skip initial newlines
- iterator first(iter, body.end(), actions.state_.filename.native_file_string().c_str());
+ iterator first(iter, body.end(), state.filename.native_file_string().c_str());
first.set_position(template_pos);
iterator last(body.end(), body.end());
r = boost::spirit::qi::parse(first, last, block_p) && first == last;
- actions.state_.phrase.swap(result);
+ state.phrase.swap(result);
}
return r;
}
}
- std::string process(quickbook::actions& actions, call_template const& x)
+ std::string process(quickbook::state& state, call_template const& x)
{
- ++actions.state_.template_depth;
- if (actions.state_.template_depth > actions.state_.max_template_depth)
+ ++state.template_depth;
+ if (state.template_depth > state.max_template_depth)
{
detail::outerr(x.position.file, x.position.line)
<< "Infinite loop detected" << std::endl;
- --actions.state_.template_depth;
- ++actions.state_.error_count;
+ --state.template_depth;
+ ++state.error_count;
return "";
}
@@ -358,17 +360,17 @@
//
// Note that for quickbook 1.4- this value is just ignored when the
// arguments are expanded.
- template_scope const& call_scope = actions.state_.templates.top_scope();
+ template_scope const& call_scope = state.templates.top_scope();
std::string result;
- actions.state_.push(); // scope the actions' states
+ state.push(); // scope the state
{
// Quickbook 1.4-: When expanding the tempalte continue to use the
// current scope (the dynamic scope).
// Quickbook 1.5+: Use the scope the template was defined in
// (the static scope).
if (qbk_version_n >= 105)
- actions.state_.templates.set_parent_scope(*x.symbol->parent);
+ state.templates.set_parent_scope(*x.symbol->parent);
std::vector<std::string> args = x.args;
@@ -376,9 +378,9 @@
// Break the arguments
if (!break_arguments(args, x.symbol->params, x.position))
{
- actions.state_.pop(); // restore the actions' states
- --actions.state_.template_depth;
- ++actions.state_.error_count;
+ state.pop(); // restore the state
+ --state.template_depth;
+ ++state.error_count;
return "";
}
@@ -388,19 +390,19 @@
std::vector<std::string>::const_iterator tpl;
boost::tie(get_arg_result, tpl) =
get_arguments(args, x.symbol->params,
- call_scope, x.position, actions);
+ call_scope, x.position, state);
if (!get_arg_result)
{
- actions.state_.pop(); // restore the actions' states
- --actions.state_.template_depth;
+ state.pop(); // restore the state
+ --state.template_depth;
return "";
}
///////////////////////////////////
// parse the template body:
- if (!parse_template(x.symbol->body, result, x.symbol->position, x.escape, actions))
+ if (!parse_template(x.symbol->body, result, x.symbol->position, x.escape, state))
{
detail::outerr(x.position.file,x.position.line)
//<< "Expanding template:" << x.symbol->identifier << std::endl
@@ -409,15 +411,15 @@
<< x.symbol->body
<< "------------------end--------------------" << std::endl
<< std::endl;
- actions.state_.pop(); // restore the actions' states
- --actions.state_.template_depth;
- ++actions.state_.error_count;
+ state.pop(); // restore the state
+ --state.template_depth;
+ ++state.error_count;
return "";
}
}
- actions.state_.pop(); // restore the actions' states
- --actions.state_.template_depth;
+ state.pop(); // restore the state
+ --state.template_depth;
return result;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk