stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2014 Joel de Guzman
|
||||
Copyright (c) 2013-2014 Agustin Berge
|
||||
|
||||
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_X3_AUXILIARY_ANY_PARSER_APR_09_2014_1145PM)
|
||||
#define BOOST_SPIRIT_X3_AUXILIARY_ANY_PARSER_APR_09_2014_1145PM
|
||||
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
#include <boost/spirit/home/x3/support/context.hpp>
|
||||
#include <boost/spirit/home/x3/support/subcontext.hpp>
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/container_traits.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/has_attribute.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/move_to.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/is_parser.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template <
|
||||
typename Iterator
|
||||
, typename Attribute = unused_type
|
||||
, typename Context = subcontext<>>
|
||||
struct any_parser : parser<any_parser<Iterator, Attribute, Context>>
|
||||
{
|
||||
typedef Attribute attribute_type;
|
||||
|
||||
static bool const has_attribute =
|
||||
!is_same<unused_type, attribute_type>::value;
|
||||
static bool const handles_container =
|
||||
traits::is_container<Attribute>::value;
|
||||
|
||||
public:
|
||||
any_parser()
|
||||
: _content(nullptr) {}
|
||||
|
||||
template <typename Expr,
|
||||
typename Enable = typename enable_if<traits::is_parser<Expr>>::type>
|
||||
any_parser(Expr const& expr)
|
||||
: _content(new holder<Expr>(expr)) {}
|
||||
|
||||
any_parser(any_parser const& other)
|
||||
: _content(other._content ? other._content->clone() : nullptr) {}
|
||||
|
||||
any_parser(any_parser&& other) = default;
|
||||
|
||||
any_parser& operator=(any_parser const& other)
|
||||
{
|
||||
_content.reset(other._content ? other._content->clone() : nullptr);
|
||||
return *this;
|
||||
}
|
||||
|
||||
any_parser& operator=(any_parser&& other) = default;
|
||||
|
||||
template <typename Iterator_, typename Context_>
|
||||
bool parse(Iterator_& first, Iterator_ const& last
|
||||
, Context_ const& context, unused_type, Attribute& attr) const
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(
|
||||
(is_same<Iterator, Iterator_>::value)
|
||||
, "Incompatible iterator used"
|
||||
);
|
||||
|
||||
BOOST_ASSERT_MSG(
|
||||
(_content != nullptr)
|
||||
, "Invalid use of uninitialized any_parser"
|
||||
);
|
||||
|
||||
return _content->parse(first, last, context, attr);
|
||||
}
|
||||
|
||||
template <typename Iterator_, typename Context_, typename Attribute_>
|
||||
bool parse(Iterator_& first, Iterator_ const& last
|
||||
, Context_ const& context, unused_type, Attribute_& attr_) const
|
||||
{
|
||||
Attribute attr;
|
||||
if (parse(first, last, context, unused, attr))
|
||||
{
|
||||
traits::move_to(attr, attr_);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string get_info() const
|
||||
{
|
||||
return _content ? _content->get_info() : "";
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
struct placeholder
|
||||
{
|
||||
virtual placeholder* clone() const = 0;
|
||||
|
||||
virtual bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, Attribute& attr) const = 0;
|
||||
|
||||
virtual std::string get_info() const = 0;
|
||||
|
||||
virtual ~placeholder() {}
|
||||
};
|
||||
|
||||
template <typename Expr>
|
||||
struct holder : placeholder
|
||||
{
|
||||
typedef typename extension::as_parser<Expr>::value_type parser_type;
|
||||
|
||||
explicit holder(Expr const& p)
|
||||
: _parser(as_parser(p)) {}
|
||||
|
||||
holder* clone() const override
|
||||
{
|
||||
return new holder(*this);
|
||||
}
|
||||
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, Attribute& attr) const override
|
||||
{
|
||||
return _parser.parse(first, last, context, unused, attr);
|
||||
}
|
||||
|
||||
std::string get_info() const override
|
||||
{
|
||||
return x3::what(_parser);
|
||||
}
|
||||
|
||||
parser_type _parser;
|
||||
};
|
||||
|
||||
private:
|
||||
std::unique_ptr<placeholder> _content;
|
||||
};
|
||||
|
||||
template <typename Iterator, typename Attribute, typename Context>
|
||||
struct get_info<any_parser<Iterator, Attribute, Context>>
|
||||
{
|
||||
typedef std::string result_type;
|
||||
std::string operator()(
|
||||
any_parser<Iterator, Attribute, Context> const& p) const
|
||||
{
|
||||
return p.get_info();
|
||||
}
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,131 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2011 Hartmut Kaiser
|
||||
Copyright (c) 2001-2014 Joel de Guzman
|
||||
Copyright (c) 2013 Agustin Berge
|
||||
|
||||
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_SPIRIT_X3_ATTR_JUL_23_2008_0956AM
|
||||
#define BOOST_SPIRIT_X3_ATTR_JUL_23_2008_0956AM
|
||||
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/container_traits.hpp>
|
||||
#include <boost/spirit/home/x3/support/traits/move_to.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
template <typename Value>
|
||||
struct attr_parser : parser<attr_parser<Value>>
|
||||
{
|
||||
typedef Value attribute_type;
|
||||
|
||||
static bool const has_attribute =
|
||||
!is_same<unused_type, attribute_type>::value;
|
||||
static bool const handles_container =
|
||||
traits::is_container<attribute_type>::value;
|
||||
|
||||
attr_parser(Value const& value)
|
||||
: value_(value) {}
|
||||
attr_parser(Value&& value)
|
||||
: value_(std::move(value)) {}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RuleContext, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RuleContext&, Attribute& attr_) const
|
||||
{
|
||||
// $$$ Change to copy_to once we have it $$$
|
||||
traits::move_to(value_, attr_);
|
||||
return true;
|
||||
}
|
||||
|
||||
Value value_;
|
||||
|
||||
private:
|
||||
// silence MSVC warning C4512: assignment operator could not be generated
|
||||
attr_parser& operator= (attr_parser const&);
|
||||
};
|
||||
|
||||
template <typename Value, std::size_t N>
|
||||
struct attr_parser<Value[N]> : parser<attr_parser<Value[N]>>
|
||||
{
|
||||
typedef Value attribute_type[N];
|
||||
|
||||
static bool const has_attribute =
|
||||
!is_same<unused_type, attribute_type>::value;
|
||||
static bool const handles_container = true;
|
||||
|
||||
attr_parser(Value const (&value)[N])
|
||||
{
|
||||
std::copy(value + 0, value + N, value_ + 0);
|
||||
}
|
||||
|
||||
attr_parser(Value (&&value)[N])
|
||||
{
|
||||
std::move(value + 0, value + N, value_ + 0);
|
||||
}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RuleContext, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RuleContext&, Attribute& attr_) const
|
||||
{
|
||||
// $$$ Change to copy_to once we have it $$$
|
||||
traits::move_to(value_ + 0, value_ + N, attr_);
|
||||
return true;
|
||||
}
|
||||
|
||||
Value value_[N];
|
||||
|
||||
private:
|
||||
// silence MSVC warning C4512: assignment operator could not be generated
|
||||
attr_parser& operator= (attr_parser const&);
|
||||
};
|
||||
|
||||
template <typename Value>
|
||||
struct get_info<attr_parser<Value>>
|
||||
{
|
||||
typedef std::string result_type;
|
||||
std::string operator()(attr_parser<Value> const& /*p*/) const
|
||||
{
|
||||
return "attr";
|
||||
}
|
||||
};
|
||||
|
||||
struct attr_gen
|
||||
{
|
||||
template <typename Value>
|
||||
attr_parser<typename remove_cv<
|
||||
typename remove_reference<Value>::type>::type>
|
||||
operator()(Value&& value) const
|
||||
{
|
||||
return { std::forward<Value>(value) };
|
||||
}
|
||||
|
||||
template <typename Value, std::size_t N>
|
||||
attr_parser<typename remove_cv<Value>::type[N]>
|
||||
operator()(Value (&value)[N]) const
|
||||
{
|
||||
return { value };
|
||||
}
|
||||
template <typename Value, std::size_t N>
|
||||
attr_parser<typename remove_cv<Value>::type[N]>
|
||||
operator()(Value (&&value)[N]) const
|
||||
{
|
||||
return { value };
|
||||
}
|
||||
};
|
||||
|
||||
auto const attr = attr_gen{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,41 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2014 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_X3_EOI_MARCH_23_2007_0454PM)
|
||||
#define BOOST_SPIRIT_X3_EOI_MARCH_23_2007_0454PM
|
||||
|
||||
#include <boost/spirit/home/x3/core/skip_over.hpp>
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
struct eoi_parser : parser<eoi_parser>
|
||||
{
|
||||
typedef unused_type attribute_type;
|
||||
static bool const has_attribute = false;
|
||||
|
||||
template <typename Iterator, typename Context, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, unused_type, Attribute&) const
|
||||
{
|
||||
x3::skip_over(first, last, context);
|
||||
return first == last;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_info<eoi_parser>
|
||||
{
|
||||
typedef std::string result_type;
|
||||
result_type operator()(eoi_parser const &) const { return "eoi"; }
|
||||
};
|
||||
|
||||
auto const eoi = eoi_parser{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2014 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_X3_EOL_MARCH_23_2007_0454PM)
|
||||
#define BOOST_SPIRIT_X3_EOL_MARCH_23_2007_0454PM
|
||||
|
||||
#include <boost/spirit/home/x3/core/skip_over.hpp>
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
struct eol_parser : parser<eol_parser>
|
||||
{
|
||||
typedef unused_type attribute_type;
|
||||
static bool const has_attribute = false;
|
||||
|
||||
template <typename Iterator, typename Context, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, unused_type, Attribute& /*attr*/) const
|
||||
{
|
||||
x3::skip_over(first, last, context);
|
||||
Iterator iter = first;
|
||||
bool matched = false;
|
||||
if (iter != last && *iter == '\r') // CR
|
||||
{
|
||||
matched = true;
|
||||
++iter;
|
||||
}
|
||||
if (iter != last && *iter == '\n') // LF
|
||||
{
|
||||
matched = true;
|
||||
++iter;
|
||||
}
|
||||
|
||||
if (matched) first = iter;
|
||||
return matched;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct get_info<eol_parser>
|
||||
{
|
||||
typedef std::string result_type;
|
||||
result_type operator()(eol_parser const &) const { return "eol"; }
|
||||
};
|
||||
|
||||
auto const eol = eol_parser{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,86 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2014 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_X3_EPS_MARCH_23_2007_0454PM)
|
||||
#define BOOST_SPIRIT_X3_EPS_MARCH_23_2007_0454PM
|
||||
|
||||
#include <boost/spirit/home/x3/core/skip_over.hpp>
|
||||
#include <boost/spirit/home/x3/core/parser.hpp>
|
||||
#include <boost/spirit/home/x3/support/unused.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
struct rule_context_tag;
|
||||
|
||||
struct semantic_predicate : parser<semantic_predicate>
|
||||
{
|
||||
typedef unused_type attribute_type;
|
||||
static bool const has_attribute = false;
|
||||
|
||||
semantic_predicate(bool predicate)
|
||||
: predicate(predicate) {}
|
||||
|
||||
template <typename Iterator, typename Context, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, unused_type, Attribute&) const
|
||||
{
|
||||
x3::skip_over(first, last, context);
|
||||
return predicate;
|
||||
}
|
||||
|
||||
bool predicate;
|
||||
};
|
||||
|
||||
template <typename F>
|
||||
struct lazy_semantic_predicate : parser<lazy_semantic_predicate<F>>
|
||||
{
|
||||
typedef unused_type attribute_type;
|
||||
static bool const has_attribute = false;
|
||||
|
||||
lazy_semantic_predicate(F f)
|
||||
: f(f) {}
|
||||
|
||||
template <typename Iterator, typename Context, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, unused_type, Attribute& attr) const
|
||||
{
|
||||
x3::skip_over(first, last, context);
|
||||
return f(x3::get<rule_context_tag>(context));
|
||||
}
|
||||
|
||||
F f;
|
||||
};
|
||||
|
||||
struct eps_parser : parser<eps_parser>
|
||||
{
|
||||
typedef unused_type attribute_type;
|
||||
static bool const has_attribute = false;
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RuleContext, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RuleContext&, Attribute&) const
|
||||
{
|
||||
x3::skip_over(first, last, context);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline semantic_predicate operator()(bool predicate) const
|
||||
{
|
||||
return { predicate };
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
lazy_semantic_predicate<F> operator()(F f) const
|
||||
{
|
||||
return { f };
|
||||
}
|
||||
};
|
||||
|
||||
auto const eps = eps_parser{};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2014 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_X3_GUARD_FERBRUARY_02_2013_0649PM)
|
||||
#define BOOST_SPIRIT_X3_GUARD_FERBRUARY_02_2013_0649PM
|
||||
|
||||
#include <boost/spirit/home/x3/support/context.hpp>
|
||||
#include <boost/spirit/home/x3/directive/expect.hpp>
|
||||
|
||||
namespace boost { namespace spirit { namespace x3
|
||||
{
|
||||
enum class error_handler_result
|
||||
{
|
||||
fail
|
||||
, retry
|
||||
, accept
|
||||
, rethrow
|
||||
};
|
||||
|
||||
template <typename Subject, typename Handler>
|
||||
struct guard : unary_parser<Subject, guard<Subject, Handler>>
|
||||
{
|
||||
typedef unary_parser<Subject, guard<Subject, Handler>> base_type;
|
||||
static bool const is_pass_through_unary = true;
|
||||
|
||||
guard(Subject const& subject, Handler handler)
|
||||
: base_type(subject), handler(handler) {}
|
||||
|
||||
template <typename Iterator, typename Context
|
||||
, typename RuleContext, typename Attribute>
|
||||
bool parse(Iterator& first, Iterator const& last
|
||||
, Context const& context, RuleContext& rcontext, Attribute& attr) const
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
try
|
||||
{
|
||||
Iterator i = first;
|
||||
bool r = this->subject.parse(i, last, context, rcontext, attr);
|
||||
if (r)
|
||||
first = i;
|
||||
return r;
|
||||
}
|
||||
catch (expectation_failure<Iterator> const& x)
|
||||
{
|
||||
switch (handler(first, last, x, context))
|
||||
{
|
||||
case error_handler_result::fail:
|
||||
return false;
|
||||
case error_handler_result::retry:
|
||||
continue;
|
||||
case error_handler_result::accept:
|
||||
return true;
|
||||
case error_handler_result::rethrow:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Handler handler;
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user