stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork

This commit is contained in:
2026-02-24 18:38:47 +00:00
parent da8c28aaeb
commit 65cb2619a7
13106 changed files with 2484322 additions and 1804 deletions
@@ -0,0 +1,134 @@
// Copyright (c) 2001-2011 Hartmut Kaiser
// Copyright (c) 2001-2011 Joel de Guzman
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if !defined(BOOST_SPIRIT_KARMA_DEBUG_HANDLER_APR_21_2010_0148PM)
#define BOOST_SPIRIT_KARMA_DEBUG_HANDLER_APR_21_2010_0148PM
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/karma/nonterminal/rule.hpp>
#include <boost/spirit/home/karma/nonterminal/debug_handler_state.hpp>
#include <boost/function.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/out.hpp>
#include <iostream>
namespace boost { namespace spirit { namespace karma
{
template <
typename OutputIterator, typename Context, typename Delimiter
, typename Properties, typename F>
struct debug_handler
{
typedef detail::output_iterator<OutputIterator, Properties>
output_iterator;
typedef detail::enable_buffering<output_iterator> buffer_type;
typedef function<bool(output_iterator&, Context&, Delimiter const&)>
function_type;
debug_handler(function_type subject, F f, std::string const& rule_name)
: subject(subject)
, f(f)
, rule_name(rule_name)
{}
bool operator()(output_iterator& sink, Context& context
, Delimiter const& delim) const
{
buffer_type buffer(sink);
bool r = false;
f (sink, context, pre_generate, rule_name, buffer);
{
detail::disable_counting<output_iterator> nocount(sink);
r = subject(sink, context, delim);
}
if (r)
{
f (sink, context, successful_generate, rule_name, buffer);
buffer.buffer_copy();
return true;
}
f (sink, context, failed_generate, rule_name, buffer);
return false;
}
function_type subject;
F f;
std::string rule_name;
};
template <typename OutputIterator
, typename T1, typename T2, typename T3, typename T4, typename F>
void debug(rule<OutputIterator, T1, T2, T3, T4>& r, F f)
{
typedef rule<OutputIterator, T1, T2, T3, T4> rule_type;
typedef
debug_handler<
OutputIterator
, typename rule_type::context_type
, typename rule_type::delimiter_type
, typename rule_type::properties
, F>
debug_handler;
r.f = debug_handler(r.f, f, r.name());
}
struct simple_trace;
namespace detail
{
// This class provides an extra level of indirection through a
// template to produce the simple_trace type. This way, the use
// of simple_trace below is hidden behind a dependent type, so
// that compilers eagerly type-checking template definitions
// won't complain that simple_trace is incomplete.
template<typename T>
struct get_simple_trace
{
typedef simple_trace type;
};
}
template <typename OutputIterator
, typename T1, typename T2, typename T3, typename T4>
void debug(rule<OutputIterator, T1, T2, T3, T4>& r)
{
typedef rule<OutputIterator, T1, T2, T3, T4> rule_type;
typedef
debug_handler<
OutputIterator
, typename rule_type::context_type
, typename rule_type::delimiter_type
, typename rule_type::properties
, simple_trace>
debug_handler;
typedef typename karma::detail::get_simple_trace<OutputIterator>::type
trace;
r.f = debug_handler(r.f, trace(), r.name());
}
}}}
///////////////////////////////////////////////////////////////////////////////
// Utility macro for easy enabling of rule and grammar debugging
#if !defined(BOOST_SPIRIT_DEBUG_NODE)
#if defined(BOOST_SPIRIT_KARMA_DEBUG)
#define BOOST_SPIRIT_DEBUG_NODE(r) r.name(#r); debug(r)
#else
#define BOOST_SPIRIT_DEBUG_NODE(r) r.name(#r);
#endif
#endif
#endif
@@ -0,0 +1,23 @@
// Copyright (c) 2001-2011 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if !defined(BOOST_SPIRIT_KARMA_DEBUG_HANDLER_STATE_APR_21_2010_0736PM)
#define BOOST_SPIRIT_KARMA_DEBUG_HANDLER_STATE_APR_21_2010_0736PM
#if defined(_MSC_VER)
#pragma once
#endif
namespace boost { namespace spirit { namespace karma
{
enum debug_handler_state
{
pre_generate
, successful_generate
, failed_generate
};
}}}
#endif
@@ -0,0 +1,53 @@
// Copyright (c) 2001-2011 Joel de Guzman
// Copyright (c) 2001-2011 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PP_IS_ITERATING
#include <boost/preprocessor/iterate.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#define BOOST_PP_FILENAME_1 \
<boost/spirit/home/karma/nonterminal/detail/fcall.hpp>
#define BOOST_PP_ITERATION_LIMITS (1, SPIRIT_ARGUMENTS_LIMIT)
#include BOOST_PP_ITERATE()
///////////////////////////////////////////////////////////////////////////////
//
// Preprocessor vertical repetition code
//
///////////////////////////////////////////////////////////////////////////////
#else // defined(BOOST_PP_IS_ITERATING)
#define N BOOST_PP_ITERATION()
template <BOOST_PP_ENUM_PARAMS(N, typename A)>
typename lazy_enable_if_c<
(params_size == N)
, proto::terminal<
spirit::karma::parameterized_nonterminal<
parameterized_subject_type
, fusion::vector<BOOST_PP_ENUM_PARAMS(N, A)> >
>
>::type
operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& f)) const
{
typedef fusion::vector<BOOST_PP_ENUM_PARAMS(N, A)> vector_type;
typedef spirit::karma::parameterized_nonterminal<
parameterized_subject_type, vector_type> parameterized_type;
typedef typename proto::terminal<parameterized_type>::type result_type;
return result_type::make(
parameterized_type(
this->get_parameterized_subject()
, fusion::make_vector(BOOST_PP_ENUM_PARAMS(N, f)))
);
}
#undef N
#endif // defined(BOOST_PP_IS_ITERATING)
@@ -0,0 +1,86 @@
// Copyright (c) 2001-2011 Joel de Guzman
// Copyright (c) 2001-2011 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if !defined(BOOST_SPIRIT_GENERATOR_BINDER_APR_17_2009_0952PM)
#define BOOST_SPIRIT_GENERATOR_BINDER_APR_17_2009_0952PM
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/fusion/include/at.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/spirit/home/support/has_semantic_action.hpp>
namespace boost { namespace spirit { namespace karma { namespace detail
{
// generator_binder for plain rules
template <typename Generator, typename Auto>
struct generator_binder
{
generator_binder(Generator const& g)
: g(g) {}
template <typename OutputIterator, typename Delimiter, typename Context>
bool call(OutputIterator& sink, Context& context
, Delimiter const& delim, mpl::true_) const
{
// If DeducedAuto is false (semantic actions is present), the
// component's attribute is unused.
return g.generate(sink, context, delim, unused);
}
template <typename OutputIterator, typename Delimiter, typename Context>
bool call(OutputIterator& sink, Context& context
, Delimiter const& delim, mpl::false_) const
{
// If DeducedAuto is true (no semantic action), we pass the rule's
// attribute on to the component.
return g.generate(sink, context, delim
, fusion::at_c<0>(context.attributes));
}
template <typename OutputIterator, typename Delimiter, typename Context>
bool operator()(OutputIterator& sink, Context& context
, Delimiter const& delim) const
{
// If Auto is false, we need to deduce whether to apply auto rule
typedef typename traits::has_semantic_action<Generator>::type auto_rule;
return call(sink, context, delim, auto_rule());
}
Generator g;
};
// generator_binder for auto rules
template <typename Generator>
struct generator_binder<Generator, mpl::true_>
{
generator_binder(Generator const& g)
: g(g) {}
template <typename OutputIterator, typename Delimiter, typename Context>
bool operator()(OutputIterator& sink, Context& context
, Delimiter const& delim) const
{
// If Auto is true, the component's attribute is unused.
return g.generate(sink, context, delim
, fusion::at_c<0>(context.attributes));
}
Generator g;
};
template <typename Auto, typename Generator>
inline generator_binder<Generator, Auto>
bind_generator(Generator const& g)
{
return generator_binder<Generator, Auto>(g);
}
}}}}
#endif
@@ -0,0 +1,76 @@
// Copyright (c) 2001-2011 Joel de Guzman
// Copyright (c) 2001-2011 Hartmut Kaiser
// Copyright (c) 2009 Francois Barel
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if !defined(BOOST_SPIRIT_KARMA_PARAMETERIZED_AUGUST_09_2009_0601AM)
#define BOOST_SPIRIT_KARMA_PARAMETERIZED_AUGUST_09_2009_0601AM
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/ref.hpp>
#include <boost/spirit/home/support/handles_container.hpp>
#include <boost/spirit/home/karma/generator.hpp>
namespace boost { namespace spirit { namespace karma
{
///////////////////////////////////////////////////////////////////////////
// parameterized_nonterminal: generator representing the invocation of a
// nonterminal, passing inherited attributes
///////////////////////////////////////////////////////////////////////////
template <typename Subject, typename Params>
struct parameterized_nonterminal
: generator<parameterized_nonterminal<Subject, Params> >
{
typedef mpl::int_<generator_properties::all_properties> properties;
parameterized_nonterminal(Subject const& subject, Params const& params)
: ref(subject), params(params)
{
}
template <typename Context, typename Unused>
struct attribute
// Forward to subject.
: Subject::template attribute<Context, Unused> {};
template <typename OutputIterator, typename Context, typename Delimiter
, typename Attribute>
bool generate(OutputIterator& sink, Context& context
, Delimiter const& delim, Attribute const& attr) const
{
// Forward to subject, passing the additional
// params argument to generate.
return ref.get().generate(sink, context, delim, attr, params);
}
template <typename Context>
info what(Context& context) const
{
// Forward to subject.
return ref.get().what(context);
}
boost::reference_wrapper<Subject const> ref;
Params params;
};
}}}
namespace boost { namespace spirit { namespace traits
{
///////////////////////////////////////////////////////////////////////////
template <typename Subject, typename Params, typename Attribute
, typename Context, typename Iterator>
struct handles_container<karma::parameterized_nonterminal<Subject, Params>
, Attribute, Context, Iterator>
: handles_container<typename remove_const<Subject>::type
, Attribute, Context, Iterator>
{};
}}}
#endif
@@ -0,0 +1,134 @@
// Copyright (c) 2001-2011 Joel de Guzman
// Copyright (c) 2001-2011 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if !defined(BOOST_SPIRIT_KARMA_GRAMMAR_MAR_05_2007_0542PM)
#define BOOST_SPIRIT_KARMA_GRAMMAR_MAR_05_2007_0542PM
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/support/info.hpp>
#include <boost/spirit/home/support/assert_msg.hpp>
#include <boost/spirit/home/karma/domain.hpp>
#include <boost/spirit/home/karma/nonterminal/rule.hpp>
#include <boost/spirit/home/karma/nonterminal/nonterminal_fwd.hpp>
#include <boost/spirit/home/karma/reference.hpp>
#include <boost/noncopyable.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace spirit { namespace karma
{
template <
typename OutputIterator, typename T1, typename T2, typename T3
, typename T4>
struct grammar
: proto::extends<
typename proto::terminal<
reference<rule<OutputIterator, T1, T2, T3, T4> const>
>::type
, grammar<OutputIterator, T1, T2, T3, T4>
>
, generator<grammar<OutputIterator, T1, T2, T3, T4> >
, noncopyable
{
typedef OutputIterator iterator_type;
typedef rule<OutputIterator, T1, T2, T3, T4> start_type;
typedef typename start_type::properties properties;
typedef typename start_type::sig_type sig_type;
typedef typename start_type::locals_type locals_type;
typedef typename start_type::delimiter_type delimiter_type;
typedef typename start_type::encoding_type encoding_type;
typedef grammar<OutputIterator, T1, T2, T3, T4> base_type;
typedef reference<start_type const> reference_;
typedef typename proto::terminal<reference_>::type terminal;
static size_t const params_size = start_type::params_size;
template <typename Context, typename Unused>
struct attribute
{
typedef typename start_type::attr_type type;
};
// the output iterator is always wrapped by karma
typedef detail::output_iterator<OutputIterator, properties>
output_iterator;
grammar(start_type const& start
, std::string const& name_ = "unnamed-grammar")
: proto::extends<terminal, base_type>(terminal::make(reference_(start)))
, name_(name_)
{}
// This constructor is used to catch if the start rule is not
// compatible with the grammar.
template <typename Iterator_, typename T1_, typename T2_, typename T3_,
typename T4_>
grammar(rule<Iterator_, T1_, T2_, T3_, T4_> const&
, std::string const& = "unnamed-grammar")
{
// If you see the assertion below failing then the start rule
// passed to the constructor of the grammar is not compatible with
// the grammar (i.e. it uses different template parameters).
BOOST_SPIRIT_ASSERT_MSG(
(is_same<start_type, rule<Iterator_, T1_, T2_, T3_, T4_> >::value)
, incompatible_start_rule, (rule<Iterator_, T1_, T2_, T3_, T4_>));
}
std::string name() const
{
return name_;
}
void name(std::string const& str)
{
name_ = str;
}
template <typename Context, typename Delimiter, typename Attribute>
bool generate(output_iterator& sink, Context& context
, Delimiter const& delim, Attribute const& attr) const
{
return this->proto_base().child0.generate(
sink, context, delim, attr);
}
template <typename Context>
info what(Context&) const
{
return info(name_);
}
// bring in the operator() overloads
start_type const& get_parameterized_subject() const
{ return this->proto_base().child0.ref.get(); }
typedef start_type parameterized_subject_type;
#include <boost/spirit/home/karma/nonterminal/detail/fcall.hpp>
std::string name_;
};
}}}
namespace boost { namespace spirit { namespace traits
{
///////////////////////////////////////////////////////////////////////////
template <
typename IteratorA, typename IteratorB, typename Attribute
, typename Context, typename T1, typename T2, typename T3, typename T4>
struct handles_container<
karma::grammar<IteratorA, T1, T2, T3, T4>, Attribute, Context
, IteratorB>
: detail::nonterminal_handles_container<
typename attribute_of<
karma::grammar<IteratorA, T1, T2, T3, T4>
, Context, IteratorB
>::type, Attribute>
{};
}}}
#endif
@@ -0,0 +1,31 @@
// Copyright (c) 2001-2011 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if !defined(BOOST_SPIRIT_KARMA_NONTERMINAL_FWD_DEC_18_2010_0913PM)
#define BOOST_SPIRIT_KARMA_NONTERMINAL_FWD_DEC_18_2010_0913PM
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/spirit/home/support/unused.hpp>
namespace boost { namespace spirit { namespace karma
{
// forward declaration only
template <
typename OutputIterator, typename T1 = unused_type
, typename T2 = unused_type, typename T3 = unused_type
, typename T4 = unused_type>
struct rule;
template <
typename OutputIterator, typename T1 = unused_type
, typename T2 = unused_type, typename T3 = unused_type
, typename T4 = unused_type>
struct grammar;
}}}
#endif
@@ -0,0 +1,448 @@
// Copyright (c) 2001-2011 Joel de Guzman
// Copyright (c) 2001-2011 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if !defined(BOOST_SPIRIT_KARMA_RULE_MAR_05_2007_0455PM)
#define BOOST_SPIRIT_KARMA_RULE_MAR_05_2007_0455PM
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/function.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/type_traits/add_const.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/size.hpp>
#include <boost/fusion/include/make_vector.hpp>
#include <boost/fusion/include/cons.hpp>
#include <boost/fusion/include/as_list.hpp>
#include <boost/fusion/include/as_vector.hpp>
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/support/argument.hpp>
#include <boost/spirit/home/support/context.hpp>
#include <boost/spirit/home/support/info.hpp>
#include <boost/spirit/home/karma/delimit_out.hpp>
#include <boost/spirit/home/karma/detail/attributes.hpp>
#include <boost/spirit/home/support/nonterminal/extract_param.hpp>
#include <boost/spirit/home/support/nonterminal/locals.hpp>
#include <boost/spirit/home/karma/reference.hpp>
#include <boost/spirit/home/karma/detail/output_iterator.hpp>
#include <boost/spirit/home/karma/nonterminal/nonterminal_fwd.hpp>
#include <boost/spirit/home/karma/nonterminal/detail/generator_binder.hpp>
#include <boost/spirit/home/karma/nonterminal/detail/parameterized.hpp>
#if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable: 4127) // conditional expression is constant
# pragma warning(disable: 4355) // 'this' : used in base member initializer list warning
#endif
namespace boost { namespace spirit { namespace karma
{
BOOST_PP_REPEAT(SPIRIT_ATTRIBUTES_LIMIT, SPIRIT_USING_ATTRIBUTE, _)
using spirit::_pass_type;
using spirit::_val_type;
using spirit::_a_type;
using spirit::_b_type;
using spirit::_c_type;
using spirit::_d_type;
using spirit::_e_type;
using spirit::_f_type;
using spirit::_g_type;
using spirit::_h_type;
using spirit::_i_type;
using spirit::_j_type;
#ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
using spirit::_pass;
using spirit::_val;
using spirit::_a;
using spirit::_b;
using spirit::_c;
using spirit::_d;
using spirit::_e;
using spirit::_f;
using spirit::_g;
using spirit::_h;
using spirit::_i;
using spirit::_j;
#endif
using spirit::info;
using spirit::locals;
template <
typename OutputIterator, typename T1, typename T2, typename T3
, typename T4>
struct rule
: proto::extends<
typename proto::terminal<
reference<rule<OutputIterator, T1, T2, T3, T4> const>
>::type
, rule<OutputIterator, T1, T2, T3, T4>
>
, generator<rule<OutputIterator, T1, T2, T3, T4> >
{
typedef mpl::int_<generator_properties::all_properties> properties;
typedef OutputIterator iterator_type;
typedef rule<OutputIterator, T1, T2, T3, T4> this_type;
typedef reference<this_type const> reference_;
typedef typename proto::terminal<reference_>::type terminal;
typedef proto::extends<terminal, this_type> base_type;
typedef mpl::vector<T1, T2, T3, T4> template_params;
// the output iterator is always wrapped by karma
typedef detail::output_iterator<OutputIterator, properties>
output_iterator;
// locals_type is a sequence of types to be used as local variables
typedef typename
spirit::detail::extract_locals<template_params>::type
locals_type;
// The delimiter-generator type
typedef typename
spirit::detail::extract_component<
karma::domain, template_params>::type
delimiter_type;
// The rule's encoding type
typedef typename
spirit::detail::extract_encoding<template_params>::type
encoding_type;
// The rule's signature
typedef typename
spirit::detail::extract_sig<template_params, encoding_type, karma::domain>::type
sig_type;
// This is the rule's attribute type
typedef typename
spirit::detail::attr_from_sig<sig_type>::type
attr_type;
typedef typename add_reference<
typename add_const<attr_type>::type>::type
attr_reference_type;
// parameter_types is a sequence of types passed as parameters to the rule
typedef typename
spirit::detail::params_from_sig<sig_type>::type
parameter_types;
static size_t const params_size =
fusion::result_of::size<parameter_types>::type::value;
// the context passed to the right hand side of a rule contains
// the attribute and the parameters for this particular rule invocation
typedef context<
fusion::cons<attr_reference_type, parameter_types>
, locals_type>
context_type;
typedef function<
bool(output_iterator&, context_type&, delimiter_type const&)>
function_type;
typedef typename
mpl::if_<
is_same<encoding_type, unused_type>
, unused_type
, tag::char_code<tag::encoding, encoding_type>
>::type
encoding_modifier_type;
explicit rule(std::string const& name_ = "unnamed-rule")
: base_type(terminal::make(reference_(*this)))
, name_(name_)
{
}
rule(rule const& rhs)
: base_type(terminal::make(reference_(*this)))
, name_(rhs.name_)
, f(rhs.f)
{
}
template <typename Auto, typename Expr>
static void define(rule& lhs, Expr const& expr, mpl::false_)
{
// Report invalid expression error as early as possible.
// If you got an error_invalid_expression error message here,
// then the expression (expr) is not a valid spirit karma expression.
BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
}
template <typename Auto, typename Expr>
static void define(rule& lhs, Expr const& expr, mpl::true_)
{
lhs.f = detail::bind_generator<Auto>(
compile<karma::domain>(expr, encoding_modifier_type()));
}
template <typename Expr>
rule (Expr const& expr, std::string const& name_ = "unnamed-rule")
: base_type(terminal::make(reference_(*this)))
, name_(name_)
{
define<mpl::false_>(*this, expr, traits::matches<karma::domain, Expr>());
}
rule& operator=(rule const& rhs)
{
// The following assertion fires when you try to initialize a rule
// from an uninitialized one. Did you mean to refer to the right
// hand side rule instead of assigning from it? In this case you
// should write lhs = rhs.alias();
BOOST_ASSERT(rhs.f && "Did you mean rhs.alias() instead of rhs?");
f = rhs.f;
name_ = rhs.name_;
return *this;
}
std::string const& name() const
{
return name_;
}
void name(std::string const& str)
{
name_ = str;
}
template <typename Expr>
rule& operator=(Expr const& expr)
{
define<mpl::false_>(*this, expr, traits::matches<karma::domain, Expr>());
return *this;
}
// VC7.1 has problems to resolve 'rule' without explicit template parameters
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1400)
// g++ 3.3 barfs if this is a member function :(
template <typename Expr>
friend rule& operator%=(rule& r, Expr const& expr)
{
define<mpl::true_>(r, expr, traits::matches<karma::domain, Expr>());
return r;
}
#if defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
// non-const version needed to suppress proto's %= kicking in
template <typename Expr>
friend rule& operator%=(rule& r, Expr& expr)
{
return r %= static_cast<Expr const&>(expr);
}
#else
// for rvalue references
template <typename Expr>
friend rule& operator%=(rule& r, Expr&& expr)
{
define<mpl::true_>(r, expr, traits::matches<karma::domain, Expr>());
return r;
}
#endif
#else
// both friend functions have to be defined out of class as VC7.1
// will complain otherwise
template <typename OutputIterator_, typename T1_, typename T2_
, typename T3_, typename T4_, typename Expr>
friend rule<OutputIterator_, T1_, T2_, T3_, T4_>& operator%=(
rule<OutputIterator_, T1_, T2_, T3_, T4_>&r, Expr const& expr);
// non-const version needed to suppress proto's %= kicking in
template <typename OutputIterator_, typename T1_, typename T2_
, typename T3_, typename T4_, typename Expr>
friend rule<OutputIterator_, T1_, T2_, T3_, T4_>& operator%=(
rule<OutputIterator_, T1_, T2_, T3_, T4_>& r, Expr& expr);
#endif
template <typename Context, typename Unused>
struct attribute
{
typedef attr_type type;
};
template <typename Context, typename Delimiter, typename Attribute>
bool generate(output_iterator& sink, Context&, Delimiter const& delim
, Attribute const& attr) const
{
if (f)
{
// Create an attribute if none is supplied.
typedef traits::make_attribute<attr_type, Attribute>
make_attribute;
typedef traits::transform_attribute<
typename make_attribute::type, attr_type, domain>
transform;
typename transform::type attr_ =
traits::pre_transform<domain, attr_type>(
make_attribute::call(attr));
// If you are seeing a compilation error here, you are probably
// trying to use a rule or a grammar which has inherited
// attributes, without passing values for them.
context_type context(attr_);
// If you are seeing a compilation error here stating that the
// third parameter can't be converted to a karma::reference
// then you are probably trying to use a rule or a grammar with
// an incompatible delimiter type.
if (f(sink, context, delim))
{
// do a post-delimit if this is an implied verbatim
if (is_same<delimiter_type, unused_type>::value)
karma::delimit_out(sink, delim);
return true;
}
}
return false;
}
template <typename Context, typename Delimiter, typename Attribute
, typename Params>
bool generate(output_iterator& sink, Context& caller_context
, Delimiter const& delim, Attribute const& attr
, Params const& params) const
{
if (f)
{
// Create an attribute if none is supplied.
typedef traits::make_attribute<attr_type, Attribute>
make_attribute;
typedef traits::transform_attribute<
typename make_attribute::type, attr_type, domain>
transform;
typename transform::type attr_ =
traits::pre_transform<domain, attr_type>(
make_attribute::call(attr));
// If you are seeing a compilation error here, you are probably
// trying to use a rule or a grammar which has inherited
// attributes, passing values of incompatible types for them.
context_type context(attr_, params, caller_context);
// If you are seeing a compilation error here stating that the
// third parameter can't be converted to a karma::reference
// then you are probably trying to use a rule or a grammar with
// an incompatible delimiter type.
if (f(sink, context, delim))
{
// do a post-delimit if this is an implied verbatim
if (is_same<delimiter_type, unused_type>::value)
karma::delimit_out(sink, delim);
return true;
}
}
return false;
}
template <typename Context>
info what(Context& /*context*/) const
{
return info(name_);
}
reference_ alias() const
{
return reference_(*this);
}
typename proto::terminal<this_type>::type copy() const
{
typename proto::terminal<this_type>::type result = {*this};
return result;
}
// bring in the operator() overloads
rule const& get_parameterized_subject() const { return *this; }
typedef rule parameterized_subject_type;
#include <boost/spirit/home/karma/nonterminal/detail/fcall.hpp>
std::string name_;
function_type f;
};
#if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
template <typename OutputIterator_, typename T1_, typename T2_
, typename T3_, typename T4_, typename Expr>
rule<OutputIterator_, T1_, T2_, T3_, T4_>& operator%=(
rule<OutputIterator_, T1_, T2_, T3_, T4_>&r, Expr const& expr)
{
// Report invalid expression error as early as possible.
// If you got an error_invalid_expression error message here, then
// the expression (expr) is not a valid spirit karma expression.
BOOST_SPIRIT_ASSERT_MATCH(karma::domain, Expr);
typedef typename
rule<OutputIterator_, T1_, T2_, T3_, T4_>::encoding_modifier_type
encoding_modifier_type;
r.f = detail::bind_generator<mpl::true_>(
compile<karma::domain>(expr, encoding_modifier_type()));
return r;
}
// non-const version needed to suppress proto's %= kicking in
template <typename OutputIterator_, typename T1_, typename T2_
, typename T3_, typename T4_, typename Expr>
rule<OutputIterator_, T1_, T2_, T3_, T4_>& operator%=(
rule<OutputIterator_, T1_, T2_, T3_, T4_>& r, Expr& expr)
{
return r %= static_cast<Expr const&>(expr);
}
#endif
}}}
namespace boost { namespace spirit { namespace traits
{
namespace detail
{
template <typename RuleAttribute, typename Attribute>
struct nonterminal_handles_container
: mpl::and_<
traits::is_container<RuleAttribute>
, is_convertible<Attribute, RuleAttribute> >
{};
}
///////////////////////////////////////////////////////////////////////////
template <
typename IteratorA, typename IteratorB, typename Attribute
, typename Context, typename T1, typename T2, typename T3, typename T4>
struct handles_container<
karma::rule<IteratorA, T1, T2, T3, T4>, Attribute, Context
, IteratorB>
: detail::nonterminal_handles_container<
typename attribute_of<
karma::rule<IteratorA, T1, T2, T3, T4>
, Context, IteratorB
>::type, Attribute>
{};
}}}
#if defined(BOOST_MSVC)
# pragma warning(pop)
#endif
#endif
@@ -0,0 +1,134 @@
// Copyright (c) 2001-2011 Hartmut Kaiser
// Copyright (c) 2001-2011 Joel de Guzman
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if !defined(BOOST_SPIRIT_KARMA_SIMPLE_TRACE_APR_21_2010_0155PM)
#define BOOST_SPIRIT_KARMA_SIMPLE_TRACE_APR_21_2010_0155PM
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/spirit/home/support/unused.hpp>
#include <boost/spirit/home/karma/nonterminal/debug_handler_state.hpp>
#include <boost/fusion/include/out.hpp>
#include <iostream>
// The stream to use for debug output
#if !defined(BOOST_SPIRIT_DEBUG_OUT)
#define BOOST_SPIRIT_DEBUG_OUT std::cerr
#endif
// number of tokens to print while debugging
#if !defined(BOOST_SPIRIT_DEBUG_PRINT_SOME)
#define BOOST_SPIRIT_DEBUG_PRINT_SOME 20
#endif
// number of spaces to indent
#if !defined(BOOST_SPIRIT_DEBUG_INDENT)
#define BOOST_SPIRIT_DEBUG_INDENT 2
#endif
namespace boost { namespace spirit { namespace karma
{
struct simple_trace
{
int& get_indent() const
{
static int indent = 0;
return indent;
}
void print_indent() const
{
int n = get_indent();
n *= BOOST_SPIRIT_DEBUG_INDENT;
for (int i = 0; i != n; ++i)
BOOST_SPIRIT_DEBUG_OUT << ' ';
}
template <typename Buffer>
void print_some(char const* tag, Buffer const& buffer) const
{
print_indent();
BOOST_SPIRIT_DEBUG_OUT << '<' << tag << '>' << std::flush;
{
std::ostreambuf_iterator<char> out(BOOST_SPIRIT_DEBUG_OUT);
buffer.buffer_copy_to(out, BOOST_SPIRIT_DEBUG_PRINT_SOME);
}
BOOST_SPIRIT_DEBUG_OUT << "</" << tag << '>' << std::endl;
}
template <typename OutputIterator, typename Context, typename State
, typename Buffer>
void operator()(
OutputIterator&, Context const& context
, State state, std::string const& rule_name
, Buffer const& buffer) const
{
switch (state)
{
case pre_generate:
print_indent();
++get_indent();
BOOST_SPIRIT_DEBUG_OUT
<< '<' << rule_name << '>' << std::endl;
print_indent();
++get_indent();
BOOST_SPIRIT_DEBUG_OUT << "<try>" << std::endl;;
print_indent();
BOOST_SPIRIT_DEBUG_OUT << "<attributes>";
traits::print_attribute(
BOOST_SPIRIT_DEBUG_OUT,
context.attributes
);
BOOST_SPIRIT_DEBUG_OUT << "</attributes>" << std::endl;
if (!fusion::empty(context.locals))
{
print_indent();
BOOST_SPIRIT_DEBUG_OUT
<< "<locals>" << context.locals << "</locals>"
<< std::endl;
}
--get_indent();
print_indent();
BOOST_SPIRIT_DEBUG_OUT << "</try>" << std::endl;;
break;
case successful_generate:
print_indent();
++get_indent();
BOOST_SPIRIT_DEBUG_OUT << "<success>" << std::endl;
print_some("result", buffer);
if (!fusion::empty(context.locals))
{
print_indent();
BOOST_SPIRIT_DEBUG_OUT
<< "<locals>" << context.locals << "</locals>"
<< std::endl;
}
--get_indent();
print_indent();
BOOST_SPIRIT_DEBUG_OUT << "</success>" << std::endl;
--get_indent();
print_indent();
BOOST_SPIRIT_DEBUG_OUT
<< "</" << rule_name << '>' << std::endl;
break;
case failed_generate:
print_indent();
BOOST_SPIRIT_DEBUG_OUT << "<fail/>" << std::endl;
--get_indent();
print_indent();
BOOST_SPIRIT_DEBUG_OUT
<< "</" << rule_name << '>' << std::endl;
break;
}
}
};
}}}
#endif